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] External Id hydration #1189

Merged
merged 7 commits into from
Sep 30, 2024
Merged

[Fix] External Id hydration #1189

merged 7 commits into from
Sep 30, 2024

Conversation

shepherd-l
Copy link
Contributor

@shepherd-l shepherd-l commented Sep 3, 2024

Description

1 Line Summary

Fixes outdated external ids caused by OneSignal returning the user's previous external id in its response for user GET requests when called quickly after the user was created.

Details

The server may still be updating and can return an outdated external Id from the getUser request. Instead of waiting for the updated external Id, we can hydrate the user with the local external Id as getting a response from the server means that the login was successful.

This PR also includes:
Adding a delay after creating a new user or push subscription as the OneSignal's backend can return incorrect 404 responses.

Systems Affected

  • WebSDK
  • Backend
  • Dashboard

Validation

Tests

Info

Checklist

  • All the automated tests pass or I explained why that is not possible
  • I have personally tested this on my machine or explained why that is not possible
  • I have included test coverage for these changes or explained why they are not needed

Programming Checklist
Interfaces:

  • Don't use default export
  • New interfaces are in model files

Functions:

  • Don't use default export
  • All function signatures have return types
  • Helpers should not access any data but rather be given the data to operate on.

Typescript:

  • No Typescript warnings
  • Avoid silencing null/undefined warnings with the exclamation point

Other:

  • Iteration: refrain from using elem of array syntax. Prefer forEach or use map
  • Avoid using global OneSignal accessor for context if possible. Instead, we can pass it to function/constructor so that we don't call OneSignal.context

Screenshots

Info

Checklist

  • I have included screenshots/recordings of the intended results or explained why they are not needed

Related Tickets



This change is Reviewable

@shepherd-l shepherd-l force-pushed the fix/externalIdHydration branch 5 times, most recently from bc29f96 to 4812749 Compare September 9, 2024 17:14
@emawby emawby changed the title WIP Delay making requests to new IDs Delay making requests to new IDs Sep 10, 2024
@shepherd-l shepherd-l force-pushed the fix/operationRepoRefactor branch 2 times, most recently from 6e61697 to 7a2bcf7 Compare September 12, 2024 15:12
src/core/executors/ExecutorBase.ts Outdated Show resolved Hide resolved
src/shared/models/NewRecordsState.ts Show resolved Hide resolved
src/page/managers/LoginManager.ts Outdated Show resolved Hide resolved
@shepherd-l shepherd-l force-pushed the fix/operationRepoRefactor branch 4 times, most recently from 9992570 to 937d585 Compare September 20, 2024 18:46
@shepherd-l shepherd-l force-pushed the fix/externalIdHydration branch 2 times, most recently from 8bb8c13 to 6ec79b5 Compare September 23, 2024 16:59
@shepherd-l shepherd-l changed the title Delay making requests to new IDs [Fix] external Id hydration Sep 24, 2024
@shepherd-l shepherd-l changed the title [Fix] external Id hydration [Fix] External Id hydration Sep 24, 2024
Base automatically changed from fix/operationRepoRefactor to main September 30, 2024 18:00
Used to keep track of creation of users and subscriptions inorder to delay operations afterwards. The delay is needed because after the server creates the user/subscription, there is a small amount of time where the data is not up to date.
Used to delay operations if the user was just created. Applied to addTag(s), removeTag(s), addAlias(es), removeAlias(es)
The server may still be updating and can return an outdated external Id from the getUser request. Instead of waiting for the updated external Id, we can hydrate the user with the local external Id as getting a response from the server means that the login was successful.

The external Id param from login() is used as the local external Id instead of the Identity Model because the Identity Model gets reset from resetModelRepoAndCache() on L89 and returns undefined.
Change operationsFromCache stub to remove promise as it is not an async function and finish running timers after each test
@shepherd-l shepherd-l merged commit a49e8e7 into main Sep 30, 2024
4 checks passed
@shepherd-l shepherd-l deleted the fix/externalIdHydration branch September 30, 2024 19:13
@shepherd-l shepherd-l mentioned this pull request Sep 30, 2024
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