-
Notifications
You must be signed in to change notification settings - Fork 262
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
[Bug] Fix processing of Identify User response if the user has changed since then #1427
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nan-li
changed the title
[Bug] Fix processing of Identify User response if the user has changed since then
WIP - [Bug] Fix processing of Identify User response if the user has changed since then
May 7, 2024
nan-li
force-pushed
the
fix/identify_user_bug_when_in_the_middle
branch
from
May 8, 2024 02:02
ecd010b
to
46edda1
Compare
nan-li
changed the title
WIP - [Bug] Fix processing of Identify User response if the user has changed since then
[Bug] Fix processing of Identify User response if the user has changed since then
May 8, 2024
nan-li
force-pushed
the
fix/identify_user_bug_when_in_the_middle
branch
from
May 8, 2024 02:17
46edda1
to
f214e69
Compare
nan-li
requested review from
jkasten2,
emawby,
jinliu9508,
shepherd-l and
jennantilla
May 8, 2024 17:45
* This is more realistic as real requests have a delay * This change was motivated by this flow: anon -> login (identify user) -> login (create user) * When the requests ran synchronously, when the identify user request returned, the "current user" was still itself.
* Create some default helper methods
* Before the fix in this PR, this test would fail because tags for user A do not get sent
nan-li
force-pushed
the
fix/identify_user_bug_when_in_the_middle
branch
from
May 8, 2024 21:35
f214e69
to
6cdedc3
Compare
* OneSignalUserMocks needed a dependency on XCTest apparently * Because it depends on OneSignalCoreMocks now, who uses XCTest
* Fix an assert about where a set of tags is sent * This test previously succeeded because all the requests are processed synchronously, but after we introduced async client requests, this test failed because it was not the correct actual behavior * Also use the new client response setting helpers (no logic change)
* Motivation: consider the scenario Anon -> Login (Identify User) -> Make Updates like Tags -> Login (Create User) * When the Identify User request returns, because the user is now different, we were not hydrating the previous user's OSID, so updates made to it were dropped. Now we still fetch the user to hydrate the OSID. * In addition, transfer subscription had a bug. What would happen is after the last Create User is sent with the device's push subscription in the payload, the Transfer Subscription request would come next and move it back to the middle user. Now we only transfer if it's still the same user. Any Create User requests after would already have the push subscription in it.
* See the URL that the response was for
* When Identify User returns 409, there may be pending requests for that user. * Avoid another user fetch just to hydrate the OSID, and instead use the external_id that we have for this user to send those pending requests. * Also, the `fetchUser` is meant only for the current user, as it clears local state for hydration. We avoid refactoring that method as well. * Add new concept of "default alias" that lives on an Identity Model and indicates what alias should be used for requests.
nan-li
force-pushed
the
fix/identify_user_bug_when_in_the_middle
branch
from
May 8, 2024 22:13
6cdedc3
to
9f156d7
Compare
Followup PR #1430 testing user switching is also testing these changes. Note CodeQL is broken after push to start live activities merged to main, its autobuild action no longer works. |
emawby
approved these changes
May 10, 2024
This was referenced May 10, 2024
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Fix processing of Identify User response when the user has changed since, so that pending updates will still be sent and transfer subscription happens only in correct situations.
Details
Note that this bug only manifests if multiple logins to different users are called one after another, or the requests are not able to succeed (server is down, or there is no internet connection during which time multiple logins are called). This PR tests and addresses those scenarios.
Motivation
Consider the scenario Anon -> Login User A (Identify User) -> Login User B (Create User)
Anon -> Login User A (Identify User) -> Login User B (Create User) -> Transfer Subscription to User A
This PR also fixes the bugs mentioned under Manual Testing section for #1418
User State Change Observer
onesignal_id
.Scope
Testing
Unit testing
Manual testing
Tested on iPhone 13 with iOS 17.4
✅ Scenario 1:
<some_existing_euid>
by way of external_id✅ Scenario 2:
✅ Scenario 3:
✅ Scenario 4:
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is