feat: Expose Integration Name to Kit Object#58
feat: Expose Integration Name to Kit Object#58alexs-mparticle wants to merge 2 commits intodevelopmentfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR exposes a computed integrationName directly on the kit instance so it’s available when the kit attaches to the Rokt Manager (and can be forwarded into Core SDK logging).
Changes:
- Add
integrationNameproperty to the kit instance and set it during initialization. - Continue passing the computed
integrationNameinto the launcher options. - Add tests intended to validate
integrationNameis present on the attached kit instance (plus custom-name behavior).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/Rokt-Kit.js |
Stores the generated integration name on the kit instance (self.integrationName) and uses it for launcher options. |
test/src/tests.js |
Adds new init-time tests asserting integrationName is available on the kit after attach, including custom integration name suffixing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Wait for initialization to complete | ||
| await waitForCondition(() => window.mParticle.Rokt.isInitialized); | ||
|
|
||
| window.mParticle.Rokt.kit.integrationName.should.equal( | ||
| `${sdkVersion}_${kitVersion}_${customName}` | ||
| ); |
There was a problem hiding this comment.
This test also waits on window.mParticle.Rokt.isInitialized, which is toggled inside the mock before attachKit necessarily completes. To avoid intermittent failures (e.g., window.mParticle.Rokt.kit still undefined), wait on attachKitCalled / forwarder.isInitialized / kit being assigned before asserting kit.integrationName.
| // Wait for initialization to complete | ||
| await waitForCondition(() => window.mParticle.Rokt.isInitialized); | ||
|
|
||
| window.mParticle.Rokt.attachKitCalled.should.equal(true); | ||
| window.mParticle.Rokt.kit.integrationName.should.be.a.String(); | ||
| window.mParticle.Rokt.kit.integrationName.should.not.be.empty(); | ||
| }); |
There was a problem hiding this comment.
Even though the test later asserts attachKitCalled, the wait condition is still window.mParticle.Rokt.isInitialized (set early by the mock). Waiting directly for attachKitCalled (or kit assignment) would better guarantee the kit has been attached before reading kit.integrationName.
| // Wait for initialization to complete | ||
| await waitForCondition(() => window.mParticle.Rokt.isInitialized); | ||
|
|
||
| window.mParticle.Rokt.kit.integrationName.should.equal( | ||
| `${sdkVersion}_${kitVersion}` | ||
| ); |
There was a problem hiding this comment.
These assertions rely on waitForCondition(() => window.mParticle.Rokt.isInitialized), but MockRoktForwarder.createLauncher sets isInitialized = true before the kit is actually attached. This can make the test race/flaky if attachKit runs later. Consider waiting on window.mParticle.Rokt.attachKitCalled (or window.mParticle.forwarder.isInitialized, or window.mParticle.Rokt.kit being set) instead so the kit is guaranteed available before asserting kit.integrationName.
Summary
Exposes the
integrationNameto the kit object, which will be passed into the Core SDK. This allows us to pick up the integration name for logging.Related to mParticle/mparticle-web-sdk#1137
Testing Plan
Using a sample app, observe that the kit now contains an
integrationNamewhen it attaches to the RoktManager.