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
2 changes: 2 additions & 0 deletions src/Rokt-Kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,8 @@ var constructor = function () {
.catch(function () {
logSelectPlacementsEvent(selectPlacementsAttributes);
});
} else {
logSelectPlacementsEvent(selectPlacementsAttributes);
}

return selection;
Expand Down
41 changes: 41 additions & 0 deletions test/src/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2892,6 +2892,47 @@ describe('Rokt Forwarder', () => {
);
});

it('should log event when selectPlacements returns a non-thenable value', async () => {
window.Rokt.createLauncher = async function () {
return Promise.resolve({
selectPlacements: function () {
// Returns a non-thenable (no .then method)
return undefined;
},
});
};

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

await waitForCondition(
() => window.mParticle.forwarder.isInitialized
);

await window.mParticle.forwarder.selectPlacements({
identifier: 'test-placement',
attributes: {
'new-attr': 'new-value',
},
});

await waitForCondition(() => mParticle.loggedEvents.length > 0);

mParticle.loggedEvents.length.should.equal(1);
mParticle.loggedEvents[0].eventName.should.equal(
'selectPlacements'
);
});

it('should skip logging when mParticle.logEvent is not available', async () => {
var originalLogEvent = window.mParticle.logEvent;
window.mParticle.logEvent = undefined;
Expand Down
Loading