@mparticle/web-rokt-kit 1.7.1 → 1.8.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.
@@ -159,6 +159,18 @@ var constructor = function () {
159
159
  return replaceOtherWithEmailsha256(userIdentities);
160
160
  }
161
161
 
162
+ function returnLocalSessionAttributes() {
163
+ if (
164
+ isEmpty(self.placementEventMappingLookup) ||
165
+ !window.mParticle.Rokt ||
166
+ typeof window.mParticle.Rokt.getLocalSessionAttributes !==
167
+ 'function'
168
+ ) {
169
+ return {};
170
+ }
171
+ return window.mParticle.Rokt.getLocalSessionAttributes();
172
+ }
173
+
162
174
  function replaceOtherWithEmailsha256(_data) {
163
175
  var data = mergeObjects({}, _data || {});
164
176
  if (_data.hasOwnProperty(OTHER_IDENTITY)) {
@@ -215,14 +227,7 @@ var constructor = function () {
215
227
 
216
228
  var filteredUserIdentities = returnUserIdentities(filteredUser);
217
229
 
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
- }
230
+ var localSessionAttributes = returnLocalSessionAttributes();
226
231
 
227
232
  var selectPlacementsAttributes = mergeObjects(
228
233
  filteredUserIdentities,
@@ -241,6 +246,24 @@ var constructor = function () {
241
246
  return self.launcher.selectPlacements(selectPlacementsOptions);
242
247
  }
243
248
 
249
+ /**
250
+ * Enables optional Integration Launcher extensions before selecting placements
251
+ * @param {string} extensionName - Name of the extension to enable
252
+ * @returns {Promise<*>} A Promise resolving to the extension API if available
253
+ */
254
+ function use(extensionName) {
255
+ if (!isKitReady()) {
256
+ console.error('Rokt Kit: Not initialized');
257
+ return Promise.reject(new Error('Rokt Kit: Not initialized'));
258
+ }
259
+ if (!extensionName || typeof extensionName !== 'string') {
260
+ return Promise.reject(
261
+ new Error('Rokt Kit: Invalid extension name')
262
+ );
263
+ }
264
+ return self.launcher.use(extensionName);
265
+ }
266
+
244
267
  /**
245
268
  * Sets extension data for Rokt Web SDK
246
269
  * @param {Object} partnerExtensionData - The extension data object containing:
@@ -260,6 +283,7 @@ var constructor = function () {
260
283
  function processEvent(event) {
261
284
  if (
262
285
  !isKitReady() ||
286
+ isEmpty(self.placementEventMappingLookup) ||
263
287
  typeof window.mParticle.Rokt.setLocalSessionAttribute !== 'function'
264
288
  ) {
265
289
  return;
@@ -373,6 +397,7 @@ var constructor = function () {
373
397
  // Called by the mParticle Rokt Manager
374
398
  this.selectPlacements = selectPlacements;
375
399
  this.hashAttributes = hashAttributes;
400
+ this.use = use;
376
401
 
377
402
  // Kit Callback Methods
378
403
  this.init = initForwarder;
@@ -396,7 +421,7 @@ var constructor = function () {
396
421
 
397
422
  function generateIntegrationName(customIntegrationName) {
398
423
  var coreSdkVersion = window.mParticle.getVersion();
399
- var kitVersion = "1.7.1";
424
+ var kitVersion = "1.8.0";
400
425
  var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
401
426
 
402
427
  if (customIntegrationName) {
@@ -498,6 +523,10 @@ function hashEventMessage(messageType, eventType, eventName) {
498
523
  );
499
524
  }
500
525
 
526
+ function isEmpty(value) {
527
+ return value == null || !(Object.keys(value) || value).length;
528
+ }
529
+
501
530
  if (window && window.mParticle && window.mParticle.addForwarder) {
502
531
  window.mParticle.addForwarder({
503
532
  name: name,
@@ -158,6 +158,18 @@ var RoktKit = (function (exports) {
158
158
  return replaceOtherWithEmailsha256(userIdentities);
159
159
  }
160
160
 
161
+ function returnLocalSessionAttributes() {
162
+ if (
163
+ isEmpty(self.placementEventMappingLookup) ||
164
+ !window.mParticle.Rokt ||
165
+ typeof window.mParticle.Rokt.getLocalSessionAttributes !==
166
+ 'function'
167
+ ) {
168
+ return {};
169
+ }
170
+ return window.mParticle.Rokt.getLocalSessionAttributes();
171
+ }
172
+
161
173
  function replaceOtherWithEmailsha256(_data) {
162
174
  var data = mergeObjects({}, _data || {});
163
175
  if (_data.hasOwnProperty(OTHER_IDENTITY)) {
@@ -214,14 +226,7 @@ var RoktKit = (function (exports) {
214
226
 
215
227
  var filteredUserIdentities = returnUserIdentities(filteredUser);
216
228
 
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
- }
229
+ var localSessionAttributes = returnLocalSessionAttributes();
225
230
 
226
231
  var selectPlacementsAttributes = mergeObjects(
227
232
  filteredUserIdentities,
@@ -240,6 +245,24 @@ var RoktKit = (function (exports) {
240
245
  return self.launcher.selectPlacements(selectPlacementsOptions);
241
246
  }
242
247
 
248
+ /**
249
+ * Enables optional Integration Launcher extensions before selecting placements
250
+ * @param {string} extensionName - Name of the extension to enable
251
+ * @returns {Promise<*>} A Promise resolving to the extension API if available
252
+ */
253
+ function use(extensionName) {
254
+ if (!isKitReady()) {
255
+ console.error('Rokt Kit: Not initialized');
256
+ return Promise.reject(new Error('Rokt Kit: Not initialized'));
257
+ }
258
+ if (!extensionName || typeof extensionName !== 'string') {
259
+ return Promise.reject(
260
+ new Error('Rokt Kit: Invalid extension name')
261
+ );
262
+ }
263
+ return self.launcher.use(extensionName);
264
+ }
265
+
243
266
  /**
244
267
  * Sets extension data for Rokt Web SDK
245
268
  * @param {Object} partnerExtensionData - The extension data object containing:
@@ -259,6 +282,7 @@ var RoktKit = (function (exports) {
259
282
  function processEvent(event) {
260
283
  if (
261
284
  !isKitReady() ||
285
+ isEmpty(self.placementEventMappingLookup) ||
262
286
  typeof window.mParticle.Rokt.setLocalSessionAttribute !== 'function'
263
287
  ) {
264
288
  return;
@@ -372,6 +396,7 @@ var RoktKit = (function (exports) {
372
396
  // Called by the mParticle Rokt Manager
373
397
  this.selectPlacements = selectPlacements;
374
398
  this.hashAttributes = hashAttributes;
399
+ this.use = use;
375
400
 
376
401
  // Kit Callback Methods
377
402
  this.init = initForwarder;
@@ -395,7 +420,7 @@ var RoktKit = (function (exports) {
395
420
 
396
421
  function generateIntegrationName(customIntegrationName) {
397
422
  var coreSdkVersion = window.mParticle.getVersion();
398
- var kitVersion = "1.7.1";
423
+ var kitVersion = "1.8.0";
399
424
  var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
400
425
 
401
426
  if (customIntegrationName) {
@@ -497,6 +522,10 @@ var RoktKit = (function (exports) {
497
522
  );
498
523
  }
499
524
 
525
+ function isEmpty(value) {
526
+ return value == null || !(Object.keys(value) || value).length;
527
+ }
528
+
500
529
  if (window && window.mParticle && window.mParticle.addForwarder) {
501
530
  window.mParticle.addForwarder({
502
531
  name: name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-rokt-kit",
3
- "version": "1.7.1",
3
+ "version": "1.8.0",
4
4
  "description": "mParticle integration kit for Rokt",
5
5
  "main": "dist/Rokt-Kit.common.js",
6
6
  "files": [