fix: Prevent mutation of global launcherOptions during initialization#36
Merged
alexs-mparticle merged 2 commits intoJul 9, 2025
Merged
Conversation
… and improve readability
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR ensures the global window.mParticle.Rokt.launcherOptions object isn’t mutated when initializing the launcher by cloning it before modification, and updates tests to verify immutability.
- Clone
launcherOptionsbefore assigningintegrationName - Update test suite to use constants and assert original options remain unchanged
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Rokt-Kit.js | Wraps launcherOptions in a shallow clone via mergeObjects |
| test/src/tests.js | Introduces sdkVersion/kitVersion constants and tests immutability |
Comments suppressed due to low confidence (1)
src/Rokt-Kit.js:70
- [nitpick] Consider using ES6 object spread (
{ ...window.mParticle.Rokt.launcherOptions }) orObject.assignfor cloning to simplify the code and potentially replace the custommergeObjectsutility. Also verify if a deep clone is needed whenlauncherOptionsmay contain nested objects to avoid unintended shared references.
var launcherOptions = mergeObjects(
rmi22186
approved these changes
Jul 9, 2025
github-actions Bot
pushed a commit
that referenced
this pull request
Jul 14, 2025
# [1.6.0](v1.5.0...v1.6.0) (2025-07-14) ### Bug Fixes * Prevent mutation of global launcherOptions during initialization ([#36](#36)) ([0f36fac](0f36fac)) ### Features * Add Extensions to Rokt Kit ([#26](#26)) ([73e9696](73e9696)) * Support adding identities to select placement attributes ([#35](#35)) ([f9595ea](f9595ea))
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
The Rokt Kit was mutating the global window.mParticle.Rokt.launcherOptions object during initialization, causing integration name corruption on subsequent initializations.
This code created a reference to the global object, not a copy. When integrationName was modified, it mutated the original global state.
First initialization: "customName" → "mParticle_wsdkv_2.43.0_kitv_1.5.0_customName"
Second initialization: "mParticle_wsdkv_2.43.0_kitv_1.5.0_customName" → "mParticle_wsdkv_2.43.0_kitv_1.5.0_mParticle_wsdkv_2.43.0_kitv_1.5.0_customName"
Testing Plan
Using a sample app, assign a value to
window.mParticle.Rokt.launcherOptions.integrationName. Confirm that the integration name matchesmParticle_wsdkv_2.43.0_kitv_1.5.0_customNamewhen the launcher is created.