diff --git a/Sources/Classes/Headers/Public/RSClient.h b/Sources/Classes/Headers/Public/RSClient.h index 78d83535..a8ba8e5c 100644 --- a/Sources/Classes/Headers/Public/RSClient.h +++ b/Sources/Classes/Headers/Public/RSClient.h @@ -51,6 +51,7 @@ typedef void (^Callback)(NSObject *_Nullable); - (void) group:(NSString *)groupId traits:(NSDictionary*)traits; - (void) group:(NSString *)groupId; +- (void) alias:(NSString *)newId previousId:(NSString * _Nullable)previousId options:(RSOption * _Nullable) options; - (void) alias:(NSString *)newId options:(RSOption * _Nullable) options; - (void) alias:(NSString *)newId; diff --git a/Sources/Classes/RSClient.m b/Sources/Classes/RSClient.m index 3cc6a058..66831379 100644 --- a/Sources/Classes/RSClient.m +++ b/Sources/Classes/RSClient.m @@ -225,10 +225,14 @@ - (void)alias:(NSString *)newId { [self reportDiscardedEvent]; return; } - [self alias:newId options:nil]; + [self alias:newId previousId:nil options:nil]; } - (void) alias:(NSString *)newId options:(RSOption *) options { + [self alias:newId previousId:nil options:options]; +} + +- (void) alias:(NSString *)newId previousId:(NSString *)previousId options:(RSOption *) options { if ([RSClient getOptStatus]) { [self reportDiscardedEvent]; return; @@ -236,7 +240,7 @@ - (void) alias:(NSString *)newId options:(RSOption *) options { RSContext *rc = [RSElementCache getContext]; NSMutableDictionary* traits = [rc.traits mutableCopy]; - NSObject *prevId = [traits objectForKey:@"userId"] ?: [traits objectForKey:@"id"] ?: self.anonymousId; + NSObject *prevId = previousId ?: [traits objectForKey:@"userId"] ?: [traits objectForKey:@"id"] ?: self.anonymousId; traits[@"id"] = newId; traits[@"userId"] = newId;