From 3272ea42d97ba556663187f79370882e5a5b447d Mon Sep 17 00:00:00 2001 From: Alexander Sapountzis Date: Tue, 20 May 2025 17:00:22 -0400 Subject: [PATCH 1/8] feat: Expose Rokt launcher config options --- src/Rokt-Kit.js | 23 +++++++++-------------- test/src/tests.js | 19 ++++++++++++------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Rokt-Kit.js b/src/Rokt-Kit.js index ed237c1..166ed8f 100644 --- a/src/Rokt-Kit.js +++ b/src/Rokt-Kit.js @@ -29,6 +29,7 @@ var constructor = function () { self.filters = {}; self.filteredUser = {}; self.userAttributes = {}; + self.launcherOptions = {}; /** * Passes attributes to the Rokt Web SDK for client-side hashing @@ -51,25 +52,19 @@ var constructor = function () { testMode, _trackerId, filteredUserAttributes, - filteredUserIdentities, - appVersion, - appName, - customFlags + _filteredUserIdentities, + _appVersion, + _appName, + _customFlags ) { var accountId = settings.accountId; self.userAttributes = filteredUserAttributes; self.onboardingExpProvider = settings.onboardingExpProvider; - var integrationName = - customFlags && customFlags['Rokt.integrationName']; - var noFunctional = customFlags && customFlags['Rokt.noFunctional']; - var noTargeting = customFlags && customFlags['Rokt.noTargeting']; - - var launcherOptions = { - integrationName: generateIntegrationName(integrationName), - noFunctional: noFunctional, - noTargeting: noTargeting, - }; + var launcherOptions = self.launcherOptions || {}; + launcherOptions.integrationName = generateIntegrationName( + launcherOptions.integrationName + ); if (testMode) { attachLauncher(accountId, launcherOptions); diff --git a/test/src/tests.js b/test/src/tests.js index c07b09a..5f3df4f 100644 --- a/test/src/tests.js +++ b/test/src/tests.js @@ -98,6 +98,7 @@ describe('Rokt Forwarder', () => { afterEach(() => { window.mParticle.forwarder.userAttributes = {}; + delete window.mParticle.forwarder.launcherOptions; }); describe('#initForwarder', () => { @@ -138,7 +139,13 @@ describe('Rokt Forwarder', () => { window.Rokt.createLauncherCalled.should.equal(true); }); - it('should set optional settings from customFlags', async () => { + it('should set optional settings from launcherOptions', async () => { + mParticle.forwarder.launcherOptions = { + integrationName: 'customName', + noFunctional: true, + noTargeting: true, + }; + await mParticle.forwarder.init( { accountId: '123456', @@ -149,12 +156,7 @@ describe('Rokt Forwarder', () => { {}, null, null, - null, - { - 'Rokt.integrationName': 'customName', - 'Rokt.noFunctional': true, - 'Rokt.noTargeting': true, - } + null ); var expectedIntegrationName = @@ -255,6 +257,9 @@ describe('Rokt Forwarder', () => { window.mParticle.Rokt.attachKitCalled = true; return Promise.resolve(); }; + mParticle.forwarder.launcherOptions = { + integrationName: customIntegrationName, + }; // Simulate the forwarder appending the custom integration name window.Rokt.integrationName = From 1d207db116bd569d4e4de32c05e5ce3955b6ebc7 Mon Sep 17 00:00:00 2001 From: Alexander Sapountzis Date: Wed, 21 May 2025 13:17:37 -0400 Subject: [PATCH 2/8] Revise launcher options passthrough --- src/Rokt-Kit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Rokt-Kit.js b/src/Rokt-Kit.js index 166ed8f..bcdcad8 100644 --- a/src/Rokt-Kit.js +++ b/src/Rokt-Kit.js @@ -61,7 +61,7 @@ var constructor = function () { self.userAttributes = filteredUserAttributes; self.onboardingExpProvider = settings.onboardingExpProvider; - var launcherOptions = self.launcherOptions || {}; + var launcherOptions = window.mParticle.Rokt.launcherOptions || {}; launcherOptions.integrationName = generateIntegrationName( launcherOptions.integrationName ); From 3958b1102301aaef945d92c44cce89494e77ef36 Mon Sep 17 00:00:00 2001 From: Alexander Sapountzis Date: Wed, 21 May 2025 13:22:27 -0400 Subject: [PATCH 3/8] Update tests --- test/src/tests.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/src/tests.js b/test/src/tests.js index 5f3df4f..0ea2e51 100644 --- a/test/src/tests.js +++ b/test/src/tests.js @@ -140,7 +140,7 @@ describe('Rokt Forwarder', () => { }); it('should set optional settings from launcherOptions', async () => { - mParticle.forwarder.launcherOptions = { + window.mParticle.Rokt.launcherOptions = { integrationName: 'customName', noFunctional: true, noTargeting: true, @@ -246,7 +246,7 @@ describe('Rokt Forwarder', () => { ); }); - it('should append custom integration name to integrationName if customFlags is passed', async () => { + it('should append custom integration name to integrationName if passed in launcherOptions', async () => { const packageVersion = require('../../package.json').version; const customIntegrationName = 'myCustomIntegration'; @@ -257,7 +257,7 @@ describe('Rokt Forwarder', () => { window.mParticle.Rokt.attachKitCalled = true; return Promise.resolve(); }; - mParticle.forwarder.launcherOptions = { + window.mParticle.Rokt.launcherOptions = { integrationName: customIntegrationName, }; @@ -279,7 +279,6 @@ describe('Rokt Forwarder', () => { null, null, null, - { 'Rokt.integrationName': customIntegrationName } ); window.Rokt.integrationName.should.equal( From 098a01c829c1f8afab88fdeaff89d2cb5209dbe3 Mon Sep 17 00:00:00 2001 From: Alexander Sapountzis Date: Wed, 21 May 2025 13:28:45 -0400 Subject: [PATCH 4/8] Address PR Comments --- test/src/tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/src/tests.js b/test/src/tests.js index 0ea2e51..8f0296f 100644 --- a/test/src/tests.js +++ b/test/src/tests.js @@ -278,7 +278,7 @@ describe('Rokt Forwarder', () => { {}, null, null, - null, + null ); window.Rokt.integrationName.should.equal( From a283b2e3bde91ad8941b03f6ab3762e660028cce Mon Sep 17 00:00:00 2001 From: Alex S <49695018+alexs-mparticle@users.noreply.github.com> Date: Wed, 21 May 2025 14:49:26 -0400 Subject: [PATCH 5/8] Update test/src/tests.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- test/src/tests.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/src/tests.js b/test/src/tests.js index 8f0296f..3eadfb1 100644 --- a/test/src/tests.js +++ b/test/src/tests.js @@ -99,6 +99,7 @@ describe('Rokt Forwarder', () => { afterEach(() => { window.mParticle.forwarder.userAttributes = {}; delete window.mParticle.forwarder.launcherOptions; + delete window.mParticle.Rokt.launcherOptions; }); describe('#initForwarder', () => { From 963f25596a5b4e0289cfb3b85cc68582f858f322 Mon Sep 17 00:00:00 2001 From: Alexander Sapountzis Date: Thu, 29 May 2025 17:44:58 -0400 Subject: [PATCH 6/8] Add manager options --- src/Rokt-Kit.js | 15 ++++++++----- test/src/tests.js | 57 +++++++++++++++++++++++++++++------------------ 2 files changed, 45 insertions(+), 27 deletions(-) diff --git a/src/Rokt-Kit.js b/src/Rokt-Kit.js index bcdcad8..d651d10 100644 --- a/src/Rokt-Kit.js +++ b/src/Rokt-Kit.js @@ -29,7 +29,6 @@ var constructor = function () { self.filters = {}; self.filteredUser = {}; self.userAttributes = {}; - self.launcherOptions = {}; /** * Passes attributes to the Rokt Web SDK for client-side hashing @@ -61,13 +60,16 @@ var constructor = function () { self.userAttributes = filteredUserAttributes; self.onboardingExpProvider = settings.onboardingExpProvider; + var managerOptions = window.mParticle.Rokt.managerOptions || {}; + var sandbox = managerOptions.sandbox || false; + var launcherOptions = window.mParticle.Rokt.launcherOptions || {}; launcherOptions.integrationName = generateIntegrationName( launcherOptions.integrationName ); if (testMode) { - attachLauncher(accountId, launcherOptions); + attachLauncher(accountId, sandbox, launcherOptions); return; } @@ -88,7 +90,7 @@ var constructor = function () { typeof window.Rokt.createLauncher === 'function' && window.Rokt.currentLauncher === undefined ) { - attachLauncher(accountId, launcherOptions); + attachLauncher(accountId, sandbox, launcherOptions); } else { console.error( 'Rokt object is not available after script load.' @@ -178,9 +180,12 @@ var constructor = function () { delete self.userAttributes[key]; } - function attachLauncher(accountId, launcherOptions) { + function attachLauncher(accountId, sandbox, launcherOptions) { var options = mergeObjects( - { accountId: accountId }, + { + accountId: accountId, + sandbox: sandbox, + }, launcherOptions || {} ); diff --git a/test/src/tests.js b/test/src/tests.js index 3eadfb1..4514030 100644 --- a/test/src/tests.js +++ b/test/src/tests.js @@ -78,6 +78,7 @@ describe('Rokt Forwarder', () => { self.noTargeting = options.noTargeting; self.createLauncherCalled = true; self.isInitialized = true; + self.sandbox = options.sandbox; return Promise.resolve({ then: function (callback) { @@ -140,6 +141,40 @@ describe('Rokt Forwarder', () => { window.Rokt.createLauncherCalled.should.equal(true); }); + it('should set sandbox to true if sandbox is true in managerOptions', async () => { + window.mParticle.Rokt.managerOptions = { + sandbox: true, + }; + + await mParticle.forwarder.init( + { + accountId: '123456', + }, + reportService.cb, + true, + ); + + window.Rokt.createLauncherCalled.should.equal(true); + window.Rokt.sandbox.should.equal(true); + }); + + it('should set sandbox to false if sandbox is false in managerOptions', async () => { + window.mParticle.Rokt.managerOptions = { + sandbox: false, + }; + + await mParticle.forwarder.init( + { + accountId: '123456', + }, + reportService.cb, + true, + ); + + window.Rokt.createLauncherCalled.should.equal(true); + window.Rokt.sandbox.should.equal(false); + }); + it('should set optional settings from launcherOptions', async () => { window.mParticle.Rokt.launcherOptions = { integrationName: 'customName', @@ -172,28 +207,6 @@ describe('Rokt Forwarder', () => { window.Rokt.noTargeting.should.equal(true); }); - it('should not set optional settings when not in customFlags', async () => { - await mParticle.forwarder.init( - { - accountId: '123456', - }, - reportService.cb, - true, - null, - {} - ); - - var expectedIntegrationName = - 'mParticle_wsdkv_1.2.3_kitv_' + - require('../../package.json').version; - - window.Rokt.createLauncherCalled.should.equal(true); - window.Rokt.accountId.should.equal('123456'); - window.Rokt.integrationName.should.equal(expectedIntegrationName); - (window.Rokt.noFunctional === undefined).should.equal(true); - (window.Rokt.noTargeting === undefined).should.equal(true); - }); - it('should set the filters on the forwarder', async () => { await mParticle.forwarder.init( { From 62de5fd5aabe38a854b9603f98a0ba8c7646044b Mon Sep 17 00:00:00 2001 From: Alexander Sapountzis Date: Thu, 29 May 2025 17:46:41 -0400 Subject: [PATCH 7/8] Update tests --- test/src/tests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/src/tests.js b/test/src/tests.js index 4514030..733b240 100644 --- a/test/src/tests.js +++ b/test/src/tests.js @@ -151,7 +151,7 @@ describe('Rokt Forwarder', () => { accountId: '123456', }, reportService.cb, - true, + true ); window.Rokt.createLauncherCalled.should.equal(true); @@ -168,7 +168,7 @@ describe('Rokt Forwarder', () => { accountId: '123456', }, reportService.cb, - true, + true ); window.Rokt.createLauncherCalled.should.equal(true); From 96763079924260a9d0d2e73e737682357782b631 Mon Sep 17 00:00:00 2001 From: Alexander Sapountzis Date: Thu, 29 May 2025 17:49:02 -0400 Subject: [PATCH 8/8] Clean up code --- src/Rokt-Kit.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Rokt-Kit.js b/src/Rokt-Kit.js index d651d10..9eb7876 100644 --- a/src/Rokt-Kit.js +++ b/src/Rokt-Kit.js @@ -50,11 +50,7 @@ var constructor = function () { _service, testMode, _trackerId, - filteredUserAttributes, - _filteredUserIdentities, - _appVersion, - _appName, - _customFlags + filteredUserAttributes ) { var accountId = settings.accountId; self.userAttributes = filteredUserAttributes;