Skip to content

Commit

Permalink
Pushed save of anonId higher up into the flow. (#977)
Browse files Browse the repository at this point in the history
* Pushed save of anonId higher up into the flow.

* Removed api endpoint test.

Co-authored-by: Brandon Sneed <[email protected]>
  • Loading branch information
bsneed and Brandon Sneed authored Mar 9, 2021
1 parent ce4280d commit e35f1c9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Segment/Classes/SEGAnalytics.m
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ - (void)identify:(NSString *)userId traits:(NSDictionary *)traits options:(NSDic
NSString *anonId = [options objectForKey:@"anonymousId"];
if (anonId == nil) {
anonId = [self getAnonymousId];
} else {
[self.integrationsManager saveAnonymousId:anonId];
}
// configure traits to match what is seen on android.
NSMutableDictionary *existingTraitsCopy = [[SEGState sharedInstance].userInfo.traits mutableCopy];
Expand Down
1 change: 1 addition & 0 deletions Segment/Internal/SEGIntegrationsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ NS_SWIFT_NAME(IntegrationsManager)

// @Deprecated - Exposing for backward API compat reasons only
- (NSString *_Nonnull)getAnonymousId;
- (void)saveAnonymousId:(NSString *)anonymousId;

@end

Expand Down
9 changes: 0 additions & 9 deletions Segment/Internal/SEGIntegrationsManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,6 @@ - (void)identify:(SEGIdentifyPayload *)payload
{
NSCAssert2(payload.userId.length > 0 || payload.traits.count > 0, @"either userId (%@) or traits (%@) must be provided.", payload.userId, payload.traits);

NSString *anonymousId = payload.anonymousId;
NSString *existingAnonymousId = self.cachedAnonymousId;

if (anonymousId == nil) {
payload.anonymousId = anonymousId;
} else if (![anonymousId isEqualToString:existingAnonymousId]) {
[self saveAnonymousId:anonymousId];
}

[self callIntegrationsWithSelector:NSSelectorFromString(@"identify:")
arguments:@[ payload ]
options:payload.options
Expand Down
3 changes: 2 additions & 1 deletion SegmentTests/AnalyticsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class AnalyticsTests: XCTestCase {
XCTAssertEqual(config.flushInterval, 30)
XCTAssertEqual(config.maxQueueSize, 1000)
XCTAssertEqual(config.writeKey, "QUI5ydwIGeFFTa1IvCBUhxL9PyW5B0jE")
XCTAssertEqual(config.apiHost?.absoluteString, "https://api.segment.io/v1")
// not needed as segment settings API can provide different host values now.
//XCTAssertEqual(config.apiHost?.absoluteString, "https://api.segment.io/v1")
XCTAssertEqual(config.shouldUseLocationServices, false)
XCTAssertEqual(config.enableAdvertisingTracking, true)
XCTAssertEqual(config.shouldUseBluetooth, false)
Expand Down

0 comments on commit e35f1c9

Please sign in to comment.