-
Notifications
You must be signed in to change notification settings - Fork 263
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] Some pending properties can be sent to new user incorrectly, when users change #1418
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 base branch from
main
to
fix/user_module_user_defaults_crashes
April 25, 2024 21:13
nan-li
force-pushed
the
use_central_identity_model_repo
branch
from
April 26, 2024 05:03
3e2359e
to
06b672e
Compare
nan-li
changed the title
WIP [Bug] Some pending properties can be sent to new user incorrectly, when users change
[Bug] Some pending properties can be sent to new user incorrectly, when users change
Apr 26, 2024
nan-li
force-pushed
the
use_central_identity_model_repo
branch
from
April 26, 2024 05:47
72f8c69
to
06b672e
Compare
nan-li
requested review from
jkasten2,
emawby,
jinliu9508,
shepherd-l and
jennantilla
April 26, 2024 05:47
nan-li
changed the base branch from
fix/user_module_user_defaults_crashes
to
main
April 26, 2024 17:01
nan-li
changed the base branch from
main
to
fix/user_module_user_defaults_crashes
April 26, 2024 17:01
nan-li
force-pushed
the
use_central_identity_model_repo
branch
4 times, most recently
from
April 29, 2024 07:14
a01efe3
to
382ada3
Compare
I pushed some changes for testing, reproducing the behavior in [tests] Add test for switching users with adding tags where the test fails before (both tags are sent to UserB), and passes after. |
nan-li
force-pushed
the
use_central_identity_model_repo
branch
from
April 29, 2024 07:24
382ada3
to
3f8c676
Compare
* We don't need the reference to the property model for an Update User request, and this reference has gone unused so far * We don't hydrate from the response as the response is not the full user, just the property that was updated. * The request still has a reference to the identity model it is operating on
* OneSignalCoreMocks now has XCTest dependency * It uses a waiter to allow the test to wait for any async calls to run, because we don't have control over all threads. For example, a test may need to wait for operation repo to run everything in the dispatch queue
* We will need to know if a particular payload exists in a dictionary to confirm what requests are sending
* Adds additional property to track if all requests have been handled by mock responses set * Adds method to use in asserts to confirm if there is only one executed request that contains the payload provided, and the url matches the path provided.f
* Change OneSignalUserTests build configs to "Test" * Add OS_TEST preprocessor macro (Test) to OneSignalOSCore which is needed for the reduced flush interval
* Starts with anon user, log into 2 users via Identify User and Create User * Add tags to each user
* The model on a Delta for property change is the properties model. However, the identity is needed to send the request. * We have been setting the identity model as the current user's when these Deltas become Requests. * However, the timing can be buggy when we flush Deltas when users change. The Operation Repo and Property Executor use a dispatch queue so by the time the request is made, the user may have changed.
* Introduce OSIdentityModelRepo managed by the User Manager where a dictionary of identity models live * This will hold identity models added when users change * When requests are uncached, their identity models will also be added as they are still being used. * This is a lightweight option over modifying the Identity Model Store (which is an option if we wish to use the model store to manage all identity models)
* When Requests are uncached in the executors, hook them up to the same identity model instance via the Identity Model Repo
nan-li
force-pushed
the
use_central_identity_model_repo
branch
from
April 29, 2024 18:18
3f8c676
to
c4d8f44
Compare
nan-li
force-pushed
the
use_central_identity_model_repo
branch
from
April 29, 2024 18:29
c4d8f44
to
581f159
Compare
* Also move its reset methods into an extension
nan-li
force-pushed
the
use_central_identity_model_repo
branch
from
April 29, 2024 20:29
6f0d5aa
to
ef9d2c6
Compare
Tests were failing because some state carried over, added more resets to the User Manager |
jkasten2
approved these changes
Apr 30, 2024
emawby
approved these changes
Apr 30, 2024
This was referenced Apr 30, 2024
Merged
This was referenced May 1, 2024
18 tasks
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
Fixes bug that when users change, user updates like tags for the previous user can be sent incorrectly to the new user.
Details
This PR has two main changes:
OSDelta will now have an ID of the Identity Model it is meant for. Previously, user updates such as add tags and adding email / sms subscriptions did not have any reference to the Identity Model. As a result, when the OSDelta is processed into Requests to send to the server, we attach them to the current user. However, since the Operation Repo and Property Executor use a dispatch queue, the user may have switched by then.
Use a central repo to hold Identity Model instances that are being used during an app session. On subsequent cold starts, when Deltas and Requests are uncached, they will go through the repo to hook up the identity model instances so they are all operating on, and updating, the same instance. If their identity model does not exist yet, it will be added to the repo.
Motivation
Bug fix
Scope
Testing
Unit testing
testSwitchUser_sendsCorrectTags
[tests] Add test for switching users with adding tagsManual testing
iPhone 13 on iOS 17.4
Scenario 1:
addTag()
and immediately logging into another user. The tag went to the new user.Scenario 2:
<user_a>
Scenario 3:
Scenario 4:
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is