Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions src/Rokt-Kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var constructor = function () {
self.filters = {};
self.filteredUser = {};
self.userAttributes = {};
self.launcherOptions = {};
Comment thread
alexs-mparticle marked this conversation as resolved.
Outdated

/**
* Passes attributes to the Rokt Web SDK for client-side hashing
Expand All @@ -51,25 +52,19 @@ var constructor = function () {
testMode,
_trackerId,
filteredUserAttributes,
filteredUserIdentities,
appVersion,
appName,
customFlags
_filteredUserIdentities,
_appVersion,
_appName,
_customFlags
Comment thread
alexs-mparticle marked this conversation as resolved.
Outdated
) {
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 = window.mParticle.Rokt.launcherOptions || {};
launcherOptions.integrationName = generateIntegrationName(
launcherOptions.integrationName
);

if (testMode) {
attachLauncher(accountId, launcherOptions);
Expand Down
25 changes: 15 additions & 10 deletions test/src/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ describe('Rokt Forwarder', () => {

afterEach(() => {
window.mParticle.forwarder.userAttributes = {};
delete window.mParticle.forwarder.launcherOptions;
Comment thread
alexs-mparticle marked this conversation as resolved.
delete window.mParticle.Rokt.launcherOptions;
});

describe('#initForwarder', () => {
Expand Down Expand Up @@ -138,7 +140,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 () => {
window.mParticle.Rokt.launcherOptions = {
integrationName: 'customName',
noFunctional: true,
noTargeting: true,
};

await mParticle.forwarder.init(
{
accountId: '123456',
Expand All @@ -149,12 +157,7 @@ describe('Rokt Forwarder', () => {
{},
null,
null,
null,
{
'Rokt.integrationName': 'customName',
'Rokt.noFunctional': true,
'Rokt.noTargeting': true,
}
null
);

var expectedIntegrationName =
Expand Down Expand Up @@ -244,7 +247,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';

Expand All @@ -255,6 +258,9 @@ describe('Rokt Forwarder', () => {
window.mParticle.Rokt.attachKitCalled = true;
return Promise.resolve();
};
window.mParticle.Rokt.launcherOptions = {
integrationName: customIntegrationName,
};

// Simulate the forwarder appending the custom integration name
window.Rokt.integrationName =
Expand All @@ -273,8 +279,7 @@ describe('Rokt Forwarder', () => {
{},
null,
null,
null,
{ 'Rokt.integrationName': customIntegrationName }
null
);

window.Rokt.integrationName.should.equal(
Expand Down