feat: forward terminate from the kit to the Rokt launcher - #122
Merged
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>
mattbodle
reviewed
Aug 18, 2026
The Web SDK drops its memoized launcher on terminate, so createLauncher can mint a new instance. The next selectPlacements now re-attaches that instance instead of calling into the terminated one.
crisryantan
reviewed
Aug 22, 2026
crisryantan
requested changes
Aug 22, 2026
crisryantan
left a comment
Collaborator
There was a problem hiding this comment.
Let's fix the types since we are already making changes
…eate Move the SPA recreate path onto a LauncherAttachContext / lifecycle state module so createLauncher options and Window.Rokt stay typed.
Type the #terminate window/kit/launcher surface so the new tests no longer cast through any.
crisryantan
approved these changes
Aug 22, 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.
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