Skip to content

SDK-563 pass configurable preferUserId through tryUser to setUserID/setEmail - #582

Open
joaodordio wants to merge 2 commits into
mainfrom
SDK-563-pt2/pass-config-preferUserId-to-tryUser
Open

SDK-563 pass configurable preferUserId through tryUser to setUserID/setEmail#582
joaodordio wants to merge 2 commits into
mainfrom
SDK-563-pt2/pass-config-preferUserId-to-tryUser

Conversation

@joaodordio

@joaodordio joaodordio commented Jul 23, 2026

Copy link
Copy Markdown
Member

📝 Summary

Pass preferUserId through tryUser so setUserID / JWT setEmail can opt out of identify-time user creation (SDK-563 pt2).

🎟️ Jira Ticket: SDK-563

📖 Description

Follow-up to #578 / 2.3.0.

That release made preferUserId configurable on updateUser, updateCart, and trackPurchase, but setUserID / JWT setEmail still called tryUser()updateUser({}), which forced preferUserId: true. Care.com (email-based project) hit this on identify and got placeholder / duplicate profiles.

This PR:

  • Threads an optional preferUserId arg through setUserID and JWT setEmail into tryUserupdateUser({ preferUserId })
  • Keeps the existing default (undefinedtrue) so callers that omit it behave as before
  • Adds authorization tests for default true and explicit false on non-JWT setUserID, JWT setUserID, and JWT setEmail
  • Adds a CHANGELOG Unreleased entry

Usage Care validated:

setUserID('user-123', undefined, false)

🧪 How to test?

  1. yarn jest --config jest.config.js src/authorization/authorization.test.ts -t preferUserId
  2. In a sample app (JWT or non-JWT), call setUserID('test-id', undefined, false) and confirm /users/update body has preferUserId: false
  3. Call setUserID('test-id') with no third arg and confirm /users/update still sends preferUserId: true

🧾 Changelog

CHANGELOG Unreleased entry added for the tryUser handoff (SDK-563).

📹 Loom recording if applicable

N/A

🐞 Github Issues solved

N/A

📚 Docs PR if applicable

https://github.com/Iterable/iterable-docs/pull/1574 (docs/sdk/august-release)

@joaodordio
joaodordio requested a review from a team as a code owner July 23, 2026 15:59
@codecov-commenter

codecov-commenter commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.43%. Comparing base (669147f) to head (aaeb652).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #582   +/-   ##
=======================================
  Coverage   74.43%   74.43%           
=======================================
  Files          57       57           
  Lines        2742     2742           
  Branches      821      821           
=======================================
  Hits         2041     2041           
  Misses        700      700           
  Partials        1        1           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

jena-chakour and others added 2 commits August 7, 2026 13:35
Lock in the tryUser handoff so identify-time /users/update respects an
explicit preferUserId, matching the Care.com fix path.
@joaodordio
joaodordio force-pushed the SDK-563-pt2/pass-config-preferUserId-to-tryUser branch from 940a48f to aaeb652 Compare August 7, 2026 12:41
@joaodordio
joaodordio enabled auto-merge (squash) August 7, 2026 13:38
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.

3 participants