@mparticle/web-rokt-kit 1.8.0 → 1.9.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.
@@ -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
@@ -280,9 +281,20 @@ var constructor = function () {
280
281
  window.Rokt.setExtensionData(partnerExtensionData);
281
282
  }
282
283
 
284
+ function processEventQueue() {
285
+ self.eventQueue.forEach(function (event) {
286
+ processEvent(event);
287
+ });
288
+ self.eventQueue = [];
289
+ }
290
+
283
291
  function processEvent(event) {
292
+ if (!isKitReady()) {
293
+ self.eventQueue.push(event);
294
+ return;
295
+ }
296
+
284
297
  if (
285
- !isKitReady() ||
286
298
  isEmpty(self.placementEventMappingLookup) ||
287
299
  typeof window.mParticle.Rokt.setLocalSessionAttribute !== 'function'
288
300
  ) {
@@ -322,34 +334,40 @@ var constructor = function () {
322
334
  launcherOptions || {}
323
335
  );
324
336
 
325
- window.Rokt.createLauncher(options)
326
- .then(function (launcher) {
327
- // Assign the launcher to a global variable for later access
328
- window.Rokt.currentLauncher = launcher;
329
- // Locally cache the launcher and filters
330
- self.launcher = launcher;
337
+ if (isPartnerInLocalLauncherTestGroup()) {
338
+ var localLauncher = window.Rokt.createLocalLauncher(options);
339
+ initRoktLauncher(localLauncher);
340
+ } else {
341
+ window.Rokt.createLauncher(options)
342
+ .then(initRoktLauncher)
343
+ .catch(function (err) {
344
+ console.error('Error creating Rokt launcher:', err);
345
+ });
346
+ }
347
+ }
348
+
349
+ function initRoktLauncher(launcher) {
350
+ // Assign the launcher to a global variable for later access
351
+ window.Rokt.currentLauncher = launcher;
352
+ // Locally cache the launcher and filters
353
+ self.launcher = launcher;
331
354
 
332
- var roktFilters = window.mParticle.Rokt.filters;
355
+ var roktFilters = window.mParticle.Rokt.filters;
333
356
 
334
- if (!roktFilters) {
335
- console.warn('Rokt Kit: No filters have been set.');
336
- } else {
337
- self.filters = roktFilters;
338
- if (!roktFilters.filteredUser) {
339
- console.warn(
340
- 'Rokt Kit: No filtered user has been set.'
341
- );
342
- }
343
- }
357
+ if (!roktFilters) {
358
+ console.warn('Rokt Kit: No filters have been set.');
359
+ } else {
360
+ self.filters = roktFilters;
361
+ if (!roktFilters.filteredUser) {
362
+ console.warn('Rokt Kit: No filtered user has been set.');
363
+ }
364
+ }
344
365
 
345
- // Kit must be initialized before attaching to the Rokt manager
346
- self.isInitialized = true;
347
- // Attaches the kit to the Rokt manager
348
- window.mParticle.Rokt.attachKit(self);
349
- })
350
- .catch(function (err) {
351
- console.error('Error creating Rokt launcher:', err);
352
- });
366
+ // Kit must be initialized before attaching to the Rokt manager
367
+ self.isInitialized = true;
368
+ // Attaches the kit to the Rokt manager
369
+ window.mParticle.Rokt.attachKit(self);
370
+ processEventQueue();
353
371
  }
354
372
 
355
373
  // mParticle Kit Callback Methods
@@ -417,11 +435,18 @@ var constructor = function () {
417
435
  function isKitReady() {
418
436
  return !!(self.isInitialized && self.launcher);
419
437
  }
438
+
439
+ function isPartnerInLocalLauncherTestGroup() {
440
+ return (
441
+ window.mParticle.config &&
442
+ window.mParticle.config.isLocalLauncherEnabled
443
+ );
444
+ }
420
445
  };
421
446
 
422
447
  function generateIntegrationName(customIntegrationName) {
423
448
  var coreSdkVersion = window.mParticle.getVersion();
424
- var kitVersion = "1.8.0";
449
+ var kitVersion = "1.9.0";
425
450
  var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
426
451
 
427
452
  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
@@ -279,9 +280,20 @@ var RoktKit = (function (exports) {
279
280
  window.Rokt.setExtensionData(partnerExtensionData);
280
281
  }
281
282
 
283
+ function processEventQueue() {
284
+ self.eventQueue.forEach(function (event) {
285
+ processEvent(event);
286
+ });
287
+ self.eventQueue = [];
288
+ }
289
+
282
290
  function processEvent(event) {
291
+ if (!isKitReady()) {
292
+ self.eventQueue.push(event);
293
+ return;
294
+ }
295
+
283
296
  if (
284
- !isKitReady() ||
285
297
  isEmpty(self.placementEventMappingLookup) ||
286
298
  typeof window.mParticle.Rokt.setLocalSessionAttribute !== 'function'
287
299
  ) {
@@ -321,34 +333,40 @@ var RoktKit = (function (exports) {
321
333
  launcherOptions || {}
322
334
  );
323
335
 
324
- window.Rokt.createLauncher(options)
325
- .then(function (launcher) {
326
- // Assign the launcher to a global variable for later access
327
- window.Rokt.currentLauncher = launcher;
328
- // Locally cache the launcher and filters
329
- self.launcher = launcher;
336
+ if (isPartnerInLocalLauncherTestGroup()) {
337
+ var localLauncher = window.Rokt.createLocalLauncher(options);
338
+ initRoktLauncher(localLauncher);
339
+ } else {
340
+ window.Rokt.createLauncher(options)
341
+ .then(initRoktLauncher)
342
+ .catch(function (err) {
343
+ console.error('Error creating Rokt launcher:', err);
344
+ });
345
+ }
346
+ }
347
+
348
+ function initRoktLauncher(launcher) {
349
+ // Assign the launcher to a global variable for later access
350
+ window.Rokt.currentLauncher = launcher;
351
+ // Locally cache the launcher and filters
352
+ self.launcher = launcher;
330
353
 
331
- var roktFilters = window.mParticle.Rokt.filters;
354
+ var roktFilters = window.mParticle.Rokt.filters;
332
355
 
333
- if (!roktFilters) {
334
- console.warn('Rokt Kit: No filters have been set.');
335
- } else {
336
- self.filters = roktFilters;
337
- if (!roktFilters.filteredUser) {
338
- console.warn(
339
- 'Rokt Kit: No filtered user has been set.'
340
- );
341
- }
342
- }
356
+ if (!roktFilters) {
357
+ console.warn('Rokt Kit: No filters have been set.');
358
+ } else {
359
+ self.filters = roktFilters;
360
+ if (!roktFilters.filteredUser) {
361
+ console.warn('Rokt Kit: No filtered user has been set.');
362
+ }
363
+ }
343
364
 
344
- // Kit must be initialized before attaching to the Rokt manager
345
- self.isInitialized = true;
346
- // Attaches the kit to the Rokt manager
347
- window.mParticle.Rokt.attachKit(self);
348
- })
349
- .catch(function (err) {
350
- console.error('Error creating Rokt launcher:', err);
351
- });
365
+ // Kit must be initialized before attaching to the Rokt manager
366
+ self.isInitialized = true;
367
+ // Attaches the kit to the Rokt manager
368
+ window.mParticle.Rokt.attachKit(self);
369
+ processEventQueue();
352
370
  }
353
371
 
354
372
  // mParticle Kit Callback Methods
@@ -416,11 +434,18 @@ var RoktKit = (function (exports) {
416
434
  function isKitReady() {
417
435
  return !!(self.isInitialized && self.launcher);
418
436
  }
437
+
438
+ function isPartnerInLocalLauncherTestGroup() {
439
+ return (
440
+ window.mParticle.config &&
441
+ window.mParticle.config.isLocalLauncherEnabled
442
+ );
443
+ }
419
444
  };
420
445
 
421
446
  function generateIntegrationName(customIntegrationName) {
422
447
  var coreSdkVersion = window.mParticle.getVersion();
423
- var kitVersion = "1.8.0";
448
+ var kitVersion = "1.9.0";
424
449
  var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
425
450
 
426
451
  if (customIntegrationName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-rokt-kit",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "mParticle integration kit for Rokt",
5
5
  "main": "dist/Rokt-Kit.common.js",
6
6
  "files": [