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

[MOB-9974] fix event replay from visitor to known user #845

Open
wants to merge 1 commit into
base: feature/itbl_track_anon_user
Choose a base branch
from

Conversation

evantk91
Copy link
Collaborator

@evantk91 evantk91 commented Oct 15, 2024

🔹 Jira Ticket(s)

✏️ Description

This pull request updates attemptAndProcessMerge to call syncEvents directly. Also, modifies flow to set userId/email before attempting event replay.

@evantk91 evantk91 changed the base branch from master to feature/itbl_track_anon_user October 15, 2024 21:41
func syncNonSyncedEvents()
func syncEvents()
Copy link
Member

Choose a reason for hiding this comment

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

Question on why are we deciding to stop using the syncNonSyncedEvents method that just adds a delay in execution of the syncEvents method?

On the InternalIterableAPI method attemptAndProcessMerge we can easily still call syncNonSyncedEvents instead right? Is there any reason why we want to use the syncEvents method directly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Calling that function was clearing the local storage for some odd reason

Copy link
Member

Choose a reason for hiding this comment

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

Hm, I see. Maybe there's a race condition issue then?

Comment on lines +154 to +160
if(config.enableAnonTracking) {
if(email != nil) {
attemptAndProcessMerge(merge: merge ?? true, replay: replay ?? true, destinationUser: email, isEmail: true, failureHandler: failureHandler)
}
self.localStorage.userIdAnnon = nil
}

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if(config.enableAnonTracking) {
if(email != nil) {
attemptAndProcessMerge(merge: merge ?? true, replay: replay ?? true, destinationUser: email, isEmail: true, failureHandler: failureHandler)
}
self.localStorage.userIdAnnon = nil
}
if config.enableAnonTracking, let email = email {
attemptAndProcessMerge(
merge: merge ?? true,
replay: replay ?? true,
destinationUser: email,
isEmail: true,
failureHandler: failureHandler
)
self.localStorage.userIdAnnon = nil
}

Copy link
Member

Choose a reason for hiding this comment

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

Just code style suggestion. It helps reducing the nesting and makes the code easier to read!
Also, in Swift you don't need to add the ( ) on if statements.

Comment on lines +188 to +197
if(config.enableAnonTracking) {
if(userId != nil && userId != localStorage.userIdAnnon) {
attemptAndProcessMerge(merge: merge ?? true, replay: replay ?? true, destinationUser: userId, isEmail: false, failureHandler: failureHandler)
}

if(!isAnon) {
self.localStorage.userIdAnnon = nil
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if(config.enableAnonTracking) {
if(userId != nil && userId != localStorage.userIdAnnon) {
attemptAndProcessMerge(merge: merge ?? true, replay: replay ?? true, destinationUser: userId, isEmail: false, failureHandler: failureHandler)
}
if(!isAnon) {
self.localStorage.userIdAnnon = nil
}
}
if config.enableAnonTracking {
if let userId = userId, userId != localStorage.userIdAnnon {
attemptAndProcessMerge(
merge: merge ?? true,
replay: replay ?? true,
destinationUser: userId,
isEmail: false,
failureHandler: failureHandler
)
}
if !isAnon {
localStorage.userIdAnnon = nil
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Same comment here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants