Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 9 additions & 1 deletion src/Rokt-Kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,19 @@ var constructor = function () {
}

function attachLauncher(accountId, launcherOptions) {
var mpSessionId =
window.mParticle &&
window.mParticle.sessionManager &&
typeof window.mParticle.sessionManager.getSession === 'function'
? window.mParticle.sessionManager.getSession()
: undefined;

var options = mergeObjects(
{
accountId: accountId,
},
launcherOptions || {}
launcherOptions || {},
mpSessionId ? { mpSessionId: mpSessionId } : {}
);

if (isPartnerInLocalLauncherTestGroup()) {
Expand Down
41 changes: 41 additions & 0 deletions test/src/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ describe('Rokt Forwarder', () => {
mParticle._Store = {
localSessionAttributes: {},
};
mParticle.sessionManager = {
getSession: function () {
return 'test-mp-session-id';
},
};
mParticle._getActiveForwarders = function () {
return [];
};
Expand Down Expand Up @@ -114,6 +119,7 @@ describe('Rokt Forwarder', () => {
self.integrationName = options.integrationName;
self.noFunctional = options.noFunctional;
self.noTargeting = options.noTargeting;
self.mpSessionId = options.mpSessionId;
self.createLauncherCalled = true;
self.isInitialized = true;
self.sandbox = options.sandbox;
Expand All @@ -130,6 +136,7 @@ describe('Rokt Forwarder', () => {
self.integrationName = options.integrationName;
self.noFunctional = options.noFunctional;
self.noTargeting = options.noTargeting;
self.mpSessionId = options.mpSessionId;
self.createLocalLauncherCalled = true;
self.isInitialized = true;
self.sandbox = options.sandbox;
Expand Down Expand Up @@ -842,6 +849,40 @@ describe('Rokt Forwarder', () => {

window.mParticle.Rokt.createLauncherCalled.should.equal(true);
});

it('should pass mpSessionId from mParticle sessionManager to createLauncher', async () => {
window.mParticle.sessionManager = {
getSession: function () {
return 'my-mp-session-123';
},
};

await window.mParticle.forwarder.init(
{ accountId: '123456' },
reportService.cb,
true,
null,
{}
);

window.mParticle.Rokt.mpSessionId.should.equal('my-mp-session-123');
});

it('should not pass mpSessionId when sessionManager is unavailable', async () => {
delete window.mParticle.sessionManager;

await window.mParticle.forwarder.init(
{ accountId: '123456' },
reportService.cb,
true,
null,
{}
);

(window.mParticle.Rokt.mpSessionId === undefined).should.equal(
true
);
});
});

describe('#selectPlacements', () => {
Expand Down
Loading