Repository navigation
fix: [SDK-5606] send full email and SMS fields on composite login - #2815
abdulraqeeb33 wants to merge 2 commits into
Conversation
Profile subscriptions were only type and token, so the backend stored notification_types -99. Match CreateSubscriptionOperation and drop the identity-verification warning. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Fix CI. |
| subscriptions = LoginProfileApplier.addSubscriptions(createUserOperation, subscriptions) | ||
| subscriptions = | ||
| LoginProfileApplier.addSubscriptions(createUserOperation, subscriptions) { type, token -> | ||
| subscriptionWithDevice(type, token, enabled = true, notificationTypes = SubscriptionStatus.SUBSCRIBED.value) |
There was a problem hiding this comment.
Blocking: for an email/SMS that already exists, Create User applies these fields as updates (turbine users/create/create.go calls UpdateAsync, and event_capnp.go sets notification_types whenever it's present). So someone who unsubscribed via the email link (-2) gets flipped back to 1 on the next composite login, and again on every login after.
addEmail doesn't hit this because create-subscription returns 200/202 for an existing sub without updating it.
Could we leave enabled/notification_types unset here and only send the device fields? New addresses would still land at -99 though, so fully fixing that probably needs Create User to only apply status on create.
There was a problem hiding this comment.
Both fixed in e5ba296.
- Dropped
enabled/notification_typesfor profile email/SMS. Device fields still sent. Backend ticket for status-on-create-only is next. - Added non-null checks (except carrier, which is null under Robolectric) and moved assertions out of
withArg.
| sub.netType shouldBe DeviceUtils.getNetType(context) | ||
| sub.carrier shouldBe DeviceUtils.getCarrierName(context) | ||
| sub.appVersion shouldBe AndroidUtils.getAppVersion(context) |
There was a problem hiding this comment.
Nit: these compare against the same helpers the code calls, so if they return null under Robolectric, a field that's never set still passes. Maybe add a non-null check where there's a real value.
fadi-george
left a comment
There was a problem hiding this comment.
Requesting changes for the resubscribe issue on LoginUserOperationExecutor.kt:214 (see inline comment).
… SMS Create User applies enabled/notification_types to an existing address, which would re-subscribe a user who unsubscribed. Device fields are still sent. Also moves the test assertions out of withArg so they don't call a mocked AndroidUtils during verification, and suppresses TooManyFunctions. Co-authored-by: Cursor <cursoragent@cursor.com>
📊 Diff Coverage ReportDiff Coverage Report (Changed Lines Only)Gate: aggregate coverage on changed executable lines must be ≥ 80% (JaCoCo line data for lines touched in the diff). Changed Files Coverage
Overall (aggregate gate)26/26 touched executable lines covered (100.0% — requires ≥ 80%) |
|
@fadi-george addressed in e5ba296, CI is green. Could you take another look?
|
Description
One Line Summary
Composite login email and SMS subscriptions now include the same device fields as
addEmailandaddSms, without a subscription status, and the identity-verification warning is gone.Details
Motivation
Fixes SDK-5606. Found in the 5.11.0 bug bash. Profile subscriptions were sent as type and token only, so the backend stored empty device fields. A successful composite login also logged a warning about identity verification that
addEmailnever logs.enabledandnotification_typesare deliberately not sent. Create User applies them to an email or SMS that already exists (on this user or moved from another), so sending "subscribed" would re-subscribe someone who unsubscribed, on every composite login. Add Subscription, whichaddEmailuses, ignores status for an existing address, so it never does this.The cost: a new address created through composite login is still stored as
notification_types: -99until the backend changes Create User to default a new email or SMS with no status to subscribed, and to apply status only on create. No SDK release is needed once that ships.Scope
Create User payloads for an email or SMS that comes from the login profile. A grouped subscription operation that already has that token is unchanged. Identity-only
login(externalId)is unchanged. Composite login still does not identify the anonymous user.Testing
Unit testing
LoginUserOperationExecutorTestsemail-only and SMS-only cases assert thatenabledandnotification_typesare absent and that the SDK version and device fields are present and non-null (exceptcarrier, which is null under Robolectric). Putting the status back makes both tests fail. Assertions run aftercoVerifyso they don't call a mockedAndroidUtilsduring verification.Manual testing
Replayed the Create User and Add Subscription requests against the demo app for email and SMS. On an emulator, the previous commit's request matched the "status sent" replay; this PR's payload is the same minus the two status fields.
addEmail/addSms11-99(needs backend change)-2)-21-2-2-21-2Affected code checklist
Checklist
Overview
Testing
Final pass
Made with Cursor