Uh oh!
There was an error while loading. Please reload this page.
feat: forward terminate from the kit to the Rokt launcher - #122
Open
jamesnrokt wants to merge 1 commit into
Open
feat: forward terminate from the kit to the Rokt launcher#122jamesnrokt wants to merge 1 commit into
jamesnrokt wants to merge 1 commit into
Conversation
Backs the new `window.mParticle.Rokt.terminate()` entry point in the core SDK (mParticle/mparticle-web-sdk). The manager delegates to the kit, which forwards to the launcher, giving partners a supported teardown path in place of the undocumented `window.Rokt.currentLauncher?.terminate()`. The launcher reference is deliberately left in place. The Rokt Web SDK memoizes a single launcher per page, so clearing it could not buy the caller a fresh one — it would only flip the kit to not-ready and leave later calls queued forever. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
| }); | ||
| // The Rokt Web SDK memoizes one launcher per page, so terminate must not | ||
| // clear the kit's launcher references — doing so would flip the kit to |
Collaborator
There was a problem hiding this comment.
Typically createLauncher can be called again after terminate, usually for SPAs.
Can this create another launcher instance in that flow and continue? (given the launcher reference is maintained)
Create a test to capture this scenario
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 freeto 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
RoktKit.terminate(), which forwards tolauncher.terminate()on the Rokt Web SDK.This is the kit half of a supported teardown path for
window.mParticle.Rokt.terminate(). The core SDK half is in mParticle/mparticle-web-sdk#1328; that PR'sRoktManager.terminate()delegates to this method. This PR should merge and release first — the manager guards the call withisFunction, so until a kit carrying this change is on the page,mParticle.Rokt.terminate()logs that the attached kit version does not support it.Partners currently tear down placements with the undocumented
window.Rokt.currentLauncher?.terminate(). This makes the same call reachable through the documented interface.Behaviour
launcher.terminate()directly, so callers canawaitthe teardown. The launcher's ownterminateraces an internal 500ms timeout and never rejects.Rokt Kit: Not initializedand resolves. Teardown is idempotent — with no launcher there is nothing to tear down.The launcher reference is deliberately left in place
terminate()does not null outthis.launcherorwindow.Rokt.currentLauncher. The Rokt Web SDK memoizes a single launcher per page (createLauncherreturns the cached promise once fulfilled), so clearing our references could not buy the caller a fresh launcher — it would only flipisKitReady()to false and leave every laterselectPlacementscall queued forever with no drain path.Leaving state untouched makes this exactly equivalent to the
window.Rokt.currentLauncher.terminate()call partners already make, just reachable through a supported API. There is a test pinning this.Testing Plan
npm run lint,npm run build,npm run testall pass — 313/313 Vitest tests, including 6 new#terminatecases covering:launcher.terminateis called when fully initializedinit()+attachKitin test modeAll 6 fail against
mainwithout the source change.Suggested manual check
On a page with a rendered placement,
await window.Rokt.currentLauncher.terminate()andawait window.mParticle.Rokt.terminate()(once mParticle/mparticle-web-sdk#1328 is also deployed) should be indistinguishable.🤖 Generated with Claude Code