@mparticle/web-rokt-kit 1.15.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.
- package/dist/Rokt-Kit.common.js +90 -2
- package/dist/Rokt-Kit.iife.js +90 -2
- package/package.json +1 -1
package/dist/Rokt-Kit.common.js
CHANGED
|
@@ -43,6 +43,7 @@ var constructor = function () {
|
|
|
43
43
|
self.placementEventMappingLookup = {};
|
|
44
44
|
self.placementEventAttributeMappingLookup = {};
|
|
45
45
|
self.eventQueue = [];
|
|
46
|
+
self.integrationName = null;
|
|
46
47
|
|
|
47
48
|
function getEventAttributeValue(event, eventAttributeKey) {
|
|
48
49
|
var attributes = event && event.EventAttributes;
|
|
@@ -253,9 +254,12 @@ var constructor = function () {
|
|
|
253
254
|
{},
|
|
254
255
|
window.mParticle.Rokt.launcherOptions || {}
|
|
255
256
|
);
|
|
256
|
-
|
|
257
|
+
self.integrationName = generateIntegrationName(
|
|
257
258
|
launcherOptions.integrationName
|
|
258
259
|
);
|
|
260
|
+
launcherOptions.integrationName = self.integrationName;
|
|
261
|
+
|
|
262
|
+
self.domain = domain;
|
|
259
263
|
|
|
260
264
|
if (testMode) {
|
|
261
265
|
self.testHelpers = {
|
|
@@ -266,6 +270,12 @@ var constructor = function () {
|
|
|
266
270
|
generateMappedEventLookup: generateMappedEventLookup,
|
|
267
271
|
generateMappedEventAttributeLookup:
|
|
268
272
|
generateMappedEventAttributeLookup,
|
|
273
|
+
sendAdBlockMeasurementSignals: sendAdBlockMeasurementSignals,
|
|
274
|
+
createAutoRemovedIframe: createAutoRemovedIframe,
|
|
275
|
+
djb2: djb2,
|
|
276
|
+
setAllowedOriginHash: function (hash) {
|
|
277
|
+
_allowedOriginHash = hash;
|
|
278
|
+
},
|
|
269
279
|
};
|
|
270
280
|
attachLauncher(accountId, launcherOptions);
|
|
271
281
|
return;
|
|
@@ -485,6 +495,8 @@ var constructor = function () {
|
|
|
485
495
|
return;
|
|
486
496
|
}
|
|
487
497
|
|
|
498
|
+
_sendEventStream(event);
|
|
499
|
+
|
|
488
500
|
if (
|
|
489
501
|
typeof window.mParticle.Rokt.setLocalSessionAttribute !== 'function'
|
|
490
502
|
) {
|
|
@@ -511,6 +523,12 @@ var constructor = function () {
|
|
|
511
523
|
}
|
|
512
524
|
}
|
|
513
525
|
|
|
526
|
+
function _sendEventStream(event) {
|
|
527
|
+
if (window.Rokt && typeof window.Rokt.__event_stream__ === 'function') {
|
|
528
|
+
window.Rokt.__event_stream__(event);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
514
532
|
function onUserIdentified(filteredUser) {
|
|
515
533
|
self.filters.filteredUser = filteredUser;
|
|
516
534
|
self.userAttributes = filteredUser.getAllUserAttributes();
|
|
@@ -563,6 +581,9 @@ var constructor = function () {
|
|
|
563
581
|
|
|
564
582
|
// Kit must be initialized before attaching to the Rokt manager
|
|
565
583
|
self.isInitialized = true;
|
|
584
|
+
|
|
585
|
+
sendAdBlockMeasurementSignals(self.domain, self.integrationName);
|
|
586
|
+
|
|
566
587
|
// Attaches the kit to the Rokt manager
|
|
567
588
|
window.mParticle.Rokt.attachKit(self);
|
|
568
589
|
processEventQueue();
|
|
@@ -657,11 +678,78 @@ var constructor = function () {
|
|
|
657
678
|
window.mParticle.captureTiming(metricName);
|
|
658
679
|
}
|
|
659
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
|
+
}
|
|
660
748
|
};
|
|
661
749
|
|
|
662
750
|
function generateIntegrationName(customIntegrationName) {
|
|
663
751
|
var coreSdkVersion = window.mParticle.getVersion();
|
|
664
|
-
var kitVersion = "1.
|
|
752
|
+
var kitVersion = "1.17.0";
|
|
665
753
|
var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
|
|
666
754
|
|
|
667
755
|
if (customIntegrationName) {
|
package/dist/Rokt-Kit.iife.js
CHANGED
|
@@ -42,6 +42,7 @@ var RoktKit = (function (exports) {
|
|
|
42
42
|
self.placementEventMappingLookup = {};
|
|
43
43
|
self.placementEventAttributeMappingLookup = {};
|
|
44
44
|
self.eventQueue = [];
|
|
45
|
+
self.integrationName = null;
|
|
45
46
|
|
|
46
47
|
function getEventAttributeValue(event, eventAttributeKey) {
|
|
47
48
|
var attributes = event && event.EventAttributes;
|
|
@@ -252,9 +253,12 @@ var RoktKit = (function (exports) {
|
|
|
252
253
|
{},
|
|
253
254
|
window.mParticle.Rokt.launcherOptions || {}
|
|
254
255
|
);
|
|
255
|
-
|
|
256
|
+
self.integrationName = generateIntegrationName(
|
|
256
257
|
launcherOptions.integrationName
|
|
257
258
|
);
|
|
259
|
+
launcherOptions.integrationName = self.integrationName;
|
|
260
|
+
|
|
261
|
+
self.domain = domain;
|
|
258
262
|
|
|
259
263
|
if (testMode) {
|
|
260
264
|
self.testHelpers = {
|
|
@@ -265,6 +269,12 @@ var RoktKit = (function (exports) {
|
|
|
265
269
|
generateMappedEventLookup: generateMappedEventLookup,
|
|
266
270
|
generateMappedEventAttributeLookup:
|
|
267
271
|
generateMappedEventAttributeLookup,
|
|
272
|
+
sendAdBlockMeasurementSignals: sendAdBlockMeasurementSignals,
|
|
273
|
+
createAutoRemovedIframe: createAutoRemovedIframe,
|
|
274
|
+
djb2: djb2,
|
|
275
|
+
setAllowedOriginHash: function (hash) {
|
|
276
|
+
_allowedOriginHash = hash;
|
|
277
|
+
},
|
|
268
278
|
};
|
|
269
279
|
attachLauncher(accountId, launcherOptions);
|
|
270
280
|
return;
|
|
@@ -484,6 +494,8 @@ var RoktKit = (function (exports) {
|
|
|
484
494
|
return;
|
|
485
495
|
}
|
|
486
496
|
|
|
497
|
+
_sendEventStream(event);
|
|
498
|
+
|
|
487
499
|
if (
|
|
488
500
|
typeof window.mParticle.Rokt.setLocalSessionAttribute !== 'function'
|
|
489
501
|
) {
|
|
@@ -510,6 +522,12 @@ var RoktKit = (function (exports) {
|
|
|
510
522
|
}
|
|
511
523
|
}
|
|
512
524
|
|
|
525
|
+
function _sendEventStream(event) {
|
|
526
|
+
if (window.Rokt && typeof window.Rokt.__event_stream__ === 'function') {
|
|
527
|
+
window.Rokt.__event_stream__(event);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
513
531
|
function onUserIdentified(filteredUser) {
|
|
514
532
|
self.filters.filteredUser = filteredUser;
|
|
515
533
|
self.userAttributes = filteredUser.getAllUserAttributes();
|
|
@@ -562,6 +580,9 @@ var RoktKit = (function (exports) {
|
|
|
562
580
|
|
|
563
581
|
// Kit must be initialized before attaching to the Rokt manager
|
|
564
582
|
self.isInitialized = true;
|
|
583
|
+
|
|
584
|
+
sendAdBlockMeasurementSignals(self.domain, self.integrationName);
|
|
585
|
+
|
|
565
586
|
// Attaches the kit to the Rokt manager
|
|
566
587
|
window.mParticle.Rokt.attachKit(self);
|
|
567
588
|
processEventQueue();
|
|
@@ -656,11 +677,78 @@ var RoktKit = (function (exports) {
|
|
|
656
677
|
window.mParticle.captureTiming(metricName);
|
|
657
678
|
}
|
|
658
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
|
+
}
|
|
659
747
|
};
|
|
660
748
|
|
|
661
749
|
function generateIntegrationName(customIntegrationName) {
|
|
662
750
|
var coreSdkVersion = window.mParticle.getVersion();
|
|
663
|
-
var kitVersion = "1.
|
|
751
|
+
var kitVersion = "1.17.0";
|
|
664
752
|
var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
|
|
665
753
|
|
|
666
754
|
if (customIntegrationName) {
|