Skip to content

Commit 7bafe6d

Browse files
chore(build): Generate latest bundle [skip ci]
1 parent 1fea071 commit 7bafe6d

File tree

2 files changed

+174
-2
lines changed

2 files changed

+174
-2
lines changed

dist/Rokt-Kit.common.js

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ var constructor = function () {
259259
);
260260
launcherOptions.integrationName = self.integrationName;
261261

262+
self.domain = domain;
263+
262264
if (testMode) {
263265
self.testHelpers = {
264266
generateLauncherScript: generateLauncherScript,
@@ -268,6 +270,12 @@ var constructor = function () {
268270
generateMappedEventLookup: generateMappedEventLookup,
269271
generateMappedEventAttributeLookup:
270272
generateMappedEventAttributeLookup,
273+
sendAdBlockMeasurementSignals: sendAdBlockMeasurementSignals,
274+
createAutoRemovedIframe: createAutoRemovedIframe,
275+
djb2: djb2,
276+
setAllowedOriginHash: function (hash) {
277+
_allowedOriginHash = hash;
278+
},
271279
};
272280
attachLauncher(accountId, launcherOptions);
273281
return;
@@ -487,6 +495,8 @@ var constructor = function () {
487495
return;
488496
}
489497

498+
_sendEventStream(event);
499+
490500
if (
491501
typeof window.mParticle.Rokt.setLocalSessionAttribute !== 'function'
492502
) {
@@ -513,6 +523,12 @@ var constructor = function () {
513523
}
514524
}
515525

526+
function _sendEventStream(event) {
527+
if (window.Rokt && typeof window.Rokt.__event_stream__ === 'function') {
528+
window.Rokt.__event_stream__(event);
529+
}
530+
}
531+
516532
function onUserIdentified(filteredUser) {
517533
self.filters.filteredUser = filteredUser;
518534
self.userAttributes = filteredUser.getAllUserAttributes();
@@ -565,6 +581,9 @@ var constructor = function () {
565581

566582
// Kit must be initialized before attaching to the Rokt manager
567583
self.isInitialized = true;
584+
585+
sendAdBlockMeasurementSignals(self.domain, self.integrationName);
586+
568587
// Attaches the kit to the Rokt manager
569588
window.mParticle.Rokt.attachKit(self);
570589
processEventQueue();
@@ -659,11 +678,78 @@ var constructor = function () {
659678
window.mParticle.captureTiming(metricName);
660679
}
661680
}
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+
}
662748
};
663749

664750
function generateIntegrationName(customIntegrationName) {
665751
var coreSdkVersion = window.mParticle.getVersion();
666-
var kitVersion = "1.16.0";
752+
var kitVersion = "1.17.0";
667753
var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
668754

669755
if (customIntegrationName) {

dist/Rokt-Kit.iife.js

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ var RoktKit = (function (exports) {
258258
);
259259
launcherOptions.integrationName = self.integrationName;
260260

261+
self.domain = domain;
262+
261263
if (testMode) {
262264
self.testHelpers = {
263265
generateLauncherScript: generateLauncherScript,
@@ -267,6 +269,12 @@ var RoktKit = (function (exports) {
267269
generateMappedEventLookup: generateMappedEventLookup,
268270
generateMappedEventAttributeLookup:
269271
generateMappedEventAttributeLookup,
272+
sendAdBlockMeasurementSignals: sendAdBlockMeasurementSignals,
273+
createAutoRemovedIframe: createAutoRemovedIframe,
274+
djb2: djb2,
275+
setAllowedOriginHash: function (hash) {
276+
_allowedOriginHash = hash;
277+
},
270278
};
271279
attachLauncher(accountId, launcherOptions);
272280
return;
@@ -486,6 +494,8 @@ var RoktKit = (function (exports) {
486494
return;
487495
}
488496

497+
_sendEventStream(event);
498+
489499
if (
490500
typeof window.mParticle.Rokt.setLocalSessionAttribute !== 'function'
491501
) {
@@ -512,6 +522,12 @@ var RoktKit = (function (exports) {
512522
}
513523
}
514524

525+
function _sendEventStream(event) {
526+
if (window.Rokt && typeof window.Rokt.__event_stream__ === 'function') {
527+
window.Rokt.__event_stream__(event);
528+
}
529+
}
530+
515531
function onUserIdentified(filteredUser) {
516532
self.filters.filteredUser = filteredUser;
517533
self.userAttributes = filteredUser.getAllUserAttributes();
@@ -564,6 +580,9 @@ var RoktKit = (function (exports) {
564580

565581
// Kit must be initialized before attaching to the Rokt manager
566582
self.isInitialized = true;
583+
584+
sendAdBlockMeasurementSignals(self.domain, self.integrationName);
585+
567586
// Attaches the kit to the Rokt manager
568587
window.mParticle.Rokt.attachKit(self);
569588
processEventQueue();
@@ -658,11 +677,78 @@ var RoktKit = (function (exports) {
658677
window.mParticle.captureTiming(metricName);
659678
}
660679
}
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+
}
661747
};
662748

663749
function generateIntegrationName(customIntegrationName) {
664750
var coreSdkVersion = window.mParticle.getVersion();
665-
var kitVersion = "1.16.0";
751+
var kitVersion = "1.17.0";
666752
var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
667753

668754
if (customIntegrationName) {

0 commit comments

Comments
 (0)