Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions dist/Rokt-Kit.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ var constructor = function () {
);
launcherOptions.integrationName = self.integrationName;

self.domain = domain;

if (testMode) {
self.testHelpers = {
generateLauncherScript: generateLauncherScript,
Expand All @@ -268,6 +270,8 @@ var constructor = function () {
generateMappedEventLookup: generateMappedEventLookup,
generateMappedEventAttributeLookup:
generateMappedEventAttributeLookup,
sendAdBlockMeasurementSignals: sendAdBlockMeasurementSignals,
createAutoRemovedIframe: createAutoRemovedIframe,
};
attachLauncher(accountId, launcherOptions);
return;
Expand Down Expand Up @@ -565,6 +569,9 @@ var constructor = function () {

// Kit must be initialized before attaching to the Rokt manager
self.isInitialized = true;

sendAdBlockMeasurementSignals(self.domain, self.integrationName);

// Attaches the kit to the Rokt manager
window.mParticle.Rokt.attachKit(self);
processEventQueue();
Expand Down Expand Up @@ -659,6 +666,59 @@ var constructor = function () {
window.mParticle.captureTiming(metricName);
}
}

function createAutoRemovedIframe(src) {
var iframe = document.createElement('iframe');
iframe.style.display = 'none';
iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
iframe.src = src;
iframe.onload = function () {
iframe.onload = null;
if (iframe.parentNode) {
iframe.parentNode.removeChild(iframe);
}
};
var target = document.body || document.head;
if (target) {
target.appendChild(iframe);
}
}

var ADBLOCK_CONTROL_DOMAIN = 'apps.roktecommerce.com';
var INIT_LOG_SAMPLING_RATE = 0.1;

function sendAdBlockMeasurementSignals(domain, version) {
if (Math.random() >= INIT_LOG_SAMPLING_RATE) {
return;
}

var guid = window.__rokt_li_guid__;
if (!guid) {
return;
}

var pageUrl = window.location.href.split('?')[0].split('#')[0];
var params =
'version=' +
encodeURIComponent(version) +
'&launcherInstanceGuid=' +
encodeURIComponent(guid) +
'&pageUrl=' +
encodeURIComponent(pageUrl);

var existingDomain = domain || 'apps.rokt.com';
createAutoRemovedIframe(
'https://' + existingDomain + '/v1/wsdk-init/index.html?' + params
);

createAutoRemovedIframe(
'https://' +
ADBLOCK_CONTROL_DOMAIN +
'/v1/wsdk-init/index.html?' +
params +
'&isControl=true'
);
}
};

function generateIntegrationName(customIntegrationName) {
Expand Down
60 changes: 60 additions & 0 deletions dist/Rokt-Kit.iife.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ var RoktKit = (function (exports) {
);
launcherOptions.integrationName = self.integrationName;

self.domain = domain;

if (testMode) {
self.testHelpers = {
generateLauncherScript: generateLauncherScript,
Expand All @@ -267,6 +269,8 @@ var RoktKit = (function (exports) {
generateMappedEventLookup: generateMappedEventLookup,
generateMappedEventAttributeLookup:
generateMappedEventAttributeLookup,
sendAdBlockMeasurementSignals: sendAdBlockMeasurementSignals,
createAutoRemovedIframe: createAutoRemovedIframe,
};
attachLauncher(accountId, launcherOptions);
return;
Expand Down Expand Up @@ -564,6 +568,9 @@ var RoktKit = (function (exports) {

// Kit must be initialized before attaching to the Rokt manager
self.isInitialized = true;

sendAdBlockMeasurementSignals(self.domain, self.integrationName);

// Attaches the kit to the Rokt manager
window.mParticle.Rokt.attachKit(self);
processEventQueue();
Expand Down Expand Up @@ -658,6 +665,59 @@ var RoktKit = (function (exports) {
window.mParticle.captureTiming(metricName);
}
}

function createAutoRemovedIframe(src) {
var iframe = document.createElement('iframe');
iframe.style.display = 'none';
iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
iframe.src = src;
iframe.onload = function () {
iframe.onload = null;
if (iframe.parentNode) {
iframe.parentNode.removeChild(iframe);
}
};
var target = document.body || document.head;
if (target) {
target.appendChild(iframe);
}
}

var ADBLOCK_CONTROL_DOMAIN = 'apps.roktecommerce.com';
var INIT_LOG_SAMPLING_RATE = 0.1;

function sendAdBlockMeasurementSignals(domain, version) {
if (Math.random() >= INIT_LOG_SAMPLING_RATE) {
return;
}

var guid = window.__rokt_li_guid__;
if (!guid) {
return;
}

var pageUrl = window.location.href.split('?')[0].split('#')[0];
var params =
'version=' +
encodeURIComponent(version) +
'&launcherInstanceGuid=' +
encodeURIComponent(guid) +
'&pageUrl=' +
encodeURIComponent(pageUrl);

var existingDomain = domain || 'apps.rokt.com';
createAutoRemovedIframe(
'https://' + existingDomain + '/v1/wsdk-init/index.html?' + params
);

createAutoRemovedIframe(
'https://' +
ADBLOCK_CONTROL_DOMAIN +
'/v1/wsdk-init/index.html?' +
params +
'&isControl=true'
);
}
};

function generateIntegrationName(customIntegrationName) {
Expand Down
60 changes: 60 additions & 0 deletions src/Rokt-Kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ var constructor = function () {
);
launcherOptions.integrationName = self.integrationName;

self.domain = domain;

if (testMode) {
self.testHelpers = {
generateLauncherScript: generateLauncherScript,
Expand All @@ -264,6 +266,8 @@ var constructor = function () {
generateMappedEventLookup: generateMappedEventLookup,
generateMappedEventAttributeLookup:
generateMappedEventAttributeLookup,
sendAdBlockMeasurementSignals: sendAdBlockMeasurementSignals,
createAutoRemovedIframe: createAutoRemovedIframe,
};
attachLauncher(accountId, launcherOptions);
return;
Expand Down Expand Up @@ -561,6 +565,9 @@ var constructor = function () {

// Kit must be initialized before attaching to the Rokt manager
self.isInitialized = true;

sendAdBlockMeasurementSignals(self.domain, self.integrationName);

// Attaches the kit to the Rokt manager
window.mParticle.Rokt.attachKit(self);
processEventQueue();
Expand Down Expand Up @@ -655,6 +662,59 @@ var constructor = function () {
window.mParticle.captureTiming(metricName);
}
}

function createAutoRemovedIframe(src) {
var iframe = document.createElement('iframe');
iframe.style.display = 'none';
iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
iframe.src = src;
iframe.onload = function () {
iframe.onload = null;
if (iframe.parentNode) {
iframe.parentNode.removeChild(iframe);
}
};
var target = document.body || document.head;
if (target) {
target.appendChild(iframe);
}
}

var ADBLOCK_CONTROL_DOMAIN = 'apps.roktecommerce.com';
var INIT_LOG_SAMPLING_RATE = 0.1;

function sendAdBlockMeasurementSignals(domain, version) {
if (Math.random() >= INIT_LOG_SAMPLING_RATE) {
return;
}

var guid = window.__rokt_li_guid__;
if (!guid) {
return;
}

var pageUrl = window.location.href.split('?')[0].split('#')[0];
var params =
'version=' +
encodeURIComponent(version) +
'&launcherInstanceGuid=' +
encodeURIComponent(guid) +
'&pageUrl=' +
encodeURIComponent(pageUrl);

var existingDomain = domain || 'apps.rokt.com';
createAutoRemovedIframe(
'https://' + existingDomain + '/v1/wsdk-init/index.html?' + params
);

createAutoRemovedIframe(
'https://' +
ADBLOCK_CONTROL_DOMAIN +
'/v1/wsdk-init/index.html?' +
params +
'&isControl=true'
);
}
};

function generateIntegrationName(customIntegrationName) {
Expand Down
Loading
Loading