feat: [SDK-5229] drop anonymous operations at enqueue when Identity Verification is active - #1497
Merged
Merged
Conversation
Merged
16 tasks
sherwinski
added this pull request to stack #1499
September 17, 2026 22:17
sherwinski
force-pushed
the
sherwin/sdk-5229
branch
2 times, most recently
from
September 21, 2026 19:55
f8ec1b3 to
a2ed037
Compare
sherwinski
force-pushed
the
sherwin/sdk-5229
branch
from
September 21, 2026 20:03
a2ed037 to
96adbe1
Compare
… is active When the app requires a JWT, an anonymous operation can never pass the dispatch gate because an anonymous user has no token. Drop it at enqueue time and warn the developer instead of holding it in the queue forever. - OperationRepo._shouldSuppressAnonymousOp runs in _enqueue and _enqueueAndWait, behind the isIvCodePathEnabled outer gate - LoginUserOperation is exempt so login and the push grant still queue it - _enqueueAndWait rejects with OperationFailedError(_Suppressed) - The push grant catches the _Suppressed rejection and keeps the model local, so an anonymous visitor under IV does not see an error - The warning uses console.warn so it shows in production builds
sherwinski
force-pushed
the
sherwin/sdk-5229
branch
from
September 21, 2026 23:12
96adbe1 to
106ccee
Compare
fadi-george
approved these changes
Sep 21, 2026
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.
Description
1 Line Summary
Drop an anonymous operation at enqueue when IV behavior is active, warn the developer, and keep the push grant lenient.
Details
Sixth of 7 M2 pull requests for Identity Verification for Web SDK. Stacked on #1496 (SDK-5231). Targets
sherwin/sdk-5231now; retarget tofeat/identity-verificationafter the earlier PRs merge.Follows decision D4 in the design doc, recorded on SDK-5215: with the requirement on, the server rejects an unsigned
POST apps/{appId}/users, so an anonymous backend user cannot exist. The SDK stays lenient. A prompt-first visitor sees no error; the SDK holds the subscription locally. Mirrors AndroidOperationRepo.kt:164-182.Scope: this PR alone does not complete the prompt-first flow in the same session. The exempt anonymous
LoginUserOperationstays in the queue, gated forever. A laterlogin(externalId, jwt)enqueues an identifiedLoginUserOperationwithexistingOnesignalIdset to the anonymous local id, and its_canStartExecutewaits for that id to resolve. The anonymous login never runs, so the identified login waits until the next page load, when the purge in SDK-5230 (#1498) removes the anonymous login and clearsexistingOnesignalId. SDK-5238 (M3, force the create-user path under IV and never carry the anonymous id) completes the in-session flow. Until SDK-5238 merges, do not read this PR as end-to-end prompt-first support.src/core/operationRepo/OperationRepo.ts_shouldSuppressAnonymousOp(op)runs at the top of_enqueueand_enqueueAndWait, behind theisIvCodePathEnabledouter gate. It returnstruewhen IV behavior is active and the operation has noexternalId.LoginUserOperationis exempt.loginand the push grant enqueue an anonymous one on purpose, and the purge in SDK-5230 removes a stale one at start._enqueuereturns._enqueueAndWaitrejects withOperationFailedErrorand_result: ExecutionResult._Suppressed.console.warn, notLog._warn, becauseLogis silent in production builds and the developer needs to see this. Same pattern as the feature flag override warning from M1.src/shared/managers/subscription/page.tscreateSubscribedUsercatches the_Suppressedrejection from_enqueueAndWaitand returns. The push model stays local in IndexedDB. Once the identified login can start (see the scope note above),LoginManager._switchUserenqueues aTransferSubscriptionOperationandLoginUserOperationExecutorreads the token from the local model, so the create-user request carries the push subscription. Any other rejection still propagates.Why the dispatch gate is not enough: an anonymous operation can never pass it, so without this PR the operation would sit in the queue forever and block later operations with the same comparison key.
Test changes. Two earlier gate tests and one 401 test enqueued anonymous operations under IV. They now place the operation in the queue directly through a
loadIntoQueuehelper, which models a row persisted before IV was on. One 401 test left an unconsumedmockResolvedValueOncethat leaked into 3 later tests; the rewrite removes the leak.Bundle size. Adds 130 B gzipped to
page.es6.js. The page limit moves to the measured 44.10 kB.Systems Affected
Validation
Tests
Info
src/core/operationRepo/OperationRepo.test.ts, newanonymous operation suppression at enqueueblock:_enqueuedrops an anonymous operation, the queue and store stay empty, andconsole.warnfires once with the operation name._enqueueAndWaitrejects an anonymous operation with_Suppressed.LoginUserOperationis queued and no warning fires.src/shared/managers/SubscriptionManager.test.ts:create-subscription, only the exemptlogin-useroperation is in the queue, and no create-user request is sent.Not covered:
autoResubscribeon a returning device under IV. The SDK-5215 comment lists it as untested. The first-grant path shares the samecreateSubscribedUserfunction, so the catch applies to both, but I did not add a test for the returning-device entry point.vp check,vp test, andvp run build:prodpass.Checklist
Programming Checklist
Interfaces:
Functions:
Typescript:
Other:
elem of arraysyntax. PreferforEachor usemapcontextif possible. Instead, we can pass it to function/constructor so that we don't callOneSignal.contextScreenshots
Info
Not needed. No UI change.
Checklist
Related Tickets