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
22 changes: 16 additions & 6 deletions src/Rokt-Kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ var constructor = function () {

self.launcher = null;
self.filters = {};
self.filteredUser = {};
self.userAttributes = {};

/**
Expand Down Expand Up @@ -115,6 +114,18 @@ var constructor = function () {
console.warn('Unable to find Rokt on the page');
}
}
/**
* Returns the user identities from the filtered user, if any
* @param {Object} filteredUser - The filtered user object containing identities
* @returns {Object} The user identities from the filtered user
*/
function returnUserIdentities(filteredUser) {
if (!filteredUser || !filteredUser.getUserIdentities) {
return {};
}

return filteredUser.getUserIdentities().userIdentities;
}

/**
* Selects placements for Rokt Web SDK with merged attributes, filters, and experimentation options
Expand Down Expand Up @@ -160,8 +171,11 @@ var constructor = function () {
? fetchOptimizely()
: {};

var filteredUserIdentities = returnUserIdentities(filteredUser);

var selectPlacementsAttributes = mergeObjects(
filteredAttributes,
filteredUserIdentities,
optimizelyAttributes,
{
mpid: mpid,
Expand All @@ -176,7 +190,7 @@ var constructor = function () {
}

function onUserIdentified(filteredUser) {
self.filteredUser = filteredUser;
self.filters.filteredUser = filteredUser;
Comment thread
alexs-mparticle marked this conversation as resolved.
self.userAttributes = filteredUser.getAllUserAttributes();
}

Expand All @@ -200,7 +214,6 @@ var constructor = function () {
.then(function (launcher) {
// Assign the launcher to a global variable for later access
window.Rokt.currentLauncher = launcher;

// Locally cache the launcher and filters
self.launcher = launcher;

Expand All @@ -214,11 +227,8 @@ var constructor = function () {
console.warn(
'Rokt Kit: No filtered user has been set.'
);
} else {
self.filteredUser = roktFilters.filteredUser;
}
Comment thread
alexs-mparticle marked this conversation as resolved.
}

// Attaches the kit to the Rokt manager
window.mParticle.Rokt.attachKit(self);

Expand Down
Loading