@mparticle/web-rokt-kit 1.16.0 → 1.17.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.
@@ -259,6 +259,8 @@ var constructor = function () {
259
259
  );
260
260
  launcherOptions.integrationName = self.integrationName;
261
261
 
262
+ self.domain = domain;
263
+
262
264
  if (testMode) {
263
265
  self.testHelpers = {
264
266
  generateLauncherScript: generateLauncherScript,
@@ -268,6 +270,12 @@ var constructor = function () {
268
270
  generateMappedEventLookup: generateMappedEventLookup,
269
271
  generateMappedEventAttributeLookup:
270
272
  generateMappedEventAttributeLookup,
273
+ sendAdBlockMeasurementSignals: sendAdBlockMeasurementSignals,
274
+ createAutoRemovedIframe: createAutoRemovedIframe,
275
+ djb2: djb2,
276
+ setAllowedOriginHash: function (hash) {
277
+ _allowedOriginHash = hash;
278
+ },
271
279
  };
272
280
  attachLauncher(accountId, launcherOptions);
273
281
  return;
@@ -487,6 +495,8 @@ var constructor = function () {
487
495
  return;
488
496
  }
489
497
 
498
+ _sendEventStream(event);
499
+
490
500
  if (
491
501
  typeof window.mParticle.Rokt.setLocalSessionAttribute !== 'function'
492
502
  ) {
@@ -513,6 +523,12 @@ var constructor = function () {
513
523
  }
514
524
  }
515
525
 
526
+ function _sendEventStream(event) {
527
+ if (window.Rokt && typeof window.Rokt.__event_stream__ === 'function') {
528
+ window.Rokt.__event_stream__(event);
529
+ }
530
+ }
531
+
516
532
  function onUserIdentified(filteredUser) {
517
533
  self.filters.filteredUser = filteredUser;
518
534
  self.userAttributes = filteredUser.getAllUserAttributes();
@@ -565,6 +581,9 @@ var constructor = function () {
565
581
 
566
582
  // Kit must be initialized before attaching to the Rokt manager
567
583
  self.isInitialized = true;
584
+
585
+ sendAdBlockMeasurementSignals(self.domain, self.integrationName);
586
+
568
587
  // Attaches the kit to the Rokt manager
569
588
  window.mParticle.Rokt.attachKit(self);
570
589
  processEventQueue();
@@ -659,11 +678,78 @@ var constructor = function () {
659
678
  window.mParticle.captureTiming(metricName);
660
679
  }
661
680
  }
681
+
682
+ function createAutoRemovedIframe(src) {
683
+ var iframe = document.createElement('iframe');
684
+ iframe.style.display = 'none';
685
+ iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
686
+ iframe.src = src;
687
+ iframe.onload = function () {
688
+ iframe.onload = null;
689
+ if (iframe.parentNode) {
690
+ iframe.parentNode.removeChild(iframe);
691
+ }
692
+ };
693
+ var target = document.body || document.head;
694
+ if (target) {
695
+ target.appendChild(iframe);
696
+ }
697
+ }
698
+
699
+ var ADBLOCK_CONTROL_DOMAIN = 'apps.roktecommerce.com';
700
+ var INIT_LOG_SAMPLING_RATE = 0.1;
701
+ var _allowedOriginHash = 1445747545;
702
+
703
+ function djb2(str) {
704
+ var hash = 5381;
705
+ for (var i = 0; i < str.length; i++) {
706
+ hash = (hash << 5) + hash + str.charCodeAt(i);
707
+ hash = hash & hash;
708
+ }
709
+ return hash;
710
+ }
711
+
712
+ function sendAdBlockMeasurementSignals(domain, version) {
713
+ if (djb2(window.location.origin) !== _allowedOriginHash) {
714
+ return;
715
+ }
716
+
717
+ if (Math.random() >= INIT_LOG_SAMPLING_RATE) {
718
+ return;
719
+ }
720
+
721
+ var guid = window.__rokt_li_guid__;
722
+ if (!guid) {
723
+ return;
724
+ }
725
+
726
+ var pageUrl = window.location.href.split('?')[0].split('#')[0];
727
+ var params =
728
+ 'version=' +
729
+ encodeURIComponent(version) +
730
+ '&launcherInstanceGuid=' +
731
+ encodeURIComponent(guid) +
732
+ '&pageUrl=' +
733
+ encodeURIComponent(pageUrl);
734
+
735
+ var existingDomain = domain || 'apps.rokt.com';
736
+ createAutoRemovedIframe(
737
+ 'https://' + existingDomain + '/v1/wsdk-init/index.html?' + params
738
+ );
739
+
740
+ createAutoRemovedIframe(
741
+ 'https://' +
742
+ ADBLOCK_CONTROL_DOMAIN +
743
+ '/v1/wsdk-init/index.html?' +
744
+ params +
745
+ '&isControl=true'
746
+ );
747
+ }
662
748
  };
663
749
 
664
750
  function generateIntegrationName(customIntegrationName) {
665
751
  var coreSdkVersion = window.mParticle.getVersion();
666
- var kitVersion = "1.16.0";
752
+ var kitVersion = "1.17.0";
667
753
  var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
668
754
 
669
755
  if (customIntegrationName) {
@@ -258,6 +258,8 @@ var RoktKit = (function (exports) {
258
258
  );
259
259
  launcherOptions.integrationName = self.integrationName;
260
260
 
261
+ self.domain = domain;
262
+
261
263
  if (testMode) {
262
264
  self.testHelpers = {
263
265
  generateLauncherScript: generateLauncherScript,
@@ -267,6 +269,12 @@ var RoktKit = (function (exports) {
267
269
  generateMappedEventLookup: generateMappedEventLookup,
268
270
  generateMappedEventAttributeLookup:
269
271
  generateMappedEventAttributeLookup,
272
+ sendAdBlockMeasurementSignals: sendAdBlockMeasurementSignals,
273
+ createAutoRemovedIframe: createAutoRemovedIframe,
274
+ djb2: djb2,
275
+ setAllowedOriginHash: function (hash) {
276
+ _allowedOriginHash = hash;
277
+ },
270
278
  };
271
279
  attachLauncher(accountId, launcherOptions);
272
280
  return;
@@ -486,6 +494,8 @@ var RoktKit = (function (exports) {
486
494
  return;
487
495
  }
488
496
 
497
+ _sendEventStream(event);
498
+
489
499
  if (
490
500
  typeof window.mParticle.Rokt.setLocalSessionAttribute !== 'function'
491
501
  ) {
@@ -512,6 +522,12 @@ var RoktKit = (function (exports) {
512
522
  }
513
523
  }
514
524
 
525
+ function _sendEventStream(event) {
526
+ if (window.Rokt && typeof window.Rokt.__event_stream__ === 'function') {
527
+ window.Rokt.__event_stream__(event);
528
+ }
529
+ }
530
+
515
531
  function onUserIdentified(filteredUser) {
516
532
  self.filters.filteredUser = filteredUser;
517
533
  self.userAttributes = filteredUser.getAllUserAttributes();
@@ -564,6 +580,9 @@ var RoktKit = (function (exports) {
564
580
 
565
581
  // Kit must be initialized before attaching to the Rokt manager
566
582
  self.isInitialized = true;
583
+
584
+ sendAdBlockMeasurementSignals(self.domain, self.integrationName);
585
+
567
586
  // Attaches the kit to the Rokt manager
568
587
  window.mParticle.Rokt.attachKit(self);
569
588
  processEventQueue();
@@ -658,11 +677,78 @@ var RoktKit = (function (exports) {
658
677
  window.mParticle.captureTiming(metricName);
659
678
  }
660
679
  }
680
+
681
+ function createAutoRemovedIframe(src) {
682
+ var iframe = document.createElement('iframe');
683
+ iframe.style.display = 'none';
684
+ iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
685
+ iframe.src = src;
686
+ iframe.onload = function () {
687
+ iframe.onload = null;
688
+ if (iframe.parentNode) {
689
+ iframe.parentNode.removeChild(iframe);
690
+ }
691
+ };
692
+ var target = document.body || document.head;
693
+ if (target) {
694
+ target.appendChild(iframe);
695
+ }
696
+ }
697
+
698
+ var ADBLOCK_CONTROL_DOMAIN = 'apps.roktecommerce.com';
699
+ var INIT_LOG_SAMPLING_RATE = 0.1;
700
+ var _allowedOriginHash = 1445747545;
701
+
702
+ function djb2(str) {
703
+ var hash = 5381;
704
+ for (var i = 0; i < str.length; i++) {
705
+ hash = (hash << 5) + hash + str.charCodeAt(i);
706
+ hash = hash & hash;
707
+ }
708
+ return hash;
709
+ }
710
+
711
+ function sendAdBlockMeasurementSignals(domain, version) {
712
+ if (djb2(window.location.origin) !== _allowedOriginHash) {
713
+ return;
714
+ }
715
+
716
+ if (Math.random() >= INIT_LOG_SAMPLING_RATE) {
717
+ return;
718
+ }
719
+
720
+ var guid = window.__rokt_li_guid__;
721
+ if (!guid) {
722
+ return;
723
+ }
724
+
725
+ var pageUrl = window.location.href.split('?')[0].split('#')[0];
726
+ var params =
727
+ 'version=' +
728
+ encodeURIComponent(version) +
729
+ '&launcherInstanceGuid=' +
730
+ encodeURIComponent(guid) +
731
+ '&pageUrl=' +
732
+ encodeURIComponent(pageUrl);
733
+
734
+ var existingDomain = domain || 'apps.rokt.com';
735
+ createAutoRemovedIframe(
736
+ 'https://' + existingDomain + '/v1/wsdk-init/index.html?' + params
737
+ );
738
+
739
+ createAutoRemovedIframe(
740
+ 'https://' +
741
+ ADBLOCK_CONTROL_DOMAIN +
742
+ '/v1/wsdk-init/index.html?' +
743
+ params +
744
+ '&isControl=true'
745
+ );
746
+ }
661
747
  };
662
748
 
663
749
  function generateIntegrationName(customIntegrationName) {
664
750
  var coreSdkVersion = window.mParticle.getVersion();
665
- var kitVersion = "1.16.0";
751
+ var kitVersion = "1.17.0";
666
752
  var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
667
753
 
668
754
  if (customIntegrationName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-rokt-kit",
3
- "version": "1.16.0",
3
+ "version": "1.17.0",
4
4
  "description": "mParticle integration kit for Rokt",
5
5
  "main": "dist/Rokt-Kit.common.js",
6
6
  "files": [