@mparticle/web-rokt-kit 1.6.2 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Rokt-Kit.common.js +72 -9
- package/dist/Rokt-Kit.iife.js +72 -9
- package/package.json +1 -1
package/dist/Rokt-Kit.common.js
CHANGED
|
@@ -33,6 +33,7 @@ var constructor = function () {
|
|
|
33
33
|
self.filters = {};
|
|
34
34
|
self.userAttributes = {};
|
|
35
35
|
self.testHelpers = null;
|
|
36
|
+
self.placementEventMappingLookup = {};
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* Generates the Rokt launcher script URL with optional domain override and extensions
|
|
@@ -62,7 +63,7 @@ var constructor = function () {
|
|
|
62
63
|
* hashed attributes from the launcher, or `null` if the kit is not initialized
|
|
63
64
|
*/
|
|
64
65
|
function hashAttributes(attributes) {
|
|
65
|
-
if (!
|
|
66
|
+
if (!isKitReady()) {
|
|
66
67
|
console.error('Rokt Kit: Not initialized');
|
|
67
68
|
return null;
|
|
68
69
|
}
|
|
@@ -78,8 +79,16 @@ var constructor = function () {
|
|
|
78
79
|
) {
|
|
79
80
|
var accountId = settings.accountId;
|
|
80
81
|
var roktExtensions = extractRoktExtensions(settings.roktExtensions);
|
|
81
|
-
self.userAttributes = filteredUserAttributes;
|
|
82
|
+
self.userAttributes = filteredUserAttributes || {};
|
|
82
83
|
self.onboardingExpProvider = settings.onboardingExpProvider;
|
|
84
|
+
|
|
85
|
+
var placementEventMapping = parseSettingsString(
|
|
86
|
+
settings.placementEventMapping
|
|
87
|
+
);
|
|
88
|
+
self.placementEventMappingLookup = generateMappedEventLookup(
|
|
89
|
+
placementEventMapping
|
|
90
|
+
);
|
|
91
|
+
|
|
83
92
|
var domain = window.mParticle.Rokt.domain;
|
|
84
93
|
var launcherOptions = mergeObjects(
|
|
85
94
|
{},
|
|
@@ -93,6 +102,9 @@ var constructor = function () {
|
|
|
93
102
|
self.testHelpers = {
|
|
94
103
|
generateLauncherScript: generateLauncherScript,
|
|
95
104
|
extractRoktExtensions: extractRoktExtensions,
|
|
105
|
+
hashEventMessage: hashEventMessage,
|
|
106
|
+
parseSettingsString: parseSettingsString,
|
|
107
|
+
generateMappedEventLookup: generateMappedEventLookup,
|
|
96
108
|
};
|
|
97
109
|
attachLauncher(accountId, launcherOptions);
|
|
98
110
|
return;
|
|
@@ -203,10 +215,20 @@ var constructor = function () {
|
|
|
203
215
|
|
|
204
216
|
var filteredUserIdentities = returnUserIdentities(filteredUser);
|
|
205
217
|
|
|
218
|
+
var localSessionAttributes = {};
|
|
219
|
+
|
|
220
|
+
try {
|
|
221
|
+
localSessionAttributes =
|
|
222
|
+
window.mParticle.Rokt.getLocalSessionAttributes();
|
|
223
|
+
} catch (error) {
|
|
224
|
+
console.error('Error getting local session attributes:', error);
|
|
225
|
+
}
|
|
226
|
+
|
|
206
227
|
var selectPlacementsAttributes = mergeObjects(
|
|
207
228
|
filteredUserIdentities,
|
|
208
229
|
replaceOtherWithEmailsha256(filteredAttributes),
|
|
209
230
|
optimizelyAttributes,
|
|
231
|
+
localSessionAttributes,
|
|
210
232
|
{
|
|
211
233
|
mpid: mpid,
|
|
212
234
|
}
|
|
@@ -227,7 +249,7 @@ var constructor = function () {
|
|
|
227
249
|
* @returns {void} Nothing is returned
|
|
228
250
|
*/
|
|
229
251
|
function setExtensionData(partnerExtensionData) {
|
|
230
|
-
if (!
|
|
252
|
+
if (!isKitReady()) {
|
|
231
253
|
console.error('Rokt Kit: Not initialized');
|
|
232
254
|
return;
|
|
233
255
|
}
|
|
@@ -235,6 +257,26 @@ var constructor = function () {
|
|
|
235
257
|
window.Rokt.setExtensionData(partnerExtensionData);
|
|
236
258
|
}
|
|
237
259
|
|
|
260
|
+
function processEvent(event) {
|
|
261
|
+
if (
|
|
262
|
+
!isKitReady() ||
|
|
263
|
+
typeof window.mParticle.Rokt.setLocalSessionAttribute !== 'function'
|
|
264
|
+
) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
var hashedEvent = hashEventMessage(
|
|
269
|
+
event.EventDataType,
|
|
270
|
+
event.EventCategory,
|
|
271
|
+
event.EventName
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
if (self.placementEventMappingLookup[hashedEvent]) {
|
|
275
|
+
var mappedValue = self.placementEventMappingLookup[hashedEvent];
|
|
276
|
+
window.mParticle.Rokt.setLocalSessionAttribute(mappedValue, true);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
238
280
|
function onUserIdentified(filteredUser) {
|
|
239
281
|
self.filters.filteredUser = filteredUser;
|
|
240
282
|
self.userAttributes = filteredUser.getAllUserAttributes();
|
|
@@ -275,10 +317,11 @@ var constructor = function () {
|
|
|
275
317
|
);
|
|
276
318
|
}
|
|
277
319
|
}
|
|
278
|
-
// Attaches the kit to the Rokt manager
|
|
279
|
-
window.mParticle.Rokt.attachKit(self);
|
|
280
320
|
|
|
321
|
+
// Kit must be initialized before attaching to the Rokt manager
|
|
281
322
|
self.isInitialized = true;
|
|
323
|
+
// Attaches the kit to the Rokt manager
|
|
324
|
+
window.mParticle.Rokt.attachKit(self);
|
|
282
325
|
})
|
|
283
326
|
.catch(function (err) {
|
|
284
327
|
console.error('Error creating Rokt launcher:', err);
|
|
@@ -333,26 +376,27 @@ var constructor = function () {
|
|
|
333
376
|
|
|
334
377
|
// Kit Callback Methods
|
|
335
378
|
this.init = initForwarder;
|
|
379
|
+
this.process = processEvent;
|
|
336
380
|
this.setExtensionData = setExtensionData;
|
|
337
381
|
this.setUserAttribute = setUserAttribute;
|
|
338
382
|
this.onUserIdentified = onUserIdentified;
|
|
339
383
|
this.removeUserAttribute = removeUserAttribute;
|
|
340
384
|
|
|
341
385
|
/**
|
|
342
|
-
* Checks if the kit is
|
|
386
|
+
* Checks if the Rokt kit is ready to use.
|
|
343
387
|
* Both conditions must be true:
|
|
344
388
|
* 1. self.isInitialized - Set after successful initialization of the kit
|
|
345
389
|
* 2. self.launcher - The Rokt launcher instance must be available
|
|
346
|
-
* @returns {boolean} Whether the kit is
|
|
390
|
+
* @returns {boolean} Whether the kit is ready for use
|
|
347
391
|
*/
|
|
348
|
-
function
|
|
392
|
+
function isKitReady() {
|
|
349
393
|
return !!(self.isInitialized && self.launcher);
|
|
350
394
|
}
|
|
351
395
|
};
|
|
352
396
|
|
|
353
397
|
function generateIntegrationName(customIntegrationName) {
|
|
354
398
|
var coreSdkVersion = window.mParticle.getVersion();
|
|
355
|
-
var kitVersion = "1.6.
|
|
399
|
+
var kitVersion = "1.6.3";
|
|
356
400
|
var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
|
|
357
401
|
|
|
358
402
|
if (customIntegrationName) {
|
|
@@ -432,6 +476,25 @@ function extractRoktExtensions(settingsString) {
|
|
|
432
476
|
return roktExtensions;
|
|
433
477
|
}
|
|
434
478
|
|
|
479
|
+
function generateMappedEventLookup(placementEventMapping) {
|
|
480
|
+
if (!placementEventMapping) {
|
|
481
|
+
return {};
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
var mappedEvents = {};
|
|
485
|
+
for (var i = 0; i < placementEventMapping.length; i++) {
|
|
486
|
+
var mapping = placementEventMapping[i];
|
|
487
|
+
mappedEvents[mapping.jsmap] = mapping.value;
|
|
488
|
+
}
|
|
489
|
+
return mappedEvents;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
function hashEventMessage(messageType, eventType, eventName) {
|
|
493
|
+
return window.mParticle.generateHash(
|
|
494
|
+
[messageType, eventType, eventName].join('')
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
|
|
435
498
|
if (window && window.mParticle && window.mParticle.addForwarder) {
|
|
436
499
|
window.mParticle.addForwarder({
|
|
437
500
|
name: name,
|
package/dist/Rokt-Kit.iife.js
CHANGED
|
@@ -32,6 +32,7 @@ var RoktKit = (function (exports) {
|
|
|
32
32
|
self.filters = {};
|
|
33
33
|
self.userAttributes = {};
|
|
34
34
|
self.testHelpers = null;
|
|
35
|
+
self.placementEventMappingLookup = {};
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
38
|
* Generates the Rokt launcher script URL with optional domain override and extensions
|
|
@@ -61,7 +62,7 @@ var RoktKit = (function (exports) {
|
|
|
61
62
|
* hashed attributes from the launcher, or `null` if the kit is not initialized
|
|
62
63
|
*/
|
|
63
64
|
function hashAttributes(attributes) {
|
|
64
|
-
if (!
|
|
65
|
+
if (!isKitReady()) {
|
|
65
66
|
console.error('Rokt Kit: Not initialized');
|
|
66
67
|
return null;
|
|
67
68
|
}
|
|
@@ -77,8 +78,16 @@ var RoktKit = (function (exports) {
|
|
|
77
78
|
) {
|
|
78
79
|
var accountId = settings.accountId;
|
|
79
80
|
var roktExtensions = extractRoktExtensions(settings.roktExtensions);
|
|
80
|
-
self.userAttributes = filteredUserAttributes;
|
|
81
|
+
self.userAttributes = filteredUserAttributes || {};
|
|
81
82
|
self.onboardingExpProvider = settings.onboardingExpProvider;
|
|
83
|
+
|
|
84
|
+
var placementEventMapping = parseSettingsString(
|
|
85
|
+
settings.placementEventMapping
|
|
86
|
+
);
|
|
87
|
+
self.placementEventMappingLookup = generateMappedEventLookup(
|
|
88
|
+
placementEventMapping
|
|
89
|
+
);
|
|
90
|
+
|
|
82
91
|
var domain = window.mParticle.Rokt.domain;
|
|
83
92
|
var launcherOptions = mergeObjects(
|
|
84
93
|
{},
|
|
@@ -92,6 +101,9 @@ var RoktKit = (function (exports) {
|
|
|
92
101
|
self.testHelpers = {
|
|
93
102
|
generateLauncherScript: generateLauncherScript,
|
|
94
103
|
extractRoktExtensions: extractRoktExtensions,
|
|
104
|
+
hashEventMessage: hashEventMessage,
|
|
105
|
+
parseSettingsString: parseSettingsString,
|
|
106
|
+
generateMappedEventLookup: generateMappedEventLookup,
|
|
95
107
|
};
|
|
96
108
|
attachLauncher(accountId, launcherOptions);
|
|
97
109
|
return;
|
|
@@ -202,10 +214,20 @@ var RoktKit = (function (exports) {
|
|
|
202
214
|
|
|
203
215
|
var filteredUserIdentities = returnUserIdentities(filteredUser);
|
|
204
216
|
|
|
217
|
+
var localSessionAttributes = {};
|
|
218
|
+
|
|
219
|
+
try {
|
|
220
|
+
localSessionAttributes =
|
|
221
|
+
window.mParticle.Rokt.getLocalSessionAttributes();
|
|
222
|
+
} catch (error) {
|
|
223
|
+
console.error('Error getting local session attributes:', error);
|
|
224
|
+
}
|
|
225
|
+
|
|
205
226
|
var selectPlacementsAttributes = mergeObjects(
|
|
206
227
|
filteredUserIdentities,
|
|
207
228
|
replaceOtherWithEmailsha256(filteredAttributes),
|
|
208
229
|
optimizelyAttributes,
|
|
230
|
+
localSessionAttributes,
|
|
209
231
|
{
|
|
210
232
|
mpid: mpid,
|
|
211
233
|
}
|
|
@@ -226,7 +248,7 @@ var RoktKit = (function (exports) {
|
|
|
226
248
|
* @returns {void} Nothing is returned
|
|
227
249
|
*/
|
|
228
250
|
function setExtensionData(partnerExtensionData) {
|
|
229
|
-
if (!
|
|
251
|
+
if (!isKitReady()) {
|
|
230
252
|
console.error('Rokt Kit: Not initialized');
|
|
231
253
|
return;
|
|
232
254
|
}
|
|
@@ -234,6 +256,26 @@ var RoktKit = (function (exports) {
|
|
|
234
256
|
window.Rokt.setExtensionData(partnerExtensionData);
|
|
235
257
|
}
|
|
236
258
|
|
|
259
|
+
function processEvent(event) {
|
|
260
|
+
if (
|
|
261
|
+
!isKitReady() ||
|
|
262
|
+
typeof window.mParticle.Rokt.setLocalSessionAttribute !== 'function'
|
|
263
|
+
) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
var hashedEvent = hashEventMessage(
|
|
268
|
+
event.EventDataType,
|
|
269
|
+
event.EventCategory,
|
|
270
|
+
event.EventName
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
if (self.placementEventMappingLookup[hashedEvent]) {
|
|
274
|
+
var mappedValue = self.placementEventMappingLookup[hashedEvent];
|
|
275
|
+
window.mParticle.Rokt.setLocalSessionAttribute(mappedValue, true);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
237
279
|
function onUserIdentified(filteredUser) {
|
|
238
280
|
self.filters.filteredUser = filteredUser;
|
|
239
281
|
self.userAttributes = filteredUser.getAllUserAttributes();
|
|
@@ -274,10 +316,11 @@ var RoktKit = (function (exports) {
|
|
|
274
316
|
);
|
|
275
317
|
}
|
|
276
318
|
}
|
|
277
|
-
// Attaches the kit to the Rokt manager
|
|
278
|
-
window.mParticle.Rokt.attachKit(self);
|
|
279
319
|
|
|
320
|
+
// Kit must be initialized before attaching to the Rokt manager
|
|
280
321
|
self.isInitialized = true;
|
|
322
|
+
// Attaches the kit to the Rokt manager
|
|
323
|
+
window.mParticle.Rokt.attachKit(self);
|
|
281
324
|
})
|
|
282
325
|
.catch(function (err) {
|
|
283
326
|
console.error('Error creating Rokt launcher:', err);
|
|
@@ -332,26 +375,27 @@ var RoktKit = (function (exports) {
|
|
|
332
375
|
|
|
333
376
|
// Kit Callback Methods
|
|
334
377
|
this.init = initForwarder;
|
|
378
|
+
this.process = processEvent;
|
|
335
379
|
this.setExtensionData = setExtensionData;
|
|
336
380
|
this.setUserAttribute = setUserAttribute;
|
|
337
381
|
this.onUserIdentified = onUserIdentified;
|
|
338
382
|
this.removeUserAttribute = removeUserAttribute;
|
|
339
383
|
|
|
340
384
|
/**
|
|
341
|
-
* Checks if the kit is
|
|
385
|
+
* Checks if the Rokt kit is ready to use.
|
|
342
386
|
* Both conditions must be true:
|
|
343
387
|
* 1. self.isInitialized - Set after successful initialization of the kit
|
|
344
388
|
* 2. self.launcher - The Rokt launcher instance must be available
|
|
345
|
-
* @returns {boolean} Whether the kit is
|
|
389
|
+
* @returns {boolean} Whether the kit is ready for use
|
|
346
390
|
*/
|
|
347
|
-
function
|
|
391
|
+
function isKitReady() {
|
|
348
392
|
return !!(self.isInitialized && self.launcher);
|
|
349
393
|
}
|
|
350
394
|
};
|
|
351
395
|
|
|
352
396
|
function generateIntegrationName(customIntegrationName) {
|
|
353
397
|
var coreSdkVersion = window.mParticle.getVersion();
|
|
354
|
-
var kitVersion = "1.6.
|
|
398
|
+
var kitVersion = "1.6.3";
|
|
355
399
|
var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
|
|
356
400
|
|
|
357
401
|
if (customIntegrationName) {
|
|
@@ -431,6 +475,25 @@ var RoktKit = (function (exports) {
|
|
|
431
475
|
return roktExtensions;
|
|
432
476
|
}
|
|
433
477
|
|
|
478
|
+
function generateMappedEventLookup(placementEventMapping) {
|
|
479
|
+
if (!placementEventMapping) {
|
|
480
|
+
return {};
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
var mappedEvents = {};
|
|
484
|
+
for (var i = 0; i < placementEventMapping.length; i++) {
|
|
485
|
+
var mapping = placementEventMapping[i];
|
|
486
|
+
mappedEvents[mapping.jsmap] = mapping.value;
|
|
487
|
+
}
|
|
488
|
+
return mappedEvents;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
function hashEventMessage(messageType, eventType, eventName) {
|
|
492
|
+
return window.mParticle.generateHash(
|
|
493
|
+
[messageType, eventType, eventName].join('')
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
|
|
434
497
|
if (window && window.mParticle && window.mParticle.addForwarder) {
|
|
435
498
|
window.mParticle.addForwarder({
|
|
436
499
|
name: name,
|