-
Notifications
You must be signed in to change notification settings - Fork 333
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
fix: allow setting anonymousId #799
Conversation
LGTM, but probably needs another set of eyes |
AnalyticsTests/TrackingTests.swift
Outdated
@@ -36,6 +36,20 @@ class TrackingTests: QuickSpec { | |||
expect(passthrough.lastContext?.eventType) == SEGEventType.identify | |||
let identify = passthrough.lastContext?.payload as? SEGIdentifyPayload | |||
expect(identify?.userId) == "testUserId1" | |||
expect(identify?.anonymousId) == nil |
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.
You need to use the beNil
matcher to match nil
:
expect(identify?.anonymousId).to(beNil())
The tests are breaking because you match an Optional
with a pointer (nil? == nil
)
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.
updated!
Historically, the iOS library has allowed setting a custom anonymous identifier (#485). During adding middlewares, a bug was introduced which started ignoring the anonymousId option. This fixes the bug and adds a test to validate the fix. This was also tested in the example app end to end and I've verified that events show up with the custom anonymousId. Test snipet: ``` [[SEGAnalytics sharedAnalytics] identify:@"Prateek" traits:nil options: @{ @"anonymousId":@"test_anonymousId" }]; ``` Event in debugger: https://cloudup.com/cFyVH4NPR_f Subsequent events will automatically attach the new anonymous ID https://cloudup.com/cK-i_SCbwsN
aa9fb47
to
0e98d4a
Compare
Historically, the iOS library has allowed setting a custom anonymous identifier (segmentio#485). During adding middlewares, a bug was introduced which started ignoring the anonymousId option. This fixes the bug and adds a test to validate the fix. This was also tested in the example app end to end and I've verified that events show up with the custom anonymousId. Test snipet: ``` [[SEGAnalytics sharedAnalytics] identify:@"Prateek" traits:nil options: @{ @"anonymousId":@"test_anonymousId" }]; ``` Event in debugger: https://cloudup.com/cFyVH4NPR_f Subsequent events will automatically attach the new anonymous ID https://cloudup.com/cK-i_SCbwsN
Historically, the iOS library has allowed setting a custom anonymous identifier (#485).
During adding middlewares, a bug was introduced which started ignoring the anonymousId option.
This fixes the bug and adds a test to validate the fix. This was also tested in the example app end to end and I've verified that events show up with the custom anonymousId.
How should this be manually tested?
Test snipet:
Event in debugger: https://cloudup.com/cFyVH4NPR_f
Subsequent events will automatically attach the new anonymous ID https://cloudup.com/cK-i_SCbwsN
Closes #753
What are the relevant tickets?
https://segment.atlassian.net/browse/LIB-266