Skip to content

fix: Prevent mutation of global launcherOptions during initialization#36

Merged
alexs-mparticle merged 2 commits into
developmentfrom
fix/SQDSDKS-7475-fix-integration-name
Jul 9, 2025
Merged

fix: Prevent mutation of global launcherOptions during initialization#36
alexs-mparticle merged 2 commits into
developmentfrom
fix/SQDSDKS-7475-fix-integration-name

Conversation

@alexs-mparticle

Copy link
Copy Markdown
Collaborator

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 matches mParticle_wsdkv_2.43.0_kitv_1.5.0_customName when the launcher is created.

This comment was marked as outdated.

@alexs-mparticle alexs-mparticle requested a review from Copilot July 9, 2025 16:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 launcherOptions before assigning integrationName
  • 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 }) or Object.assign for cloning to simplify the code and potentially replace the custom mergeObjects utility. Also verify if a deep clone is needed when launcherOptions may contain nested objects to avoid unintended shared references.
        var launcherOptions = mergeObjects(

@alexs-mparticle alexs-mparticle merged commit 0f36fac into development Jul 9, 2025
4 checks passed
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))
@alexs-mparticle alexs-mparticle deleted the fix/SQDSDKS-7475-fix-integration-name branch March 25, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants