-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RUM-7795 Anonymous RUM Identifier #2172
base: develop
Are you sure you want to change the base?
Conversation
Datadog ReportBranch report: ✅ 0 Failed, 1013 Passed, 2754 Skipped, 47.38s Total duration (1m 45.5s time saved) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGMT! Only a few minor comments.
DatadogRUM/Tests/Integrations/AnonymousIdentifierManagerTests.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks great overall 👌 - I only left suggestions on naming and documenting the public API.
Requesting a change tho, to add integration unit tests for this feature. Using real instance of the SDK + proxy and asserting that anonymous ID is generated and inserted into events of two RUM sessions started in two instances of the SDK. I can help and pair on this 🙌
Co-authored-by: Maciek Grzybowski <[email protected]>
7ca3267
# Conflicts: # api-surface-swift
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the the anonymous id naming be consistent?
There is AnonymousIdentifier
, AnonymousId
and AnonymousID
in the code.
Datadog/IntegrationUnitTests/RUM/AnonymousIdentifierTests.swift
Outdated
Show resolved
Hide resolved
@simaoseica-dd Thanks for the review. I addressed all the comments. For naming I went for full Let me know if it looks more consistent. |
Datadog ReportBranch report: ✅ 0 Failed, 627 Passed, 3177 Skipped, 27.43s Total duration (2m 2.73s time saved) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👌
self?.featureScope.set(anonymousId: anonymousId) | ||
} else { | ||
let anonymousId = self?.uuidGenerator.generateUnique().toRUMDataFormat | ||
self?.featureScope.rumDataStore.setValue(anonymousId, forKey: .anonymousId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to update the rumDataStore
as well if the anonymousId
already exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let anonymousId = anonymousId ?? self?.uuidGenerator.generateUnique().toRUMDataFormat
And then the rumDataStore.setValue
and featureScope.set
?
@@ -31,5 +31,6 @@ class RUMConfigurationTests: XCTestCase { | |||
XCTAssertNil(config.longTaskEventMapper) | |||
XCTAssertNil(config.onSessionStart) | |||
XCTAssertNil(config.customEndpoint) | |||
XCTAssertEqual(config.trackAnonymousUser, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
XCTAssertEqual(config.trackAnonymousUser, true) | |
XCTAssertTrue(config.trackAnonymousUser) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small nits
👍
|
||
assertAnonymousIdentifier(isSet: true, in: session2) | ||
let anonymousId2 = session2.views.last?.viewEvents.first?.usr?.anonymousId | ||
XCTAssertEqual(anonymousId1, anonymousId1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo here. Always asserts.
@@ -330,4 +330,87 @@ class DatadogCoreTests: XCTestCase { | |||
core.flush() | |||
XCTAssertEqual(requestBuilderSpy.requestParameters.count, 0, "It should not send any request") | |||
} | |||
|
|||
func testItAppendsUserDataIfAnonymousIdentifierExists() { | |||
let core = DatadogCore( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit/ DatadogCoreProxy()
? and in the other tests too?
self?.featureScope.set(anonymousId: anonymousId) | ||
} else { | ||
let anonymousId = self?.uuidGenerator.generateUnique().toRUMDataFormat | ||
self?.featureScope.rumDataStore.setValue(anonymousId, forKey: .anonymousId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let anonymousId = anonymousId ?? self?.uuidGenerator.generateUnique().toRUMDataFormat
And then the rumDataStore.setValue
and featureScope.set
?
What and why?
Adds capability of tracking anonymous id (enabled by default). This data allows linking sessions coming from the same device.
How?
Following proposal from this RFC (internal) it reuses data store mechanism, and based on configuration it generates and reuses stored identifier.
This identifier is attached to
UserInfo
object (schema already updated), which is enriching other SDK events.Review checklist
make api-surface
)