Repository navigation
SDK-128 add autoUserUpdate config to control identify-time users/update - #591
Draft
joaodordio wants to merge 1 commit into
Draft
joaodordio wants to merge 1 commit into
joaodordio wants to merge 1 commit into
Conversation
setUserID and JWT setEmail call users/update on every identify. Sites that reload on every navigation send one per page view. autoUserUpdate keeps that as the default (true), adds 'oncePerUser' to send it once per user per browser until logout, and false to skip it.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #591 +/- ##
==========================================
+ Coverage 75.32% 75.57% +0.24%
==========================================
Files 57 58 +1
Lines 2752 2776 +24
Branches 806 810 +4
==========================================
+ Hits 2073 2098 +25
+ Misses 678 677 -1
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or 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
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.
📝 Summary
Adds
autoUserUpdate(true|'oncePerUser'|false, defaulttrue) to control theusers/updatecall made bysetUserIDand JWTsetEmail.🎟️ Jira Ticket: SDK-128
📖 Description
setUserID(both modes) and JWTsetEmailcalltryUser, which sendsPOST /api/users/updatewith up to 3 retries. A customer whose site does a full reload on every navigation identifies the user on every page load, so they send oneusers/updateper page view. That call also takes a token from the org's volume rate-limit bucket, which is shared withupdateSubscriptionsandlists/subscribe.This PR:
autoUserUpdatetoOptions, defaulting totrue. Anything other thanfalseor'oncePerUser'behaves liketrue, so nothing changes for customers who don't set it.'oncePerUser': after a successfulusers/update, storesemail:<email>oruserID:<id>in localStorage (itbl_user_updated), and skips the call while the same identity is identified again. A different identity sends it again.logoutclears the stored identity. A failed call stores nothing, so the next identify retries.false: never sends the call. The customer creates the profile with the already-publicupdateUser, or from their server.src/authorization/autoUserUpdate.ts;authorization.tsonly changes at the threetryUsercall sites and bothlogoutmethods.updateUserendpoint name and theWithJWTsetEmail/setUserIDsignatures.Backend context, checked on Iterable
origin/master:'oncePerUser'exists: plainfalsewould break those requests for first-time users unless the customer creates the profile.users/mergewith a missing destination renames the source profile instead of failing, so merging an unknown user still works when the call is skipped.Mobile parity: Android and iOS don't call
users/updateon login and skip a repeat login with the same identity.'oncePerUser'brings Web close to that, and the name followsautoPushRegistration.Known limitation: the stored identity isn't scoped by API key. A site that uses two Iterable projects on the same origin with
'oncePerUser'would skip profile creation in the second one.🧪 How to test?
yarn jest --config jest.config.js src/authorization/authorization.autoUserUpdate.test.ts. It coverstrue,false,'oncePerUser', unrecognized values, logout, failed calls, and email/userId collisions across non-JWTsetUserID, JWTsetUserIDand JWTsetEmail.yarn jest --config jest.config.js(27 suites, 419 tests passing) andyarn typecheck.initializeWithConfig({ configOptions: { autoUserUpdate: 'oncePerUser' }, ... }), callsetUserID('u1'), reload, and call it again. Only the first identify sends/users/update. Afterlogout(), the next identify sends it again.🧾 Changelog
CHANGELOG Unreleased entry added (SDK-128).
📹 Loom recording if applicable
N/A
🐞 Github Issues solved
N/A
📚 Docs PR if applicable
https://github.com/Iterable/iterable-docs/pull/1614