@mparticle/web-rokt-kit 1.7.2 → 1.8.1

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.
@@ -34,6 +34,7 @@ var constructor = function () {
34
34
  self.userAttributes = {};
35
35
  self.testHelpers = null;
36
36
  self.placementEventMappingLookup = {};
37
+ self.eventQueue = [];
37
38
 
38
39
  /**
39
40
  * Generates the Rokt launcher script URL with optional domain override and extensions
@@ -246,6 +247,24 @@ var constructor = function () {
246
247
  return self.launcher.selectPlacements(selectPlacementsOptions);
247
248
  }
248
249
 
250
+ /**
251
+ * Enables optional Integration Launcher extensions before selecting placements
252
+ * @param {string} extensionName - Name of the extension to enable
253
+ * @returns {Promise<*>} A Promise resolving to the extension API if available
254
+ */
255
+ function use(extensionName) {
256
+ if (!isKitReady()) {
257
+ console.error('Rokt Kit: Not initialized');
258
+ return Promise.reject(new Error('Rokt Kit: Not initialized'));
259
+ }
260
+ if (!extensionName || typeof extensionName !== 'string') {
261
+ return Promise.reject(
262
+ new Error('Rokt Kit: Invalid extension name')
263
+ );
264
+ }
265
+ return self.launcher.use(extensionName);
266
+ }
267
+
249
268
  /**
250
269
  * Sets extension data for Rokt Web SDK
251
270
  * @param {Object} partnerExtensionData - The extension data object containing:
@@ -262,9 +281,20 @@ var constructor = function () {
262
281
  window.Rokt.setExtensionData(partnerExtensionData);
263
282
  }
264
283
 
284
+ function processEventQueue() {
285
+ self.eventQueue.forEach(function (event) {
286
+ processEvent(event);
287
+ });
288
+ self.eventQueue = [];
289
+ }
290
+
265
291
  function processEvent(event) {
292
+ if (!isKitReady()) {
293
+ self.eventQueue.push(event);
294
+ return;
295
+ }
296
+
266
297
  if (
267
- !isKitReady() ||
268
298
  isEmpty(self.placementEventMappingLookup) ||
269
299
  typeof window.mParticle.Rokt.setLocalSessionAttribute !== 'function'
270
300
  ) {
@@ -328,6 +358,7 @@ var constructor = function () {
328
358
  self.isInitialized = true;
329
359
  // Attaches the kit to the Rokt manager
330
360
  window.mParticle.Rokt.attachKit(self);
361
+ processEventQueue();
331
362
  })
332
363
  .catch(function (err) {
333
364
  console.error('Error creating Rokt launcher:', err);
@@ -379,6 +410,7 @@ var constructor = function () {
379
410
  // Called by the mParticle Rokt Manager
380
411
  this.selectPlacements = selectPlacements;
381
412
  this.hashAttributes = hashAttributes;
413
+ this.use = use;
382
414
 
383
415
  // Kit Callback Methods
384
416
  this.init = initForwarder;
@@ -402,7 +434,7 @@ var constructor = function () {
402
434
 
403
435
  function generateIntegrationName(customIntegrationName) {
404
436
  var coreSdkVersion = window.mParticle.getVersion();
405
- var kitVersion = "1.7.2";
437
+ var kitVersion = "1.8.1";
406
438
  var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
407
439
 
408
440
  if (customIntegrationName) {
@@ -33,6 +33,7 @@ var RoktKit = (function (exports) {
33
33
  self.userAttributes = {};
34
34
  self.testHelpers = null;
35
35
  self.placementEventMappingLookup = {};
36
+ self.eventQueue = [];
36
37
 
37
38
  /**
38
39
  * Generates the Rokt launcher script URL with optional domain override and extensions
@@ -245,6 +246,24 @@ var RoktKit = (function (exports) {
245
246
  return self.launcher.selectPlacements(selectPlacementsOptions);
246
247
  }
247
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
+
248
267
  /**
249
268
  * Sets extension data for Rokt Web SDK
250
269
  * @param {Object} partnerExtensionData - The extension data object containing:
@@ -261,9 +280,20 @@ var RoktKit = (function (exports) {
261
280
  window.Rokt.setExtensionData(partnerExtensionData);
262
281
  }
263
282
 
283
+ function processEventQueue() {
284
+ self.eventQueue.forEach(function (event) {
285
+ processEvent(event);
286
+ });
287
+ self.eventQueue = [];
288
+ }
289
+
264
290
  function processEvent(event) {
291
+ if (!isKitReady()) {
292
+ self.eventQueue.push(event);
293
+ return;
294
+ }
295
+
265
296
  if (
266
- !isKitReady() ||
267
297
  isEmpty(self.placementEventMappingLookup) ||
268
298
  typeof window.mParticle.Rokt.setLocalSessionAttribute !== 'function'
269
299
  ) {
@@ -327,6 +357,7 @@ var RoktKit = (function (exports) {
327
357
  self.isInitialized = true;
328
358
  // Attaches the kit to the Rokt manager
329
359
  window.mParticle.Rokt.attachKit(self);
360
+ processEventQueue();
330
361
  })
331
362
  .catch(function (err) {
332
363
  console.error('Error creating Rokt launcher:', err);
@@ -378,6 +409,7 @@ var RoktKit = (function (exports) {
378
409
  // Called by the mParticle Rokt Manager
379
410
  this.selectPlacements = selectPlacements;
380
411
  this.hashAttributes = hashAttributes;
412
+ this.use = use;
381
413
 
382
414
  // Kit Callback Methods
383
415
  this.init = initForwarder;
@@ -401,7 +433,7 @@ var RoktKit = (function (exports) {
401
433
 
402
434
  function generateIntegrationName(customIntegrationName) {
403
435
  var coreSdkVersion = window.mParticle.getVersion();
404
- var kitVersion = "1.7.2";
436
+ var kitVersion = "1.8.1";
405
437
  var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
406
438
 
407
439
  if (customIntegrationName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-rokt-kit",
3
- "version": "1.7.2",
3
+ "version": "1.8.1",
4
4
  "description": "mParticle integration kit for Rokt",
5
5
  "main": "dist/Rokt-Kit.common.js",
6
6
  "files": [