Skip to content
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: set anonymousId as previousId in alias API if userId is not present #553

Merged
merged 4 commits into from
Dec 6, 2024

Conversation

1abhishekpandey
Copy link
Contributor

Description

  • In the existing alias API, set anonymousId as previousId, if userId is not present.
  • This case will happen when an alias event is made before any identify event is made. In this case, previousId needs to be set as anonymousId but currently this field is not present. So we've added a fix to add the correct value.

@1abhishekpandey 1abhishekpandey self-assigned this Nov 26, 2024
@1abhishekpandey 1abhishekpandey marked this pull request as ready for review December 2, 2024 03:09
@1abhishekpandey 1abhishekpandey requested a review from a team as a code owner December 2, 2024 03:09
Comment on lines 243 to 245
if (prevId == nil) {
prevId = self.anonymousId;
}
Copy link
Contributor

@SKannaniOS SKannaniOS Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To simplify multiple if conditions, use the Ternary Conditional Operator (?:) as shown below.

NSObject *prevId = [traits objectForKey:@"userId"] ?: [traits objectForKey:@"id"] ?: self.anonymousId;

@1abhishekpandey 1abhishekpandey merged commit 67c6715 into develop Dec 6, 2024
13 checks passed
@1abhishekpandey 1abhishekpandey deleted the fix/sdk-2669-ios-fix-alias-api branch December 6, 2024 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants