diff --git a/kits/adobe-target/dist/AdobeTarget-Kit.common.js b/kits/adobe-target/dist/AdobeTarget-Kit.common.js new file mode 100644 index 000000000..70cd63102 --- /dev/null +++ b/kits/adobe-target/dist/AdobeTarget-Kit.common.js @@ -0,0 +1,825 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +function Common() {} + +Common.prototype.exampleMethod = function() { + return 'I am an example'; +}; + +var common = Common; + +function CommerceHandler(common) { + this.common = common || {}; +} + +CommerceHandler.prototype.logCommerceEvent = function(event) { + var MBOXNAME = event.CustomFlags['ADOBETARGET.MBOX']; + var price = event.ProductAction.TotalAmount || 0; + var productSkus = []; + + if (!MBOXNAME) { + console.warn( + 'ADOBE.MBOX not passed as custom flag; not forwarding to Adobe Target' + ); + return; + } + + if (event.ProductAction && event.ProductAction.ProductList.length) { + event.ProductAction.ProductList.forEach(function(product) { + if (product.Sku) { + productSkus.push(product.Sku); + } + }); + + switch (event.EventCategory) { + case mParticle.CommerceEventType.ProductPurchase: + window.adobe.target.trackEvent({ + mbox: MBOXNAME, + params: { + orderId: event.ProductAction.TransactionId, + orderTotal: price, + productPurchasedId: productSkus.join(', '), + }, + }); + break; + default: + console.warn( + 'Only product purchases are mapped to Adobe Target. Event not forwarded.' + ); + } + } + + /* + Sample ecommerce event schema: + { + CurrencyCode: 'USD', + DeviceId:'a80eea1c-57f5-4f84-815e-06fe971b6ef2', // MP generated + EventAttributes: { key1: 'value1', key2: 'value2' }, + EventType: 16, + EventCategory: 10, // (This is an add product to cart event, see below for additional ecommerce EventCategories) + EventName: "eCommerce - AddToCart", + MPID: "8278431810143183490", + ProductAction: { + Affiliation: 'aff1', + CouponCode: 'coupon', + ProductActionType: 7, + ProductList: [ + { + Attributes: { prodKey1: 'prodValue1', prodKey2: 'prodValue2' }, + Brand: 'Apple', + Category: 'phones', + CouponCode: 'coupon1', + Name: 'iPhone', + Price: '600', + Quantity: 2, + Sku: "SKU123", + TotalAmount: 1200, + Variant: '64GB' + } + ], + TransactionId: "tid1", + ShippingAmount: 10, + TaxAmount: 5, + TotalAmount: 1215, + }, + UserAttributes: { userKey1: 'userValue1', userKey2: 'userValue2' } + UserIdentities: [ + { + Identity: 'test@gmail.com', Type: 7 + } + ] + } + + If your SDK has specific ways to log different eCommerce events, see below for + mParticle's additional ecommerce EventCategory types: + + 10: ProductAddToCart, (as shown above) + 11: ProductRemoveFromCart, + 12: ProductCheckout, + 13: ProductCheckoutOption, + 14: ProductClick, + 15: ProductViewDetail, + 16: ProductPurchase, + 17: ProductRefund, + 18: PromotionView, + 19: PromotionClick, + 20: ProductAddToWishlist, + 21: ProductRemoveFromWishlist, + 22: ProductImpression + */ +}; + +var commerceHandler = CommerceHandler; + +function EventHandler(common) { + this.common = common || {}; +} + +EventHandler.prototype.logEvent = function(event) { + var MBOXNAME = event.CustomFlags['ADOBETARGET.MBOX']; + var successHandler = event.CustomFlags['ADOBETARGET.SUCCESS']; + var errorHandler = event.CustomFlags['ADOBETARGET.ERROR']; + var getOffer = event.CustomFlags['ADOBETARGET.GETOFFER']; + var timeout = event.CustomFlags['ADOBETARGET.TIMEOUT']; + + if (!MBOXNAME) { + console.warn( + 'ADOBE.MBOX not passed as custom flag; not forwarding to Adobe Target' + ); + return false; + } + + var params = {}; + for (var key in event.EventAttributes) { + params[key] = event.EventAttributes[key]; + } + + var options = { + mbox: MBOXNAME, + params: params, + }; + + if (timeout) { + options.timeout = timeout; + } + + // an event is either a getOffer event or a trackEvent event + if (getOffer) { + options.success = function(offer) { + window.adobe.target.applyOffer(offer); + if (successHandler && typeof successHandler === 'function') { + successHandler(offer); + } + }; + options.error = function(status, error) { + if (errorHandler && typeof errorHandler === 'function') { + errorHandler(status, error); + } + }; + window.adobe.target.getOffer(options); + } else { + var selector = event.CustomFlags['ADOBETARGET.SELECTOR']; + var type = event.CustomFlags['ADOBETARGET.TYPE']; + var preventDefault = event.CustomFlags['ADOBETARGET.PREVENTDEFAULT']; + + if (selector) { + options.selector = selector; + } + if (type) { + options.type = type; + } + if (preventDefault) { + options.preventDefault = preventDefault; + } + + window.adobe.target.trackEvent(options); + } + + return true; +}; + +EventHandler.prototype.logError = function() {}; + +EventHandler.prototype.logPageView = function(event) { + this.logEvent(event); +}; + +var eventHandler = EventHandler; + +/* +The 'mParticleUser' is an object with methods get user Identities and set/get user attributes +Partners can determine what userIds are available to use in their SDK +Call mParticleUser.getUserIdentities() to return an object of userIdentities --> { userIdentities: {customerid: '1234', email: 'email@gmail.com'} } +For more identity types, see http://docs.mparticle.com/developers/sdk/javascript/identity#allowed-identity-types +Call mParticleUser.getMPID() to get mParticle ID +For any additional methods, see http://docs.mparticle.com/developers/sdk/javascript/apidocs/classes/mParticle.Identity.getCurrentUser().html +*/ + +/* +identityApiRequest has the schema: +{ + userIdentities: { + customerid: '123', + email: 'abc' + } +} +For more userIdentity types, see http://docs.mparticle.com/developers/sdk/javascript/identity#allowed-identity-types +*/ + +function IdentityHandler(common) { + this.common = common || {}; +} +IdentityHandler.prototype.onUserIdentified = function(mParticleUser) {}; +IdentityHandler.prototype.onIdentifyComplete = function( + mParticleUser, + identityApiRequest +) {}; +IdentityHandler.prototype.onLoginComplete = function( + mParticleUser, + identityApiRequest +) {}; +IdentityHandler.prototype.onLogoutComplete = function( + mParticleUser, + identityApiRequest +) {}; +IdentityHandler.prototype.onModifyComplete = function( + mParticleUser, + identityApiRequest +) {}; + +/* In previous versions of the mParticle web SDK, setting user identities on + kits is only reachable via the onSetUserIdentity method below. We recommend + filling out `onSetUserIdentity` for maximum compatibility +*/ +IdentityHandler.prototype.onSetUserIdentity = function( + forwarderSettings, + id, + type +) {}; + +var identityHandler = IdentityHandler; + +var initialization = { + name: 'AdobeTarget', + initForwarder: function( + forwarderSettings, + testMode, + userAttributes, + userIdentities, + processEvent, + eventQueue, + isInitialized + ) { + if (!testMode) { + // Adobe Target's at.js file is hosted by the customer, loaded before mParticle.js, and has initialization code inside of at.js + var adobeTargetPresent = window.adobe && window.adobe.target; + } + }, +}; + +var initialization_1 = initialization; + +var sessionHandler = { + onSessionStart: function(event) {}, + onSessionEnd: function(event) {}, +}; + +var sessionHandler_1 = sessionHandler; + +/* +The 'mParticleUser' is an object with methods on it to get user Identities and set/get user attributes +Partners can determine what userIds are available to use in their SDK +Call mParticleUser.getUserIdentities() to return an object of userIdentities --> { userIdentities: {customerid: '1234', email: 'email@gmail.com'} } +For more identity types, see http://docs.mparticle.com/developers/sdk/javascript/identity#allowed-identity-types +Call mParticleUser.getMPID() to get mParticle ID +For any additional methods, see http://docs.mparticle.com/developers/sdk/javascript/apidocs/classes/mParticle.Identity.getCurrentUser().html +*/ + +function UserAttributeHandler(common) { + this.common = common = {}; +} +UserAttributeHandler.prototype.onRemoveUserAttribute = function( + key, + mParticleUser +) {}; +UserAttributeHandler.prototype.onSetUserAttribute = function( + key, + value, + mParticleUser +) {}; +UserAttributeHandler.prototype.onConsentStateUpdated = function( + oldState, + newState, + mParticleUser +) {}; + +var userAttributeHandler = UserAttributeHandler; + +// =============== REACH OUT TO MPARTICLE IF YOU HAVE ANY QUESTIONS =============== +// +// Copyright 2018 mParticle, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + + + + + + + + +var name = initialization_1.name, + moduleId = initialization_1.moduleId, + MessageType = { + SessionStart: 1, + SessionEnd: 2, + PageView: 3, + PageEvent: 4, + CrashReport: 5, + OptOut: 6, + Commerce: 16, + Media: 20, + }; + +var constructor = function() { + var self = this, + isInitialized = false, + forwarderSettings, + reportingService, + eventQueue = []; + + self.name = initialization_1.name; + self.moduleId = initialization_1.moduleId; + self.common = new common(); + + function initForwarder( + settings, + service, + testMode, + trackerId, + userAttributes, + userIdentities, + appVersion, + appName, + customFlags, + clientId + ) { + forwarderSettings = settings; + + if ( + typeof window !== 'undefined' && + window.mParticle.isTestEnvironment + ) { + reportingService = function() {}; + } else { + reportingService = service; + } + + try { + initialization_1.initForwarder( + settings, + testMode, + userAttributes, + userIdentities, + processEvent, + eventQueue, + isInitialized, + self.common, + appVersion, + appName, + customFlags, + clientId + ); + self.eventHandler = new eventHandler(self.common); + self.identityHandler = new identityHandler(self.common); + self.userAttributeHandler = new userAttributeHandler(self.common); + self.commerceHandler = new commerceHandler(self.common); + + isInitialized = true; + } catch (e) { + console.log('Failed to initialize ' + name + ' - ' + e); + } + } + + function processEvent(event) { + var reportEvent = false; + if (isInitialized) { + try { + if (event.EventDataType === MessageType.SessionStart) { + reportEvent = logSessionStart(event); + } else if (event.EventDataType === MessageType.SessionEnd) { + reportEvent = logSessionEnd(event); + } else if (event.EventDataType === MessageType.CrashReport) { + reportEvent = logError(event); + } else if (event.EventDataType === MessageType.PageView) { + reportEvent = logPageView(event); + } else if (event.EventDataType === MessageType.Commerce) { + reportEvent = logEcommerceEvent(event); + } else if (event.EventDataType === MessageType.PageEvent) { + reportEvent = logEvent(event); + } else if (event.EventDataType === MessageType.Media) { + // Kits should just treat Media Events as generic Events + reportEvent = logEvent(event); + } + if (reportEvent === true && reportingService) { + reportingService(self, event); + return 'Successfully sent to ' + name; + } else { + return ( + 'Error logging event or event type not supported on forwarder ' + + name + ); + } + } catch (e) { + return 'Failed to send to ' + name + ' ' + e; + } + } else { + eventQueue.push(event); + return ( + "Can't send to forwarder " + + name + + ', not initialized. Event added to queue.' + ); + } + } + + function logSessionStart(event) { + try { + sessionHandler_1.onSessionStart(event); + return true; + } catch (e) { + return { + error: 'Error starting session on forwarder ' + name + '; ' + e, + }; + } + } + + function logSessionEnd(event) { + try { + sessionHandler_1.onSessionEnd(event); + return true; + } catch (e) { + return { + error: 'Error ending session on forwarder ' + name + '; ' + e, + }; + } + } + + function logError(event) { + try { + self.eventHandler.logError(event); + return true; + } catch (e) { + return { + error: 'Error logging error on forwarder ' + name + '; ' + e, + }; + } + } + + function logPageView(event) { + try { + self.eventHandler.logPageView(event); + return true; + } catch (e) { + return { + error: + 'Error logging page view on forwarder ' + name + '; ' + e, + }; + } + } + + function logEvent(event) { + try { + self.eventHandler.logEvent(event); + return true; + } catch (e) { + return { + error: 'Error logging event on forwarder ' + name + '; ' + e, + }; + } + } + + function logEcommerceEvent(event) { + try { + self.commerceHandler.logCommerceEvent(event); + return true; + } catch (e) { + return { + error: + 'Error logging purchase event on forwarder ' + + name + + '; ' + + e, + }; + } + } + + function setUserAttribute(key, value) { + if (isInitialized) { + try { + self.userAttributeHandler.onSetUserAttribute( + key, + value, + forwarderSettings + ); + return 'Successfully set user attribute on forwarder ' + name; + } catch (e) { + return ( + 'Error setting user attribute on forwarder ' + + name + + '; ' + + e + ); + } + } else { + return ( + "Can't set user attribute on forwarder " + + name + + ', not initialized' + ); + } + } + + function removeUserAttribute(key) { + if (isInitialized) { + try { + self.userAttributeHandler.onRemoveUserAttribute( + key, + forwarderSettings + ); + return ( + 'Successfully removed user attribute on forwarder ' + name + ); + } catch (e) { + return ( + 'Error removing user attribute on forwarder ' + + name + + '; ' + + e + ); + } + } else { + return ( + "Can't remove user attribute on forwarder " + + name + + ', not initialized' + ); + } + } + + function setUserIdentity(id, type) { + if (isInitialized) { + try { + self.identityHandler.onSetUserIdentity( + forwarderSettings, + id, + type + ); + return 'Successfully set user Identity on forwarder ' + name; + } catch (e) { + return ( + 'Error removing user attribute on forwarder ' + + name + + '; ' + + e + ); + } + } else { + return ( + "Can't call setUserIdentity on forwarder " + + name + + ', not initialized' + ); + } + } + + function onUserIdentified(user) { + if (isInitialized) { + try { + self.identityHandler.onUserIdentified(user); + + return ( + 'Successfully called onUserIdentified on forwarder ' + name + ); + } catch (e) { + return { + error: + 'Error calling onUserIdentified on forwarder ' + + name + + '; ' + + e, + }; + } + } else { + return ( + "Can't set new user identities on forwader " + + name + + ', not initialized' + ); + } + } + + function onIdentifyComplete(user, filteredIdentityRequest) { + if (isInitialized) { + try { + self.identityHandler.onIdentifyComplete( + user, + filteredIdentityRequest + ); + + return ( + 'Successfully called onIdentifyComplete on forwarder ' + + name + ); + } catch (e) { + return { + error: + 'Error calling onIdentifyComplete on forwarder ' + + name + + '; ' + + e, + }; + } + } else { + return ( + "Can't call onIdentifyCompleted on forwader " + + name + + ', not initialized' + ); + } + } + + function onLoginComplete(user, filteredIdentityRequest) { + if (isInitialized) { + try { + self.identityHandler.onLoginComplete( + user, + filteredIdentityRequest + ); + + return ( + 'Successfully called onLoginComplete on forwarder ' + name + ); + } catch (e) { + return { + error: + 'Error calling onLoginComplete on forwarder ' + + name + + '; ' + + e, + }; + } + } else { + return ( + "Can't call onLoginComplete on forwader " + + name + + ', not initialized' + ); + } + } + + function onLogoutComplete(user, filteredIdentityRequest) { + if (isInitialized) { + try { + self.identityHandler.onLogoutComplete( + user, + filteredIdentityRequest + ); + + return ( + 'Successfully called onLogoutComplete on forwarder ' + name + ); + } catch (e) { + return { + error: + 'Error calling onLogoutComplete on forwarder ' + + name + + '; ' + + e, + }; + } + } else { + return ( + "Can't call onLogoutComplete on forwader " + + name + + ', not initialized' + ); + } + } + + function onModifyComplete(user, filteredIdentityRequest) { + if (isInitialized) { + try { + self.identityHandler.onModifyComplete( + user, + filteredIdentityRequest + ); + + return ( + 'Successfully called onModifyComplete on forwarder ' + name + ); + } catch (e) { + return { + error: + 'Error calling onModifyComplete on forwarder ' + + name + + '; ' + + e, + }; + } + } else { + return ( + "Can't call onModifyComplete on forwader " + + name + + ', not initialized' + ); + } + } + + function setOptOut(isOptingOutBoolean) { + if (isInitialized) { + try { + self.initialization.setOptOut(isOptingOutBoolean); + + return 'Successfully called setOptOut on forwarder ' + name; + } catch (e) { + return { + error: + 'Error calling setOptOut on forwarder ' + + name + + '; ' + + e, + }; + } + } else { + return ( + "Can't call setOptOut on forwader " + + name + + ', not initialized' + ); + } + } + + this.init = initForwarder; + this.process = processEvent; + this.setUserAttribute = setUserAttribute; + this.removeUserAttribute = removeUserAttribute; + this.onUserIdentified = onUserIdentified; + this.setUserIdentity = setUserIdentity; + this.onIdentifyComplete = onIdentifyComplete; + this.onLoginComplete = onLoginComplete; + this.onLogoutComplete = onLogoutComplete; + this.onModifyComplete = onModifyComplete; + this.setOptOut = setOptOut; +}; + +function getId() { + return moduleId; +} + +function isObject(val) { + return ( + val != null && typeof val === 'object' && Array.isArray(val) === false + ); +} + +function register(config) { + if (!config) { + console.log( + 'You must pass a config object to register the kit ' + name + ); + return; + } + + if (!isObject(config)) { + console.log( + "'config' must be an object. You passed in a " + typeof config + ); + return; + } + + if (isObject(config.kits)) { + config.kits[name] = { + constructor: constructor, + }; + } else { + config.kits = {}; + config.kits[name] = { + constructor: constructor, + }; + } + console.log( + 'Successfully registered ' + name + ' to your mParticle configuration' + ); +} + +if (typeof window !== 'undefined') { + if (window && window.mParticle && window.mParticle.addForwarder) { + window.mParticle.addForwarder({ + name: name, + constructor: constructor, + getId: getId, + }); + } +} + +var webKitWrapper = { + register: register, +}; +var webKitWrapper_1 = webKitWrapper.register; + +exports.default = webKitWrapper; +exports.register = webKitWrapper_1; diff --git a/kits/adobe-target/dist/AdobeTarget-Kit.iife.js b/kits/adobe-target/dist/AdobeTarget-Kit.iife.js new file mode 100644 index 000000000..cf3a6a19b --- /dev/null +++ b/kits/adobe-target/dist/AdobeTarget-Kit.iife.js @@ -0,0 +1,828 @@ +var AdobeTargetKit = (function (exports) { + 'use strict'; + + function Common() {} + + Common.prototype.exampleMethod = function() { + return 'I am an example'; + }; + + var common = Common; + + function CommerceHandler(common) { + this.common = common || {}; + } + + CommerceHandler.prototype.logCommerceEvent = function(event) { + var MBOXNAME = event.CustomFlags['ADOBETARGET.MBOX']; + var price = event.ProductAction.TotalAmount || 0; + var productSkus = []; + + if (!MBOXNAME) { + console.warn( + 'ADOBE.MBOX not passed as custom flag; not forwarding to Adobe Target' + ); + return; + } + + if (event.ProductAction && event.ProductAction.ProductList.length) { + event.ProductAction.ProductList.forEach(function(product) { + if (product.Sku) { + productSkus.push(product.Sku); + } + }); + + switch (event.EventCategory) { + case mParticle.CommerceEventType.ProductPurchase: + window.adobe.target.trackEvent({ + mbox: MBOXNAME, + params: { + orderId: event.ProductAction.TransactionId, + orderTotal: price, + productPurchasedId: productSkus.join(', '), + }, + }); + break; + default: + console.warn( + 'Only product purchases are mapped to Adobe Target. Event not forwarded.' + ); + } + } + + /* + Sample ecommerce event schema: + { + CurrencyCode: 'USD', + DeviceId:'a80eea1c-57f5-4f84-815e-06fe971b6ef2', // MP generated + EventAttributes: { key1: 'value1', key2: 'value2' }, + EventType: 16, + EventCategory: 10, // (This is an add product to cart event, see below for additional ecommerce EventCategories) + EventName: "eCommerce - AddToCart", + MPID: "8278431810143183490", + ProductAction: { + Affiliation: 'aff1', + CouponCode: 'coupon', + ProductActionType: 7, + ProductList: [ + { + Attributes: { prodKey1: 'prodValue1', prodKey2: 'prodValue2' }, + Brand: 'Apple', + Category: 'phones', + CouponCode: 'coupon1', + Name: 'iPhone', + Price: '600', + Quantity: 2, + Sku: "SKU123", + TotalAmount: 1200, + Variant: '64GB' + } + ], + TransactionId: "tid1", + ShippingAmount: 10, + TaxAmount: 5, + TotalAmount: 1215, + }, + UserAttributes: { userKey1: 'userValue1', userKey2: 'userValue2' } + UserIdentities: [ + { + Identity: 'test@gmail.com', Type: 7 + } + ] + } + + If your SDK has specific ways to log different eCommerce events, see below for + mParticle's additional ecommerce EventCategory types: + + 10: ProductAddToCart, (as shown above) + 11: ProductRemoveFromCart, + 12: ProductCheckout, + 13: ProductCheckoutOption, + 14: ProductClick, + 15: ProductViewDetail, + 16: ProductPurchase, + 17: ProductRefund, + 18: PromotionView, + 19: PromotionClick, + 20: ProductAddToWishlist, + 21: ProductRemoveFromWishlist, + 22: ProductImpression + */ + }; + + var commerceHandler = CommerceHandler; + + function EventHandler(common) { + this.common = common || {}; + } + + EventHandler.prototype.logEvent = function(event) { + var MBOXNAME = event.CustomFlags['ADOBETARGET.MBOX']; + var successHandler = event.CustomFlags['ADOBETARGET.SUCCESS']; + var errorHandler = event.CustomFlags['ADOBETARGET.ERROR']; + var getOffer = event.CustomFlags['ADOBETARGET.GETOFFER']; + var timeout = event.CustomFlags['ADOBETARGET.TIMEOUT']; + + if (!MBOXNAME) { + console.warn( + 'ADOBE.MBOX not passed as custom flag; not forwarding to Adobe Target' + ); + return false; + } + + var params = {}; + for (var key in event.EventAttributes) { + params[key] = event.EventAttributes[key]; + } + + var options = { + mbox: MBOXNAME, + params: params, + }; + + if (timeout) { + options.timeout = timeout; + } + + // an event is either a getOffer event or a trackEvent event + if (getOffer) { + options.success = function(offer) { + window.adobe.target.applyOffer(offer); + if (successHandler && typeof successHandler === 'function') { + successHandler(offer); + } + }; + options.error = function(status, error) { + if (errorHandler && typeof errorHandler === 'function') { + errorHandler(status, error); + } + }; + window.adobe.target.getOffer(options); + } else { + var selector = event.CustomFlags['ADOBETARGET.SELECTOR']; + var type = event.CustomFlags['ADOBETARGET.TYPE']; + var preventDefault = event.CustomFlags['ADOBETARGET.PREVENTDEFAULT']; + + if (selector) { + options.selector = selector; + } + if (type) { + options.type = type; + } + if (preventDefault) { + options.preventDefault = preventDefault; + } + + window.adobe.target.trackEvent(options); + } + + return true; + }; + + EventHandler.prototype.logError = function() {}; + + EventHandler.prototype.logPageView = function(event) { + this.logEvent(event); + }; + + var eventHandler = EventHandler; + + /* + The 'mParticleUser' is an object with methods get user Identities and set/get user attributes + Partners can determine what userIds are available to use in their SDK + Call mParticleUser.getUserIdentities() to return an object of userIdentities --> { userIdentities: {customerid: '1234', email: 'email@gmail.com'} } + For more identity types, see http://docs.mparticle.com/developers/sdk/javascript/identity#allowed-identity-types + Call mParticleUser.getMPID() to get mParticle ID + For any additional methods, see http://docs.mparticle.com/developers/sdk/javascript/apidocs/classes/mParticle.Identity.getCurrentUser().html + */ + + /* + identityApiRequest has the schema: + { + userIdentities: { + customerid: '123', + email: 'abc' + } + } + For more userIdentity types, see http://docs.mparticle.com/developers/sdk/javascript/identity#allowed-identity-types + */ + + function IdentityHandler(common) { + this.common = common || {}; + } + IdentityHandler.prototype.onUserIdentified = function(mParticleUser) {}; + IdentityHandler.prototype.onIdentifyComplete = function( + mParticleUser, + identityApiRequest + ) {}; + IdentityHandler.prototype.onLoginComplete = function( + mParticleUser, + identityApiRequest + ) {}; + IdentityHandler.prototype.onLogoutComplete = function( + mParticleUser, + identityApiRequest + ) {}; + IdentityHandler.prototype.onModifyComplete = function( + mParticleUser, + identityApiRequest + ) {}; + + /* In previous versions of the mParticle web SDK, setting user identities on + kits is only reachable via the onSetUserIdentity method below. We recommend + filling out `onSetUserIdentity` for maximum compatibility + */ + IdentityHandler.prototype.onSetUserIdentity = function( + forwarderSettings, + id, + type + ) {}; + + var identityHandler = IdentityHandler; + + var initialization = { + name: 'AdobeTarget', + initForwarder: function( + forwarderSettings, + testMode, + userAttributes, + userIdentities, + processEvent, + eventQueue, + isInitialized + ) { + if (!testMode) { + // Adobe Target's at.js file is hosted by the customer, loaded before mParticle.js, and has initialization code inside of at.js + var adobeTargetPresent = window.adobe && window.adobe.target; + } + }, + }; + + var initialization_1 = initialization; + + var sessionHandler = { + onSessionStart: function(event) {}, + onSessionEnd: function(event) {}, + }; + + var sessionHandler_1 = sessionHandler; + + /* + The 'mParticleUser' is an object with methods on it to get user Identities and set/get user attributes + Partners can determine what userIds are available to use in their SDK + Call mParticleUser.getUserIdentities() to return an object of userIdentities --> { userIdentities: {customerid: '1234', email: 'email@gmail.com'} } + For more identity types, see http://docs.mparticle.com/developers/sdk/javascript/identity#allowed-identity-types + Call mParticleUser.getMPID() to get mParticle ID + For any additional methods, see http://docs.mparticle.com/developers/sdk/javascript/apidocs/classes/mParticle.Identity.getCurrentUser().html + */ + + function UserAttributeHandler(common) { + this.common = common = {}; + } + UserAttributeHandler.prototype.onRemoveUserAttribute = function( + key, + mParticleUser + ) {}; + UserAttributeHandler.prototype.onSetUserAttribute = function( + key, + value, + mParticleUser + ) {}; + UserAttributeHandler.prototype.onConsentStateUpdated = function( + oldState, + newState, + mParticleUser + ) {}; + + var userAttributeHandler = UserAttributeHandler; + + // =============== REACH OUT TO MPARTICLE IF YOU HAVE ANY QUESTIONS =============== + // + // Copyright 2018 mParticle, Inc. + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + + + + + + + + + + var name = initialization_1.name, + moduleId = initialization_1.moduleId, + MessageType = { + SessionStart: 1, + SessionEnd: 2, + PageView: 3, + PageEvent: 4, + CrashReport: 5, + OptOut: 6, + Commerce: 16, + Media: 20, + }; + + var constructor = function() { + var self = this, + isInitialized = false, + forwarderSettings, + reportingService, + eventQueue = []; + + self.name = initialization_1.name; + self.moduleId = initialization_1.moduleId; + self.common = new common(); + + function initForwarder( + settings, + service, + testMode, + trackerId, + userAttributes, + userIdentities, + appVersion, + appName, + customFlags, + clientId + ) { + forwarderSettings = settings; + + if ( + typeof window !== 'undefined' && + window.mParticle.isTestEnvironment + ) { + reportingService = function() {}; + } else { + reportingService = service; + } + + try { + initialization_1.initForwarder( + settings, + testMode, + userAttributes, + userIdentities, + processEvent, + eventQueue, + isInitialized, + self.common, + appVersion, + appName, + customFlags, + clientId + ); + self.eventHandler = new eventHandler(self.common); + self.identityHandler = new identityHandler(self.common); + self.userAttributeHandler = new userAttributeHandler(self.common); + self.commerceHandler = new commerceHandler(self.common); + + isInitialized = true; + } catch (e) { + console.log('Failed to initialize ' + name + ' - ' + e); + } + } + + function processEvent(event) { + var reportEvent = false; + if (isInitialized) { + try { + if (event.EventDataType === MessageType.SessionStart) { + reportEvent = logSessionStart(event); + } else if (event.EventDataType === MessageType.SessionEnd) { + reportEvent = logSessionEnd(event); + } else if (event.EventDataType === MessageType.CrashReport) { + reportEvent = logError(event); + } else if (event.EventDataType === MessageType.PageView) { + reportEvent = logPageView(event); + } else if (event.EventDataType === MessageType.Commerce) { + reportEvent = logEcommerceEvent(event); + } else if (event.EventDataType === MessageType.PageEvent) { + reportEvent = logEvent(event); + } else if (event.EventDataType === MessageType.Media) { + // Kits should just treat Media Events as generic Events + reportEvent = logEvent(event); + } + if (reportEvent === true && reportingService) { + reportingService(self, event); + return 'Successfully sent to ' + name; + } else { + return ( + 'Error logging event or event type not supported on forwarder ' + + name + ); + } + } catch (e) { + return 'Failed to send to ' + name + ' ' + e; + } + } else { + eventQueue.push(event); + return ( + "Can't send to forwarder " + + name + + ', not initialized. Event added to queue.' + ); + } + } + + function logSessionStart(event) { + try { + sessionHandler_1.onSessionStart(event); + return true; + } catch (e) { + return { + error: 'Error starting session on forwarder ' + name + '; ' + e, + }; + } + } + + function logSessionEnd(event) { + try { + sessionHandler_1.onSessionEnd(event); + return true; + } catch (e) { + return { + error: 'Error ending session on forwarder ' + name + '; ' + e, + }; + } + } + + function logError(event) { + try { + self.eventHandler.logError(event); + return true; + } catch (e) { + return { + error: 'Error logging error on forwarder ' + name + '; ' + e, + }; + } + } + + function logPageView(event) { + try { + self.eventHandler.logPageView(event); + return true; + } catch (e) { + return { + error: + 'Error logging page view on forwarder ' + name + '; ' + e, + }; + } + } + + function logEvent(event) { + try { + self.eventHandler.logEvent(event); + return true; + } catch (e) { + return { + error: 'Error logging event on forwarder ' + name + '; ' + e, + }; + } + } + + function logEcommerceEvent(event) { + try { + self.commerceHandler.logCommerceEvent(event); + return true; + } catch (e) { + return { + error: + 'Error logging purchase event on forwarder ' + + name + + '; ' + + e, + }; + } + } + + function setUserAttribute(key, value) { + if (isInitialized) { + try { + self.userAttributeHandler.onSetUserAttribute( + key, + value, + forwarderSettings + ); + return 'Successfully set user attribute on forwarder ' + name; + } catch (e) { + return ( + 'Error setting user attribute on forwarder ' + + name + + '; ' + + e + ); + } + } else { + return ( + "Can't set user attribute on forwarder " + + name + + ', not initialized' + ); + } + } + + function removeUserAttribute(key) { + if (isInitialized) { + try { + self.userAttributeHandler.onRemoveUserAttribute( + key, + forwarderSettings + ); + return ( + 'Successfully removed user attribute on forwarder ' + name + ); + } catch (e) { + return ( + 'Error removing user attribute on forwarder ' + + name + + '; ' + + e + ); + } + } else { + return ( + "Can't remove user attribute on forwarder " + + name + + ', not initialized' + ); + } + } + + function setUserIdentity(id, type) { + if (isInitialized) { + try { + self.identityHandler.onSetUserIdentity( + forwarderSettings, + id, + type + ); + return 'Successfully set user Identity on forwarder ' + name; + } catch (e) { + return ( + 'Error removing user attribute on forwarder ' + + name + + '; ' + + e + ); + } + } else { + return ( + "Can't call setUserIdentity on forwarder " + + name + + ', not initialized' + ); + } + } + + function onUserIdentified(user) { + if (isInitialized) { + try { + self.identityHandler.onUserIdentified(user); + + return ( + 'Successfully called onUserIdentified on forwarder ' + name + ); + } catch (e) { + return { + error: + 'Error calling onUserIdentified on forwarder ' + + name + + '; ' + + e, + }; + } + } else { + return ( + "Can't set new user identities on forwader " + + name + + ', not initialized' + ); + } + } + + function onIdentifyComplete(user, filteredIdentityRequest) { + if (isInitialized) { + try { + self.identityHandler.onIdentifyComplete( + user, + filteredIdentityRequest + ); + + return ( + 'Successfully called onIdentifyComplete on forwarder ' + + name + ); + } catch (e) { + return { + error: + 'Error calling onIdentifyComplete on forwarder ' + + name + + '; ' + + e, + }; + } + } else { + return ( + "Can't call onIdentifyCompleted on forwader " + + name + + ', not initialized' + ); + } + } + + function onLoginComplete(user, filteredIdentityRequest) { + if (isInitialized) { + try { + self.identityHandler.onLoginComplete( + user, + filteredIdentityRequest + ); + + return ( + 'Successfully called onLoginComplete on forwarder ' + name + ); + } catch (e) { + return { + error: + 'Error calling onLoginComplete on forwarder ' + + name + + '; ' + + e, + }; + } + } else { + return ( + "Can't call onLoginComplete on forwader " + + name + + ', not initialized' + ); + } + } + + function onLogoutComplete(user, filteredIdentityRequest) { + if (isInitialized) { + try { + self.identityHandler.onLogoutComplete( + user, + filteredIdentityRequest + ); + + return ( + 'Successfully called onLogoutComplete on forwarder ' + name + ); + } catch (e) { + return { + error: + 'Error calling onLogoutComplete on forwarder ' + + name + + '; ' + + e, + }; + } + } else { + return ( + "Can't call onLogoutComplete on forwader " + + name + + ', not initialized' + ); + } + } + + function onModifyComplete(user, filteredIdentityRequest) { + if (isInitialized) { + try { + self.identityHandler.onModifyComplete( + user, + filteredIdentityRequest + ); + + return ( + 'Successfully called onModifyComplete on forwarder ' + name + ); + } catch (e) { + return { + error: + 'Error calling onModifyComplete on forwarder ' + + name + + '; ' + + e, + }; + } + } else { + return ( + "Can't call onModifyComplete on forwader " + + name + + ', not initialized' + ); + } + } + + function setOptOut(isOptingOutBoolean) { + if (isInitialized) { + try { + self.initialization.setOptOut(isOptingOutBoolean); + + return 'Successfully called setOptOut on forwarder ' + name; + } catch (e) { + return { + error: + 'Error calling setOptOut on forwarder ' + + name + + '; ' + + e, + }; + } + } else { + return ( + "Can't call setOptOut on forwader " + + name + + ', not initialized' + ); + } + } + + this.init = initForwarder; + this.process = processEvent; + this.setUserAttribute = setUserAttribute; + this.removeUserAttribute = removeUserAttribute; + this.onUserIdentified = onUserIdentified; + this.setUserIdentity = setUserIdentity; + this.onIdentifyComplete = onIdentifyComplete; + this.onLoginComplete = onLoginComplete; + this.onLogoutComplete = onLogoutComplete; + this.onModifyComplete = onModifyComplete; + this.setOptOut = setOptOut; + }; + + function getId() { + return moduleId; + } + + function isObject(val) { + return ( + val != null && typeof val === 'object' && Array.isArray(val) === false + ); + } + + function register(config) { + if (!config) { + console.log( + 'You must pass a config object to register the kit ' + name + ); + return; + } + + if (!isObject(config)) { + console.log( + "'config' must be an object. You passed in a " + typeof config + ); + return; + } + + if (isObject(config.kits)) { + config.kits[name] = { + constructor: constructor, + }; + } else { + config.kits = {}; + config.kits[name] = { + constructor: constructor, + }; + } + console.log( + 'Successfully registered ' + name + ' to your mParticle configuration' + ); + } + + if (typeof window !== 'undefined') { + if (window && window.mParticle && window.mParticle.addForwarder) { + window.mParticle.addForwarder({ + name: name, + constructor: constructor, + getId: getId, + }); + } + } + + var webKitWrapper = { + register: register, + }; + var webKitWrapper_1 = webKitWrapper.register; + + exports.default = webKitWrapper; + exports.register = webKitWrapper_1; + + return exports; + +}({})); diff --git a/kits/adobe/HeartbeatKit/dist/AdobeHBKit.esm.js b/kits/adobe/HeartbeatKit/dist/AdobeHBKit.esm.js new file mode 100644 index 000000000..e5f3c642a --- /dev/null +++ b/kits/adobe/HeartbeatKit/dist/AdobeHBKit.esm.js @@ -0,0 +1,564 @@ +function Common() { + this.playheadPosition = 0; + this.startupTime = 0; + this.droppedFrames = 0; + this.bitRate = 0; + this.fps = 0; +} + +var common = Common; + +var MediaEventType = { + Play: 23, + Pause: 24, + ContentEnd: 25, + SessionStart: 30, + SessionEnd: 31, + SeekStart: 32, + SeekEnd: 33, + BufferStart: 34, + BufferEnd: 35, + UpdatePlayheadPosition: 36, + AdClick: 37, + AdBreakStart: 38, + AdBreakEnd: 39, + AdStart: 40, + AdEnd: 41, + AdSkip: 42, + SegmentStart: 43, + SegmentEnd: 44, + SegmentSkip: 45, + UpdateQoS: 46, +}; + +var ContentType = { + Audio: 'Audio', + Video: 'Video', +}; + +var StreamType = { + LiveStream: 'LiveStream', + OnDemand: 'OnDemand', + Linear: 'Linear', + Podcast: 'Podcast', + Audiobook: 'Audiobook', +}; + +function EventHandler(common) { + this.common = common || {}; +} +EventHandler.prototype.logEvent = function(event) { + var customAttributes = {}; + if (event && event.EventAttributes) { + customAttributes = event.EventAttributes; + } + + if (event && event.PlayheadPosition) { + this.common.playheadPosition = event.PlayheadPosition / 1000; + } + + switch (event.EventCategory) { + case MediaEventType.AdBreakStart: + var adBreakObject = this.common.MediaHeartbeat.createAdBreakObject( + event.AdBreak.title, + event.AdBreak.placement || 0, // TODO: Ad Break Object doesn't support placement yet + this.common.playheadPosition + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdBreakStart, + adBreakObject, + customAttributes + ); + break; + case MediaEventType.AdBreakEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdBreakComplete, + {}, + customAttributes + ); + break; + case MediaEventType.AdStart: + var adObject = this.common.MediaHeartbeat.createAdObject( + event.AdContent.title, + event.AdContent.id, + event.AdContent.position, + event.AdContent.duration / 1000 + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdStart, + adObject, + customAttributes + ); + break; + case MediaEventType.AdEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdComplete, + {}, + customAttributes + ); + break; + case MediaEventType.AdSkip: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdSkip, + {}, + customAttributes + ); + break; + case MediaEventType.AdClick: + // This is not supported in Adobe Heartbeat + console.warn('Ad Click is not a supported Adobe Heartbeat Event'); + break; + case MediaEventType.BufferStart: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.BufferStart, + {}, + customAttributes + ); + break; + case MediaEventType.BufferEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.BufferComplete, + {}, + customAttributes + ); + break; + case MediaEventType.ContentEnd: + this.common.mediaHeartbeat.trackComplete(); + break; + case MediaEventType.SessionStart: + var streamType = getStreamType( + event.StreamType, + event.ContentType, + this.common.MediaHeartbeat.StreamType + ); + + var adobeMediaObject = this.common.MediaHeartbeat.createMediaObject( + event.ContentTitle, + event.ContentId, + event.Duration / 1000, + streamType, + event.ContentType + ); + + var combinedAttributes = getAdobeMetadataKeys( + customAttributes, + this.common.MediaHeartbeat + ); + + this.common.mediaHeartbeat.trackSessionStart( + adobeMediaObject, + combinedAttributes + ); + break; + + case MediaEventType.SessionEnd: + this.common.mediaHeartbeat.trackSessionEnd(); + break; + case MediaEventType.Play: + this.common.mediaHeartbeat.trackPlay(); + break; + case MediaEventType.Pause: + this.common.mediaHeartbeat.trackPause(); + break; + case MediaEventType.UpdatePlayheadPosition: + // This is commented out because we're updating playhead position + // for all events and Adobe does not have a relevant playhead + // update position function + break; + case MediaEventType.SeekStart: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.SeekStart, + {}, + customAttributes + ); + break; + case MediaEventType.SeekEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.SeekComplete, + {}, + customAttributes + ); + break; + case MediaEventType.SegmentStart: + var chapterObject = this.common.MediaHeartbeat.createChapterObject( + event.Segment.title, + event.Segment.index, + event.Segment.duration / 1000, + this.common.playheadPosition + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.ChapterStart, + chapterObject, + customAttributes + ); + break; + case MediaEventType.SegmentEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.ChapterComplete, + {}, + customAttributes + ); + break; + case MediaEventType.SegmentSkip: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.ChapterSkip, + {}, + customAttributes + ); + break; + case MediaEventType.UpdateQoS: + this.common.startupTime = event.QoS.startupTime / 1000; + this.common.droppedFrames = event.QoS.droppedFrames; + this.common.bitRate = event.QoS.bitRate; + this.common.fps = event.QoS.fps; + + var qosObject = this.common.MediaHeartbeat.createQoSObject( + this.common.bitRate, + this.common.startupTime, + this.common.fps, + this.common.droppedFrames + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.BitrateChange, + qosObject, + customAttributes + ); + break; + default: + console.error('Unknown Event Type', event); + return false; + } +}; + +var getAdobeMetadataKeys = function(attributes, Heartbeat) { + var AdobeMetadataLookupTable = { + // Ad Meta Data + ad_content_advertiser: Heartbeat.AdMetadataKeys.ADVERTISER, + ad_content_campaign: Heartbeat.AdMetadataKeys.CAMPAIGN_ID, + ad_content_creative: Heartbeat.AdMetadataKeys.CREATIVE_ID, + ad_content_placement: Heartbeat.AdMetadataKeys.PLACEMENT_ID, + ad_content_site_id: Heartbeat.AdMetadataKeys.SITE_ID, + ad_content_creative_url: Heartbeat.AdMetadataKeys.CREATIVE_URL, + + // Audio Meta + content_artist: Heartbeat.AudioMetadataKeys.ARTIST, + content_album: Heartbeat.AudioMetadataKeys.ALBUM, + content_label: Heartbeat.AudioMetadataKeys.LABEL, + content_author: Heartbeat.AudioMetadataKeys.AUTHOR, + content_station: Heartbeat.AudioMetadataKeys.STATION, + content_publisher: Heartbeat.AudioMetadataKeys.PUBLISHER, + + // Video Meta + content_show: Heartbeat.VideoMetadataKeys.SHOW, + stream_format: Heartbeat.VideoMetadataKeys.STREAM_FORMAT, + content_season: Heartbeat.VideoMetadataKeys.SEASON, + content_episode: Heartbeat.VideoMetadataKeys.EPISODE, + content_asset_id: Heartbeat.VideoMetadataKeys.ASSET_ID, + content_genre: Heartbeat.VideoMetadataKeys.GENRE, + content_first_air_date: Heartbeat.VideoMetadataKeys.FIRST_AIR_DATE, + content_digital_date: Heartbeat.VideoMetadataKeys.FIRST_DIGITAL_DATE, + content_rating: Heartbeat.VideoMetadataKeys.RATING, + content_originator: Heartbeat.VideoMetadataKeys.ORIGINATOR, + content_network: Heartbeat.VideoMetadataKeys.NETWORK, + content_show_type: Heartbeat.VideoMetadataKeys.SHOW_TYPE, + content_ad_load: Heartbeat.VideoMetadataKeys.AD_LOAD, + content_mvpd: Heartbeat.VideoMetadataKeys.MVPD, + content_authorized: Heartbeat.VideoMetadataKeys.AUTHORIZED, + content_daypart: Heartbeat.VideoMetadataKeys.DAY_PART, + content_feed: Heartbeat.VideoMetadataKeys.FEED, + }; + + var adobeMetadataKeys = {}; + for (var attribute in attributes) { + var key = attribute; + if (AdobeMetadataLookupTable[attribute]) { + key = AdobeMetadataLookupTable[attribute]; + } + adobeMetadataKeys[key] = attributes[attribute]; + } + + return adobeMetadataKeys; +}; + +var getStreamType = function(streamType, contentType, types) { + switch (streamType) { + case StreamType.OnDemand: + return contentType === ContentType.Video ? types.VOD : types.AOD; + case StreamType.LiveStream: + return types.LIVE; + case StreamType.Linear: + return types.LINEAR; + case StreamType.Podcast: + return types.PODCAST; + case StreamType.Audiobook: + return types.AUDIOBOOK; + default: + // If it's an unknown type, just pass it through to Adobe + return streamType; + } +}; + +var eventHandler = EventHandler; + +var Initialization = { + name: 'AdobeHeartbeat', + moduleId: 124, + initForwarder: function( + settings, + testMode, + userAttributes, + userIdentities, + processEvent, + eventQueue, + common, + initForwarderCallback + ) { + var self = this; + if (!window.mParticle.isTestEnvironment || !window.ADB) { + /* Load your Web SDK here using a variant of your snippet from your readme that your customers would generally put into their tags + Generally, our integrations create script tags and append them to the . Please follow the following format as a guide: + */ + var adobeHeartbeatSdk = document.createElement('script'); + adobeHeartbeatSdk.type = 'text/javascript'; + adobeHeartbeatSdk.async = true; + adobeHeartbeatSdk.src = + 'https://static.mparticle.com/sdk/web/adobe/MediaSDK.min.js'; + ( + document.getElementsByTagName('head')[0] || + document.getElementsByTagName('body')[0] + ).appendChild(adobeHeartbeatSdk); + adobeHeartbeatSdk.onload = function() { + if (ADB) { + self.initHeartbeat( + settings, + common, + ADB, + testMode, + initForwarderCallback + ); + if (eventQueue.length > 0) { + // Process any events that may have been queued up while forwarder was being initialized. + for (var i = 0; i < eventQueue.length; i++) { + processEvent(eventQueue[i]); + } + // now that each queued event is processed, we empty the eventQueue + eventQueue = []; + } + } + }; + } else { + // For testing, you should fill out this section in order to ensure any required initialization calls are made, + // clientSDKObject.initialize(forwarderSettings.apiKey) + self.initHeartbeat( + settings, + common, + ADB, + testMode, + initForwarderCallback + ); + } + }, + initHeartbeat: function( + settings, + common, + adobeSDK, + testMode, + initHeartbeatCallback + ) { + try { + // Init App Measurement with Visitor + var appMeasurement = new AppMeasurement(settings.reportSuiteIDs); + var visitorOptions = {}; + if (settings.audienceManagerServer) { + visitorOptions.audienceManagerServer = + settings.audienceManagerServer; + } + + appMeasurement.visitor = Visitor.getInstance( + settings.organizationID, + visitorOptions + ); + appMeasurement.trackingServer = settings.trackingServer; + appMeasurement.account = settings.reportSuiteIDs; + appMeasurement.pageName = document.title; + appMeasurement.charSet = 'UTF­8'; + + // Init Media Heartbeat + + var MediaHeartbeat = adobeSDK.va.MediaHeartbeat; + var MediaHeartbeatConfig = adobeSDK.va.MediaHeartbeatConfig; + var MediaHeartbeatDelegate = adobeSDK.va.MediaHeartbeatDelegate; + var mediaConfig = new MediaHeartbeatConfig(); + common.MediaHeartbeat = MediaHeartbeat; + + mediaConfig.trackingServer = settings.mediaTrackingServer; + mediaConfig.ssl = settings.useSSL === 'True'; + mediaConfig.playerName = 'mParticle Media SDK'; + + var mediaDelegate = new MediaHeartbeatDelegate(); + + mediaDelegate.getCurrentPlaybackTime = function() { + return common.playheadPosition; + }; + + mediaDelegate.getQoSObject = function() { + return MediaHeartbeat.createQoSObject( + common.bitRate, + common.startupTime, + common.fps, + common.droppedFrames + ); + }; + + var mediaHeartbeat = new MediaHeartbeat( + mediaDelegate, + mediaConfig, + appMeasurement + ); + common.mediaHeartbeat = mediaHeartbeat; + } catch (e) { + console.error(e); + } + + initHeartbeatCallback(); + }, +}; + +var initialization = Initialization; + +// =============== REACH OUT TO MPARTICLE IF YOU HAVE ANY QUESTIONS =============== +// +// Copyright 2018 mParticle, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + + + + +var MessageType = { + SessionStart: 1, + SessionEnd: 2, + PageView: 3, + PageEvent: 4, + CrashReport: 5, + OptOut: 6, + Commerce: 16, + Media: 20, +}; + +function constructor() { + var self = this, + isAdobeMediaSDKInitialized = false, + reportingService, + eventQueue = [], + name = 'AdobeHeartbeatKit'; + + self.moduleId = initialization.moduleId; + self.common = new common(); + + var initForwarderCallback = function() { + isAdobeMediaSDKInitialized = true; + }; + + function initForwarder( + settings, + service, + testMode, + trackerId, + userAttributes, + userIdentities + ) { + if (window.mParticle.isTestEnvironment) { + reportingService = function() {}; + } else { + reportingService = service; + } + + try { + initialization.initForwarder( + settings, + testMode, + userAttributes, + userIdentities, + processEvent, + eventQueue, + self.common, + initForwarderCallback + ); + self.eventHandler = new eventHandler(self.common); + } catch (e) { + console.error('Failed to initialize ' + name, e); + } + } + + function processEvent(event) { + var reportEvent = false; + if (isAdobeMediaSDKInitialized) { + try { + if (event.EventDataType === MessageType.Media) { + // Kits should just treat Media Events as generic Events + reportEvent = logEvent(event); + } + if (reportEvent === true && reportingService) { + reportingService(self, event); + return 'Successfully sent to ' + name; + } else { + return ( + 'Error logging event or event type not supported on forwarder ' + + name + ); + } + } catch (e) { + return 'Failed to send to ' + name + ' ' + e; + } + } else { + eventQueue.push(event); + return ( + 'Cannot send to forwarder ' + + name + + ', not initialized. Event added to queue.' + ); + } + } + + function logEvent(event) { + try { + self.eventHandler.logEvent(event); + return true; + } catch (e) { + return { + error: 'Error logging event on forwarder ' + name + '; ' + e, + }; + } + } + + this.init = initForwarder; + this.process = processEvent; +} + +if (window.mParticle && window.mParticle.registerHBK) { + window.mParticle.registerHBK({ constructor: constructor }); +} + +var src = { + AdobeHbkConstructor: constructor, +}; +var src_1 = src.AdobeHbkConstructor; + +export default src; +export { src_1 as AdobeHbkConstructor }; diff --git a/kits/adobe/HeartbeatKit/dist/AdobeHBKit.iife.js b/kits/adobe/HeartbeatKit/dist/AdobeHBKit.iife.js new file mode 100644 index 000000000..18b0838e7 --- /dev/null +++ b/kits/adobe/HeartbeatKit/dist/AdobeHBKit.iife.js @@ -0,0 +1,569 @@ +var mpAdobeHBKit = (function (exports) { + function Common() { + this.playheadPosition = 0; + this.startupTime = 0; + this.droppedFrames = 0; + this.bitRate = 0; + this.fps = 0; + } + + var common = Common; + + var MediaEventType = { + Play: 23, + Pause: 24, + ContentEnd: 25, + SessionStart: 30, + SessionEnd: 31, + SeekStart: 32, + SeekEnd: 33, + BufferStart: 34, + BufferEnd: 35, + UpdatePlayheadPosition: 36, + AdClick: 37, + AdBreakStart: 38, + AdBreakEnd: 39, + AdStart: 40, + AdEnd: 41, + AdSkip: 42, + SegmentStart: 43, + SegmentEnd: 44, + SegmentSkip: 45, + UpdateQoS: 46, + }; + + var ContentType = { + Audio: 'Audio', + Video: 'Video', + }; + + var StreamType = { + LiveStream: 'LiveStream', + OnDemand: 'OnDemand', + Linear: 'Linear', + Podcast: 'Podcast', + Audiobook: 'Audiobook', + }; + + function EventHandler(common) { + this.common = common || {}; + } + EventHandler.prototype.logEvent = function(event) { + var customAttributes = {}; + if (event && event.EventAttributes) { + customAttributes = event.EventAttributes; + } + + if (event && event.PlayheadPosition) { + this.common.playheadPosition = event.PlayheadPosition / 1000; + } + + switch (event.EventCategory) { + case MediaEventType.AdBreakStart: + var adBreakObject = this.common.MediaHeartbeat.createAdBreakObject( + event.AdBreak.title, + event.AdBreak.placement || 0, // TODO: Ad Break Object doesn't support placement yet + this.common.playheadPosition + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdBreakStart, + adBreakObject, + customAttributes + ); + break; + case MediaEventType.AdBreakEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdBreakComplete, + {}, + customAttributes + ); + break; + case MediaEventType.AdStart: + var adObject = this.common.MediaHeartbeat.createAdObject( + event.AdContent.title, + event.AdContent.id, + event.AdContent.position, + event.AdContent.duration / 1000 + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdStart, + adObject, + customAttributes + ); + break; + case MediaEventType.AdEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdComplete, + {}, + customAttributes + ); + break; + case MediaEventType.AdSkip: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdSkip, + {}, + customAttributes + ); + break; + case MediaEventType.AdClick: + // This is not supported in Adobe Heartbeat + console.warn('Ad Click is not a supported Adobe Heartbeat Event'); + break; + case MediaEventType.BufferStart: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.BufferStart, + {}, + customAttributes + ); + break; + case MediaEventType.BufferEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.BufferComplete, + {}, + customAttributes + ); + break; + case MediaEventType.ContentEnd: + this.common.mediaHeartbeat.trackComplete(); + break; + case MediaEventType.SessionStart: + var streamType = getStreamType( + event.StreamType, + event.ContentType, + this.common.MediaHeartbeat.StreamType + ); + + var adobeMediaObject = this.common.MediaHeartbeat.createMediaObject( + event.ContentTitle, + event.ContentId, + event.Duration / 1000, + streamType, + event.ContentType + ); + + var combinedAttributes = getAdobeMetadataKeys( + customAttributes, + this.common.MediaHeartbeat + ); + + this.common.mediaHeartbeat.trackSessionStart( + adobeMediaObject, + combinedAttributes + ); + break; + + case MediaEventType.SessionEnd: + this.common.mediaHeartbeat.trackSessionEnd(); + break; + case MediaEventType.Play: + this.common.mediaHeartbeat.trackPlay(); + break; + case MediaEventType.Pause: + this.common.mediaHeartbeat.trackPause(); + break; + case MediaEventType.UpdatePlayheadPosition: + // This is commented out because we're updating playhead position + // for all events and Adobe does not have a relevant playhead + // update position function + break; + case MediaEventType.SeekStart: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.SeekStart, + {}, + customAttributes + ); + break; + case MediaEventType.SeekEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.SeekComplete, + {}, + customAttributes + ); + break; + case MediaEventType.SegmentStart: + var chapterObject = this.common.MediaHeartbeat.createChapterObject( + event.Segment.title, + event.Segment.index, + event.Segment.duration / 1000, + this.common.playheadPosition + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.ChapterStart, + chapterObject, + customAttributes + ); + break; + case MediaEventType.SegmentEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.ChapterComplete, + {}, + customAttributes + ); + break; + case MediaEventType.SegmentSkip: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.ChapterSkip, + {}, + customAttributes + ); + break; + case MediaEventType.UpdateQoS: + this.common.startupTime = event.QoS.startupTime / 1000; + this.common.droppedFrames = event.QoS.droppedFrames; + this.common.bitRate = event.QoS.bitRate; + this.common.fps = event.QoS.fps; + + var qosObject = this.common.MediaHeartbeat.createQoSObject( + this.common.bitRate, + this.common.startupTime, + this.common.fps, + this.common.droppedFrames + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.BitrateChange, + qosObject, + customAttributes + ); + break; + default: + console.error('Unknown Event Type', event); + return false; + } + }; + + var getAdobeMetadataKeys = function(attributes, Heartbeat) { + var AdobeMetadataLookupTable = { + // Ad Meta Data + ad_content_advertiser: Heartbeat.AdMetadataKeys.ADVERTISER, + ad_content_campaign: Heartbeat.AdMetadataKeys.CAMPAIGN_ID, + ad_content_creative: Heartbeat.AdMetadataKeys.CREATIVE_ID, + ad_content_placement: Heartbeat.AdMetadataKeys.PLACEMENT_ID, + ad_content_site_id: Heartbeat.AdMetadataKeys.SITE_ID, + ad_content_creative_url: Heartbeat.AdMetadataKeys.CREATIVE_URL, + + // Audio Meta + content_artist: Heartbeat.AudioMetadataKeys.ARTIST, + content_album: Heartbeat.AudioMetadataKeys.ALBUM, + content_label: Heartbeat.AudioMetadataKeys.LABEL, + content_author: Heartbeat.AudioMetadataKeys.AUTHOR, + content_station: Heartbeat.AudioMetadataKeys.STATION, + content_publisher: Heartbeat.AudioMetadataKeys.PUBLISHER, + + // Video Meta + content_show: Heartbeat.VideoMetadataKeys.SHOW, + stream_format: Heartbeat.VideoMetadataKeys.STREAM_FORMAT, + content_season: Heartbeat.VideoMetadataKeys.SEASON, + content_episode: Heartbeat.VideoMetadataKeys.EPISODE, + content_asset_id: Heartbeat.VideoMetadataKeys.ASSET_ID, + content_genre: Heartbeat.VideoMetadataKeys.GENRE, + content_first_air_date: Heartbeat.VideoMetadataKeys.FIRST_AIR_DATE, + content_digital_date: Heartbeat.VideoMetadataKeys.FIRST_DIGITAL_DATE, + content_rating: Heartbeat.VideoMetadataKeys.RATING, + content_originator: Heartbeat.VideoMetadataKeys.ORIGINATOR, + content_network: Heartbeat.VideoMetadataKeys.NETWORK, + content_show_type: Heartbeat.VideoMetadataKeys.SHOW_TYPE, + content_ad_load: Heartbeat.VideoMetadataKeys.AD_LOAD, + content_mvpd: Heartbeat.VideoMetadataKeys.MVPD, + content_authorized: Heartbeat.VideoMetadataKeys.AUTHORIZED, + content_daypart: Heartbeat.VideoMetadataKeys.DAY_PART, + content_feed: Heartbeat.VideoMetadataKeys.FEED, + }; + + var adobeMetadataKeys = {}; + for (var attribute in attributes) { + var key = attribute; + if (AdobeMetadataLookupTable[attribute]) { + key = AdobeMetadataLookupTable[attribute]; + } + adobeMetadataKeys[key] = attributes[attribute]; + } + + return adobeMetadataKeys; + }; + + var getStreamType = function(streamType, contentType, types) { + switch (streamType) { + case StreamType.OnDemand: + return contentType === ContentType.Video ? types.VOD : types.AOD; + case StreamType.LiveStream: + return types.LIVE; + case StreamType.Linear: + return types.LINEAR; + case StreamType.Podcast: + return types.PODCAST; + case StreamType.Audiobook: + return types.AUDIOBOOK; + default: + // If it's an unknown type, just pass it through to Adobe + return streamType; + } + }; + + var eventHandler = EventHandler; + + var Initialization = { + name: 'AdobeHeartbeat', + moduleId: 124, + initForwarder: function( + settings, + testMode, + userAttributes, + userIdentities, + processEvent, + eventQueue, + common, + initForwarderCallback + ) { + var self = this; + if (!window.mParticle.isTestEnvironment || !window.ADB) { + /* Load your Web SDK here using a variant of your snippet from your readme that your customers would generally put into their tags + Generally, our integrations create script tags and append them to the . Please follow the following format as a guide: + */ + var adobeHeartbeatSdk = document.createElement('script'); + adobeHeartbeatSdk.type = 'text/javascript'; + adobeHeartbeatSdk.async = true; + adobeHeartbeatSdk.src = + 'https://static.mparticle.com/sdk/web/adobe/MediaSDK.min.js'; + ( + document.getElementsByTagName('head')[0] || + document.getElementsByTagName('body')[0] + ).appendChild(adobeHeartbeatSdk); + adobeHeartbeatSdk.onload = function() { + if (ADB) { + self.initHeartbeat( + settings, + common, + ADB, + testMode, + initForwarderCallback + ); + if (eventQueue.length > 0) { + // Process any events that may have been queued up while forwarder was being initialized. + for (var i = 0; i < eventQueue.length; i++) { + processEvent(eventQueue[i]); + } + // now that each queued event is processed, we empty the eventQueue + eventQueue = []; + } + } + }; + } else { + // For testing, you should fill out this section in order to ensure any required initialization calls are made, + // clientSDKObject.initialize(forwarderSettings.apiKey) + self.initHeartbeat( + settings, + common, + ADB, + testMode, + initForwarderCallback + ); + } + }, + initHeartbeat: function( + settings, + common, + adobeSDK, + testMode, + initHeartbeatCallback + ) { + try { + // Init App Measurement with Visitor + var appMeasurement = new AppMeasurement(settings.reportSuiteIDs); + var visitorOptions = {}; + if (settings.audienceManagerServer) { + visitorOptions.audienceManagerServer = + settings.audienceManagerServer; + } + + appMeasurement.visitor = Visitor.getInstance( + settings.organizationID, + visitorOptions + ); + appMeasurement.trackingServer = settings.trackingServer; + appMeasurement.account = settings.reportSuiteIDs; + appMeasurement.pageName = document.title; + appMeasurement.charSet = 'UTF­8'; + + // Init Media Heartbeat + + var MediaHeartbeat = adobeSDK.va.MediaHeartbeat; + var MediaHeartbeatConfig = adobeSDK.va.MediaHeartbeatConfig; + var MediaHeartbeatDelegate = adobeSDK.va.MediaHeartbeatDelegate; + var mediaConfig = new MediaHeartbeatConfig(); + common.MediaHeartbeat = MediaHeartbeat; + + mediaConfig.trackingServer = settings.mediaTrackingServer; + mediaConfig.ssl = settings.useSSL === 'True'; + mediaConfig.playerName = 'mParticle Media SDK'; + + var mediaDelegate = new MediaHeartbeatDelegate(); + + mediaDelegate.getCurrentPlaybackTime = function() { + return common.playheadPosition; + }; + + mediaDelegate.getQoSObject = function() { + return MediaHeartbeat.createQoSObject( + common.bitRate, + common.startupTime, + common.fps, + common.droppedFrames + ); + }; + + var mediaHeartbeat = new MediaHeartbeat( + mediaDelegate, + mediaConfig, + appMeasurement + ); + common.mediaHeartbeat = mediaHeartbeat; + } catch (e) { + console.error(e); + } + + initHeartbeatCallback(); + }, + }; + + var initialization = Initialization; + + // =============== REACH OUT TO MPARTICLE IF YOU HAVE ANY QUESTIONS =============== + // + // Copyright 2018 mParticle, Inc. + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + + + + + + var MessageType = { + SessionStart: 1, + SessionEnd: 2, + PageView: 3, + PageEvent: 4, + CrashReport: 5, + OptOut: 6, + Commerce: 16, + Media: 20, + }; + + function constructor() { + var self = this, + isAdobeMediaSDKInitialized = false, + reportingService, + eventQueue = [], + name = 'AdobeHeartbeatKit'; + + self.moduleId = initialization.moduleId; + self.common = new common(); + + var initForwarderCallback = function() { + isAdobeMediaSDKInitialized = true; + }; + + function initForwarder( + settings, + service, + testMode, + trackerId, + userAttributes, + userIdentities + ) { + if (window.mParticle.isTestEnvironment) { + reportingService = function() {}; + } else { + reportingService = service; + } + + try { + initialization.initForwarder( + settings, + testMode, + userAttributes, + userIdentities, + processEvent, + eventQueue, + self.common, + initForwarderCallback + ); + self.eventHandler = new eventHandler(self.common); + } catch (e) { + console.error('Failed to initialize ' + name, e); + } + } + + function processEvent(event) { + var reportEvent = false; + if (isAdobeMediaSDKInitialized) { + try { + if (event.EventDataType === MessageType.Media) { + // Kits should just treat Media Events as generic Events + reportEvent = logEvent(event); + } + if (reportEvent === true && reportingService) { + reportingService(self, event); + return 'Successfully sent to ' + name; + } else { + return ( + 'Error logging event or event type not supported on forwarder ' + + name + ); + } + } catch (e) { + return 'Failed to send to ' + name + ' ' + e; + } + } else { + eventQueue.push(event); + return ( + 'Cannot send to forwarder ' + + name + + ', not initialized. Event added to queue.' + ); + } + } + + function logEvent(event) { + try { + self.eventHandler.logEvent(event); + return true; + } catch (e) { + return { + error: 'Error logging event on forwarder ' + name + '; ' + e, + }; + } + } + + this.init = initForwarder; + this.process = processEvent; + } + + if (window.mParticle && window.mParticle.registerHBK) { + window.mParticle.registerHBK({ constructor: constructor }); + } + + var src = { + AdobeHbkConstructor: constructor, + }; + var src_1 = src.AdobeHbkConstructor; + + exports.AdobeHbkConstructor = src_1; + exports.default = src; + + return exports; + +}({})); diff --git a/kits/adobe/packages/AdobeClient/dist/AdobeClientSideKit.common.js b/kits/adobe/packages/AdobeClient/dist/AdobeClientSideKit.common.js new file mode 100644 index 000000000..f1ae90b1a --- /dev/null +++ b/kits/adobe/packages/AdobeClient/dist/AdobeClientSideKit.common.js @@ -0,0 +1,1323 @@ +function Common() { + this.playheadPosition = 0; + this.startupTime = 0; + this.droppedFrames = 0; + this.bitRate = 0; + this.fps = 0; +} + +var common = Common; + +var MediaEventType = { + Play: 23, + Pause: 24, + ContentEnd: 25, + SessionStart: 30, + SessionEnd: 31, + SeekStart: 32, + SeekEnd: 33, + BufferStart: 34, + BufferEnd: 35, + UpdatePlayheadPosition: 36, + AdClick: 37, + AdBreakStart: 38, + AdBreakEnd: 39, + AdStart: 40, + AdEnd: 41, + AdSkip: 42, + SegmentStart: 43, + SegmentEnd: 44, + SegmentSkip: 45, + UpdateQoS: 46, +}; + +var ContentType = { + Audio: 'Audio', + Video: 'Video', +}; + +var StreamType = { + LiveStream: 'LiveStream', + OnDemand: 'OnDemand', + Linear: 'Linear', + Podcast: 'Podcast', + Audiobook: 'Audiobook', +}; + +function EventHandler(common) { + this.common = common || {}; +} +EventHandler.prototype.logEvent = function(event) { + var customAttributes = {}; + if (event && event.EventAttributes) { + customAttributes = event.EventAttributes; + } + + if (event && event.PlayheadPosition) { + this.common.playheadPosition = event.PlayheadPosition / 1000; + } + + switch (event.EventCategory) { + case MediaEventType.AdBreakStart: + var adBreakObject = this.common.MediaHeartbeat.createAdBreakObject( + event.AdBreak.title, + event.AdBreak.placement || 0, // TODO: Ad Break Object doesn't support placement yet + this.common.playheadPosition + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdBreakStart, + adBreakObject, + customAttributes + ); + break; + case MediaEventType.AdBreakEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdBreakComplete, + {}, + customAttributes + ); + break; + case MediaEventType.AdStart: + var adObject = this.common.MediaHeartbeat.createAdObject( + event.AdContent.title, + event.AdContent.id, + event.AdContent.position, + event.AdContent.duration / 1000 + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdStart, + adObject, + customAttributes + ); + break; + case MediaEventType.AdEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdComplete, + {}, + customAttributes + ); + break; + case MediaEventType.AdSkip: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdSkip, + {}, + customAttributes + ); + break; + case MediaEventType.AdClick: + // This is not supported in Adobe Heartbeat + console.warn('Ad Click is not a supported Adobe Heartbeat Event'); + break; + case MediaEventType.BufferStart: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.BufferStart, + {}, + customAttributes + ); + break; + case MediaEventType.BufferEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.BufferComplete, + {}, + customAttributes + ); + break; + case MediaEventType.ContentEnd: + this.common.mediaHeartbeat.trackComplete(); + break; + case MediaEventType.SessionStart: + var streamType = getStreamType( + event.StreamType, + event.ContentType, + this.common.MediaHeartbeat.StreamType + ); + + var adobeMediaObject = this.common.MediaHeartbeat.createMediaObject( + event.ContentTitle, + event.ContentId, + event.Duration / 1000, + streamType, + event.ContentType + ); + + var combinedAttributes = getAdobeMetadataKeys( + customAttributes, + this.common.MediaHeartbeat + ); + + this.common.mediaHeartbeat.trackSessionStart( + adobeMediaObject, + combinedAttributes + ); + break; + + case MediaEventType.SessionEnd: + this.common.mediaHeartbeat.trackSessionEnd(); + break; + case MediaEventType.Play: + this.common.mediaHeartbeat.trackPlay(); + break; + case MediaEventType.Pause: + this.common.mediaHeartbeat.trackPause(); + break; + case MediaEventType.UpdatePlayheadPosition: + // This is commented out because we're updating playhead position + // for all events and Adobe does not have a relevant playhead + // update position function + break; + case MediaEventType.SeekStart: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.SeekStart, + {}, + customAttributes + ); + break; + case MediaEventType.SeekEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.SeekComplete, + {}, + customAttributes + ); + break; + case MediaEventType.SegmentStart: + var chapterObject = this.common.MediaHeartbeat.createChapterObject( + event.Segment.title, + event.Segment.index, + event.Segment.duration / 1000, + this.common.playheadPosition + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.ChapterStart, + chapterObject, + customAttributes + ); + break; + case MediaEventType.SegmentEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.ChapterComplete, + {}, + customAttributes + ); + break; + case MediaEventType.SegmentSkip: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.ChapterSkip, + {}, + customAttributes + ); + break; + case MediaEventType.UpdateQoS: + this.common.startupTime = event.QoS.startupTime / 1000; + this.common.droppedFrames = event.QoS.droppedFrames; + this.common.bitRate = event.QoS.bitRate; + this.common.fps = event.QoS.fps; + + var qosObject = this.common.MediaHeartbeat.createQoSObject( + this.common.bitRate, + this.common.startupTime, + this.common.fps, + this.common.droppedFrames + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.BitrateChange, + qosObject, + customAttributes + ); + break; + default: + console.error('Unknown Event Type', event); + return false; + } +}; + +var getAdobeMetadataKeys = function(attributes, Heartbeat) { + var AdobeMetadataLookupTable = { + // Ad Meta Data + ad_content_advertiser: Heartbeat.AdMetadataKeys.ADVERTISER, + ad_content_campaign: Heartbeat.AdMetadataKeys.CAMPAIGN_ID, + ad_content_creative: Heartbeat.AdMetadataKeys.CREATIVE_ID, + ad_content_placement: Heartbeat.AdMetadataKeys.PLACEMENT_ID, + ad_content_site_id: Heartbeat.AdMetadataKeys.SITE_ID, + ad_content_creative_url: Heartbeat.AdMetadataKeys.CREATIVE_URL, + + // Audio Meta + content_artist: Heartbeat.AudioMetadataKeys.ARTIST, + content_album: Heartbeat.AudioMetadataKeys.ALBUM, + content_label: Heartbeat.AudioMetadataKeys.LABEL, + content_author: Heartbeat.AudioMetadataKeys.AUTHOR, + content_station: Heartbeat.AudioMetadataKeys.STATION, + content_publisher: Heartbeat.AudioMetadataKeys.PUBLISHER, + + // Video Meta + content_show: Heartbeat.VideoMetadataKeys.SHOW, + stream_format: Heartbeat.VideoMetadataKeys.STREAM_FORMAT, + content_season: Heartbeat.VideoMetadataKeys.SEASON, + content_episode: Heartbeat.VideoMetadataKeys.EPISODE, + content_asset_id: Heartbeat.VideoMetadataKeys.ASSET_ID, + content_genre: Heartbeat.VideoMetadataKeys.GENRE, + content_first_air_date: Heartbeat.VideoMetadataKeys.FIRST_AIR_DATE, + content_digital_date: Heartbeat.VideoMetadataKeys.FIRST_DIGITAL_DATE, + content_rating: Heartbeat.VideoMetadataKeys.RATING, + content_originator: Heartbeat.VideoMetadataKeys.ORIGINATOR, + content_network: Heartbeat.VideoMetadataKeys.NETWORK, + content_show_type: Heartbeat.VideoMetadataKeys.SHOW_TYPE, + content_ad_load: Heartbeat.VideoMetadataKeys.AD_LOAD, + content_mvpd: Heartbeat.VideoMetadataKeys.MVPD, + content_authorized: Heartbeat.VideoMetadataKeys.AUTHORIZED, + content_daypart: Heartbeat.VideoMetadataKeys.DAY_PART, + content_feed: Heartbeat.VideoMetadataKeys.FEED, + }; + + var adobeMetadataKeys = {}; + for (var attribute in attributes) { + var key = attribute; + if (AdobeMetadataLookupTable[attribute]) { + key = AdobeMetadataLookupTable[attribute]; + } + adobeMetadataKeys[key] = attributes[attribute]; + } + + return adobeMetadataKeys; +}; + +var getStreamType = function(streamType, contentType, types) { + switch (streamType) { + case StreamType.OnDemand: + return contentType === ContentType.Video ? types.VOD : types.AOD; + case StreamType.LiveStream: + return types.LIVE; + case StreamType.Linear: + return types.LINEAR; + case StreamType.Podcast: + return types.PODCAST; + case StreamType.Audiobook: + return types.AUDIOBOOK; + default: + // If it's an unknown type, just pass it through to Adobe + return streamType; + } +}; + +var eventHandler = EventHandler; + +var Initialization = { + name: 'AdobeHeartbeat', + moduleId: 124, + initForwarder: function( + settings, + testMode, + userAttributes, + userIdentities, + processEvent, + eventQueue, + common, + initForwarderCallback + ) { + var self = this; + if (!window.mParticle.isTestEnvironment || !window.ADB) { + /* Load your Web SDK here using a variant of your snippet from your readme that your customers would generally put into their tags + Generally, our integrations create script tags and append them to the . Please follow the following format as a guide: + */ + var adobeHeartbeatSdk = document.createElement('script'); + adobeHeartbeatSdk.type = 'text/javascript'; + adobeHeartbeatSdk.async = true; + adobeHeartbeatSdk.src = + 'https://static.mparticle.com/sdk/web/adobe/MediaSDK.min.js'; + ( + document.getElementsByTagName('head')[0] || + document.getElementsByTagName('body')[0] + ).appendChild(adobeHeartbeatSdk); + adobeHeartbeatSdk.onload = function() { + if (ADB) { + self.initHeartbeat( + settings, + common, + ADB, + testMode, + initForwarderCallback + ); + if (eventQueue.length > 0) { + // Process any events that may have been queued up while forwarder was being initialized. + for (var i = 0; i < eventQueue.length; i++) { + processEvent(eventQueue[i]); + } + // now that each queued event is processed, we empty the eventQueue + eventQueue = []; + } + } + }; + } else { + // For testing, you should fill out this section in order to ensure any required initialization calls are made, + // clientSDKObject.initialize(forwarderSettings.apiKey) + self.initHeartbeat( + settings, + common, + ADB, + testMode, + initForwarderCallback + ); + } + }, + initHeartbeat: function( + settings, + common, + adobeSDK, + testMode, + initHeartbeatCallback + ) { + try { + // Init App Measurement with Visitor + var appMeasurement = new AppMeasurement(settings.reportSuiteIDs); + var visitorOptions = {}; + if (settings.audienceManagerServer) { + visitorOptions.audienceManagerServer = + settings.audienceManagerServer; + } + + appMeasurement.visitor = Visitor.getInstance( + settings.organizationID, + visitorOptions + ); + appMeasurement.trackingServer = settings.trackingServer; + appMeasurement.account = settings.reportSuiteIDs; + appMeasurement.pageName = document.title; + appMeasurement.charSet = 'UTF­8'; + + // Init Media Heartbeat + + var MediaHeartbeat = adobeSDK.va.MediaHeartbeat; + var MediaHeartbeatConfig = adobeSDK.va.MediaHeartbeatConfig; + var MediaHeartbeatDelegate = adobeSDK.va.MediaHeartbeatDelegate; + var mediaConfig = new MediaHeartbeatConfig(); + common.MediaHeartbeat = MediaHeartbeat; + + mediaConfig.trackingServer = settings.mediaTrackingServer; + mediaConfig.ssl = settings.useSSL === 'True'; + mediaConfig.playerName = 'mParticle Media SDK'; + + var mediaDelegate = new MediaHeartbeatDelegate(); + + mediaDelegate.getCurrentPlaybackTime = function() { + return common.playheadPosition; + }; + + mediaDelegate.getQoSObject = function() { + return MediaHeartbeat.createQoSObject( + common.bitRate, + common.startupTime, + common.fps, + common.droppedFrames + ); + }; + + var mediaHeartbeat = new MediaHeartbeat( + mediaDelegate, + mediaConfig, + appMeasurement + ); + common.mediaHeartbeat = mediaHeartbeat; + } catch (e) { + console.error(e); + } + + initHeartbeatCallback(); + }, +}; + +var initialization = Initialization; + +// =============== REACH OUT TO MPARTICLE IF YOU HAVE ANY QUESTIONS =============== +// +// Copyright 2018 mParticle, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + + + + +var MessageType = { + SessionStart: 1, + SessionEnd: 2, + PageView: 3, + PageEvent: 4, + CrashReport: 5, + OptOut: 6, + Commerce: 16, + Media: 20, +}; + +function constructor() { + var self = this, + isAdobeMediaSDKInitialized = false, + reportingService, + eventQueue = [], + name = 'AdobeHeartbeatKit'; + + self.moduleId = initialization.moduleId; + self.common = new common(); + + var initForwarderCallback = function() { + isAdobeMediaSDKInitialized = true; + }; + + function initForwarder( + settings, + service, + testMode, + trackerId, + userAttributes, + userIdentities + ) { + if (window.mParticle.isTestEnvironment) { + reportingService = function() {}; + } else { + reportingService = service; + } + + try { + initialization.initForwarder( + settings, + testMode, + userAttributes, + userIdentities, + processEvent, + eventQueue, + self.common, + initForwarderCallback + ); + self.eventHandler = new eventHandler(self.common); + } catch (e) { + console.error('Failed to initialize ' + name, e); + } + } + + function processEvent(event) { + var reportEvent = false; + if (isAdobeMediaSDKInitialized) { + try { + if (event.EventDataType === MessageType.Media) { + // Kits should just treat Media Events as generic Events + reportEvent = logEvent(event); + } + if (reportEvent === true && reportingService) { + reportingService(self, event); + return 'Successfully sent to ' + name; + } else { + return ( + 'Error logging event or event type not supported on forwarder ' + + name + ); + } + } catch (e) { + return 'Failed to send to ' + name + ' ' + e; + } + } else { + eventQueue.push(event); + return ( + 'Cannot send to forwarder ' + + name + + ', not initialized. Event added to queue.' + ); + } + } + + function logEvent(event) { + try { + self.eventHandler.logEvent(event); + return true; + } catch (e) { + return { + error: 'Error logging event on forwarder ' + name + '; ' + e, + }; + } + } + + this.init = initForwarder; + this.process = processEvent; +} + +if (window.mParticle && window.mParticle.registerHBK) { + window.mParticle.registerHBK({ constructor: constructor }); +} + +var src = { + AdobeHbkConstructor: constructor, +}; +var src_1 = src.AdobeHbkConstructor; + +/** + * @license + * Adobe Visitor API for JavaScript version: 4.4.0 + * Copyright 2019 Adobe, Inc. All Rights Reserved + * More info available at https://marketing.adobe.com/resources/help/en_US/mcvid/ + */ +var e=function(){function e(t){return (e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(){return {callbacks:{},add:function(e,t){this.callbacks[e]=this.callbacks[e]||[];var n=this.callbacks[e].push(t)-1,i=this;return function(){i.callbacks[e].splice(n,1);}},execute:function(e,t){if(this.callbacks[e]){t=void 0===t?[]:t,t=t instanceof Array?t:[t];try{for(;this.callbacks[e].length;){var n=this.callbacks[e].shift();"function"==typeof n?n.apply(null,t):n instanceof Array&&n[1].apply(n[0],t);}delete this.callbacks[e];}catch(e){}}},executeAll:function(e,t){(t||e&&!j.isObjectEmpty(e))&&Object.keys(this.callbacks).forEach(function(t){var n=void 0!==e[t]?e[t]:"";this.execute(t,n);},this);},hasCallbacks:function(){return Boolean(Object.keys(this.callbacks).length)}}}function i(e,t,n){var i=null==e?void 0:e[t];return void 0===i?n:i}function r(e){for(var t=/^\d+$/,n=0,i=e.length;nr)return 1;if(r>i)return -1}return 0}function s(e,t){if(e===t)return 0;var n=e.toString().split("."),i=t.toString().split(".");return r(n.concat(i))?(a(n,i),o(n,i)):NaN}function l(e){return e===Object(e)&&0===Object.keys(e).length}function c(e){return "function"==typeof e||e instanceof Array&&e.length}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){return !0};this.log=_e("log",e,t),this.warn=_e("warn",e,t),this.error=_e("error",e,t);}function d(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.isEnabled,n=e.cookieName,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i.cookies;return t&&n&&r?{remove:function(){r.remove(n);},get:function(){var e=r.get(n),t={};try{t=JSON.parse(e);}catch(e){t={};}return t},set:function(e,t){t=t||{},r.set(n,JSON.stringify(e),{domain:t.optInCookieDomain||"",cookieLifetime:t.optInStorageExpiry||3419e4,expires:!0});}}:{get:Le,set:Le,remove:Le}}function f(e){this.name=this.constructor.name,this.message=e,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error(e).stack;}function p(){function e(e,t){var n=Se(e);return n.length?n.every(function(e){return !!t[e]}):De(t)}function t(){M(b),O(ce.COMPLETE),_(h.status,h.permissions),m.set(h.permissions,{optInCookieDomain:l,optInStorageExpiry:c}),C.execute(xe);}function n(e){return function(n,i){if(!Ae(n))throw new Error("[OptIn] Invalid category(-ies). Please use the `OptIn.Categories` enum.");return O(ce.CHANGED),Object.assign(b,ye(Se(n),e)),i||t(),h}}var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.doesOptInApply,a=i.previousPermissions,o=i.preOptInApprovals,s=i.isOptInStorageEnabled,l=i.optInCookieDomain,c=i.optInStorageExpiry,u=i.isIabContext,f=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},p=f.cookies,g=Pe(a);Re(g,"Invalid `previousPermissions`!"),Re(o,"Invalid `preOptInApprovals`!");var m=d({isEnabled:!!s,cookieName:"adobeujs-optin"},{cookies:p}),h=this,_=le(h),C=ge(),I=Me(g),v=Me(o),S=m.get(),D={},A=function(e,t){return ke(e)||t&&ke(t)?ce.COMPLETE:ce.PENDING}(I,S),y=function(e,t,n){var i=ye(pe,!r);return r?Object.assign({},i,e,t,n):i}(v,I,S),b=be(y),O=function(e){return A=e},M=function(e){return y=e};h.deny=n(!1),h.approve=n(!0),h.denyAll=h.deny.bind(h,pe),h.approveAll=h.approve.bind(h,pe),h.isApproved=function(t){return e(t,h.permissions)},h.isPreApproved=function(t){return e(t,v)},h.fetchPermissions=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=t?h.on(ce.COMPLETE,e):Le;return !r||r&&h.isComplete||!!o?e(h.permissions):t||C.add(xe,function(){return e(h.permissions)}),n},h.complete=function(){h.status===ce.CHANGED&&t();},h.registerPlugin=function(e){if(!e||!e.name||"function"!=typeof e.onRegister)throw new Error(je);D[e.name]||(D[e.name]=e,e.onRegister.call(e,h));},h.execute=Ne(D),Object.defineProperties(h,{permissions:{get:function(){return y}},status:{get:function(){return A}},Categories:{get:function(){return ue}},doesOptInApply:{get:function(){return !!r}},isPending:{get:function(){return h.status===ce.PENDING}},isComplete:{get:function(){return h.status===ce.COMPLETE}},__plugins:{get:function(){return Object.keys(D)}},isIabContext:{get:function(){return u}}});}function g(e,t){function n(){r=null,e.call(e,new f("The call took longer than you wanted!"));}function i(){r&&(clearTimeout(r),e.apply(e,arguments));}if(void 0===t)return e;var r=setTimeout(n,t);return i}function m(){if(window.__cmp)return window.__cmp;var e=window;if(e===window.top)return void Ie.error("__cmp not found");for(var t;!t;){e=e.parent;try{e.frames.__cmpLocator&&(t=e);}catch(e){}if(e===window.top)break}if(!t)return void Ie.error("__cmp not found");var n={};return window.__cmp=function(e,i,r){var a=Math.random()+"",o={__cmpCall:{command:e,parameter:i,callId:a}};n[a]=r,t.postMessage(o,"*");},window.addEventListener("message",function(e){var t=e.data;if("string"==typeof t)try{t=JSON.parse(e.data);}catch(e){}if(t.__cmpReturn){var i=t.__cmpReturn;n[i.callId]&&(n[i.callId](i.returnValue,i.success),delete n[i.callId]);}},!1),window.__cmp}function h(){var e=this;e.name="iabPlugin",e.version="0.0.1";var t=ge(),n={allConsentData:null},i=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return n[e]=t};e.fetchConsentData=function(e){var t=e.callback,n=e.timeout,i=g(t,n);r({callback:i});},e.isApproved=function(e){var t=e.callback,i=e.category,a=e.timeout;if(n.allConsentData)return t(null,s(i,n.allConsentData.vendorConsents,n.allConsentData.purposeConsents));var o=g(function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.vendorConsents,a=n.purposeConsents;t(e,s(i,r,a));},a);r({category:i,callback:o});},e.onRegister=function(t){var n=Object.keys(de),i=function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i.purposeConsents,a=i.gdprApplies,o=i.vendorConsents;!e&&a&&o&&r&&(n.forEach(function(e){var n=s(e,o,r);t[n?"approve":"deny"](e,!0);}),t.complete());};e.fetchConsentData({callback:i});};var r=function(e){var r=e.callback;if(n.allConsentData)return r(null,n.allConsentData);t.add("FETCH_CONSENT_DATA",r);var s={};o(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.purposeConsents,o=e.gdprApplies,l=e.vendorConsents;(arguments.length>1?arguments[1]:void 0)&&(s={purposeConsents:r,gdprApplies:o,vendorConsents:l},i("allConsentData",s)),a(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(arguments.length>1?arguments[1]:void 0)&&(s.consentString=e.consentData,i("allConsentData",s)),t.execute("FETCH_CONSENT_DATA",[null,n.allConsentData]);});});},a=function(e){var t=m();t&&t("getConsentData",null,e);},o=function(e){var t=Fe(de),n=m();n&&n("getVendorConsents",t,e);},s=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=!!t[de[e]];return i&&function(){return fe[e].every(function(e){return n[e]})}()};}var _="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};Object.assign=Object.assign||function(e){for(var t,n,i=1;i4;e--){var t=document.createElement("div");if(t.innerHTML="\x3c!--[if IE "+e+"]>=0;n--)if(t=i.slice(n).join("."),Q.set("test","cookie",{domain:t}))return Q.remove("test",{domain:t}),t;return ""},Z={compare:s,isLessThan:function(e,t){return s(e,t)<0},areVersionsDifferent:function(e,t){return 0!==s(e,t)},isGreaterThan:function(e,t){return s(e,t)>0},isEqual:function(e,t){return 0===s(e,t)}},ee=!!_.postMessage,te={postMessage:function(e,t,n){var i=1;t&&(ee?n.postMessage(e,t.replace(/([^:]+:\/\/[^\/]+).*/,"$1")):t&&(n.location=t.replace(/#.*$/,"")+"#"+ +new Date+i+++"&"+e));},receiveMessage:function(e,t){var n;try{ee&&(e&&(n=function(n){if("string"==typeof t&&n.origin!==t||"[object Function]"===Object.prototype.toString.call(t)&&!1===t(n.origin))return !1;e(n);}),_.addEventListener?_[e?"addEventListener":"removeEventListener"]("message",n):_[e?"attachEvent":"detachEvent"]("onmessage",n));}catch(e){}}},ne=function(e){var t,n,i="0123456789",r="",a="",o=8,s=10,l=10;if(1==e){for(i+="ABCDEF",t=0;16>t;t++)n=Math.floor(Math.random()*o),r+=i.substring(n,n+1),n=Math.floor(Math.random()*o),a+=i.substring(n,n+1),o=16;return r+"-"+a}for(t=0;19>t;t++)n=Math.floor(Math.random()*s),r+=i.substring(n,n+1),0===t&&9==n?s=3:(1==t||2==t)&&10!=s&&2>n?s=10:2n?l=10:20&&(t=!1)),{corsType:e,corsCookiesEnabled:t}}(),getCORSInstance:function(){return "none"===this.corsMetadata.corsType?null:new _[this.corsMetadata.corsType]},fireCORS:function(t,n,i){function r(e){var n;try{if((n=JSON.parse(e))!==Object(n))return void a.handleCORSError(t,null,"Response is not JSON")}catch(e){return void a.handleCORSError(t,e,"Error parsing response as JSON")}try{for(var i=t.callback,r=_,o=0;o=a&&(e.splice(r,1),r--);return {dataPresent:o,dataValid:s}},manageSyncsSize:function(e){if(e.join("*").length>this.MAX_SYNCS_LENGTH)for(e.sort(function(e,t){return parseInt(e.split("-")[1],10)-parseInt(t.split("-")[1],10)});e.join("*").length>this.MAX_SYNCS_LENGTH;)e.shift();},fireSync:function(t,n,i,r,a,o){var s=this;if(t){if("img"===n.tag){var l,c,u,d,f=n.url,p=e.loadSSL?"https:":"http:";for(l=0,c=f.length;lre.DAYS_BETWEEN_SYNC_ID_CALLS},attachIframeASAP:function(){function e(){t.startedAttachingIframe||(n.body?t.attachIframe():setTimeout(e,30));}var t=this;e();}}},oe={audienceManagerServer:{},audienceManagerServerSecure:{},cookieDomain:{},cookieLifetime:{},cookieName:{},doesOptInApply:{},disableThirdPartyCalls:{},discardTrackingServerECID:{},idSyncAfterIDCallResult:{},idSyncAttachIframeOnWindowLoad:{},idSyncContainerID:{},idSyncDisable3rdPartySyncing:{},disableThirdPartyCookies:{},idSyncDisableSyncs:{},disableIdSyncs:{},idSyncIDCallResult:{},idSyncSSLUseAkamai:{},isCoopSafe:{},isIabContext:{},isOptInStorageEnabled:{},loadSSL:{},loadTimeout:{},marketingCloudServer:{},marketingCloudServerSecure:{},optInCookieDomain:{},optInStorageExpiry:{},overwriteCrossDomainMCIDAndAID:{},preOptInApprovals:{},previousPermissions:{},resetBeforeVersion:{},sdidParamExpiry:{},serverState:{},sessionCookieName:{},secureCookie:{},takeTimeoutMetrics:{},trackingServer:{},trackingServerSecure:{},whitelistIframeDomains:{},whitelistParentDomain:{}},se={getConfigNames:function(){return Object.keys(oe)},getConfigs:function(){return oe},normalizeConfig:function(e){return "function"!=typeof e?e:e()}},le=function(e){var t={};return e.on=function(e,n,i){if(!n||"function"!=typeof n)throw new Error("[ON] Callback should be a function.");t.hasOwnProperty(e)||(t[e]=[]);var r=t[e].push({callback:n,context:i})-1;return function(){t[e].splice(r,1),t[e].length||delete t[e];}},e.off=function(e,n){t.hasOwnProperty(e)&&(t[e]=t[e].filter(function(e){if(e.callback!==n)return e}));},e.publish=function(e){if(t.hasOwnProperty(e)){var n=[].slice.call(arguments,1);t[e].slice(0).forEach(function(e){e.callback.apply(e.context,n);});}},e.publish},ce={PENDING:"pending",CHANGED:"changed",COMPLETE:"complete"},ue={AAM:"aam",ADCLOUD:"adcloud",ANALYTICS:"aa",CAMPAIGN:"campaign",ECID:"ecid",LIVEFYRE:"livefyre",TARGET:"target",VIDEO_ANALYTICS:"videoaa"},de=(C={},t(C,ue.AAM,565),t(C,ue.ECID,565),C),fe=(I={},t(I,ue.AAM,[1,2,5]),t(I,ue.ECID,[1,2,5]),I),pe=function(e){return Object.keys(e).map(function(t){return e[t]})}(ue),ge=function(){var e={};return e.callbacks=Object.create(null),e.add=function(t,n){if(!c(n))throw new Error("[callbackRegistryFactory] Make sure callback is a function or an array of functions.");e.callbacks[t]=e.callbacks[t]||[];var i=e.callbacks[t].push(n)-1;return function(){e.callbacks[t].splice(i,1);}},e.execute=function(t,n){if(e.callbacks[t]){n=void 0===n?[]:n,n=n instanceof Array?n:[n];try{for(;e.callbacks[t].length;){var i=e.callbacks[t].shift();"function"==typeof i?i.apply(null,n):i instanceof Array&&i[1].apply(i[0],n);}delete e.callbacks[t];}catch(e){}}},e.executeAll=function(t,n){(n||t&&!l(t))&&Object.keys(e.callbacks).forEach(function(n){var i=void 0!==t[n]?t[n]:"";e.execute(n,i);},e);},e.hasCallbacks=function(){return Boolean(Object.keys(e.callbacks).length)},e},me=function(){},he=function(e){var t=window,n=t.console;return !!n&&"function"==typeof n[e]},_e=function(e,t,n){return n()?function(){if(he(e)){for(var n=arguments.length,i=new Array(n),r=0;r-1})},ye=function(e,t){return e.reduce(function(e,n){return e[n]=t,e},{})},be=function(e){return JSON.parse(JSON.stringify(e))},Oe=function(e){return "[object Array]"===Object.prototype.toString.call(e)&&!e.length},Me=function(e){if(Te(e))return e;try{return JSON.parse(e)}catch(e){return {}}},ke=function(e){return void 0===e||(Te(e)?Ae(Object.keys(e)):Ee(e))},Ee=function(e){try{var t=JSON.parse(e);return !!e&&ve(e,"string")&&Ae(Object.keys(t))}catch(e){return !1}},Te=function(e){return null!==e&&ve(e,"object")&&!1===Array.isArray(e)},Le=function(){},Pe=function(e){return ve(e,"function")?e():e},Re=function(e,t){ke(e)||Ie.error("".concat(t));},we=function(e){return Object.keys(e).map(function(t){return e[t]})},Fe=function(e){return we(e).filter(function(e,t,n){return n.indexOf(e)===t})},Ne=function(e){return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.command,i=t.params,r=void 0===i?{}:i,a=t.callback,o=void 0===a?Le:a;if(!n||-1===n.indexOf("."))throw new Error("[OptIn.execute] Please provide a valid command.");try{var s=n.split("."),l=e[s[0]],c=s[1];if(!l||"function"!=typeof l[c])throw new Error("Make sure the plugin and API name exist.");var u=Object.assign(r,{callback:o});l[c].call(l,u);}catch(e){Ie.error("[execute] Something went wrong: "+e.message);}}};f.prototype=Object.create(Error.prototype),f.prototype.constructor=f;var xe="fetchPermissions",je="[OptIn#registerPlugin] Plugin is invalid.";p.Categories=ue,p.TimeoutError=f;var Ve=Object.freeze({OptIn:p,IabPlugin:h}),He=function(e,t){e.publishDestinations=function(n){var i=arguments[1],r=arguments[2];try{r="function"==typeof r?r:n.callback;}catch(e){r=function(){};}var a=t;if(!a.readyToAttachIframePreliminary())return void r({error:"The destination publishing iframe is disabled in the Visitor library."});if("string"==typeof n){if(!n.length)return void r({error:"subdomain is not a populated string."});if(!(i instanceof Array&&i.length))return void r({error:"messages is not a populated array."});var o=!1;if(i.forEach(function(e){ +"string"==typeof e&&e.length&&(a.addMessage(e),o=!0);}),!o)return void r({error:"None of the messages are populated strings."})}else{if(!j.isObject(n))return void r({error:"Invalid parameters passed."});var s=n;if("string"!=typeof(n=s.subdomain)||!n.length)return void r({error:"config.subdomain is not a populated string."});var l=s.urlDestinations;if(!(l instanceof Array&&l.length))return void r({error:"config.urlDestinations is not a populated array."});var c=[];l.forEach(function(e){j.isObject(e)&&(e.hideReferrer?e.message&&a.addMessage(e.message):c.push(e));});!function e(){c.length&&setTimeout(function(){var t=new Image,n=c.shift();t.src=n.url,a.onPageDestinationsFired.push(n),e();},100);}();}a.iframe?(r({message:"The destination publishing iframe is already attached and loaded."}),a.requestToProcess()):!e.subdomain&&e._getField("MCMID")?(a.subdomain=n,a.doAttachIframe=!0,a.url=a.getUrl(),a.readyToAttachIframe()?(a.iframeLoadedCallbacks.push(function(e){r({message:"Attempted to attach and load the destination publishing iframe through this API call. Result: "+(e.message||"no result")});}),a.attachIframe()):r({error:"Encountered a problem in attempting to attach and load the destination publishing iframe through this API call."})):a.iframeLoadedCallbacks.push(function(e){r({message:"Attempted to attach and load the destination publishing iframe through normal Visitor API processing. Result: "+(e.message||"no result")});});};},Ue=function e(t){function n(e,t){return e>>>t|e<<32-t}for(var i,r,a=Math.pow,o=a(2,32),s="",l=[],c=8*t.length,u=e.h=e.h||[],d=e.k=e.k||[],f=d.length,p={},g=2;f<64;g++)if(!p[g]){for(i=0;i<313;i+=g)p[i]=g;u[f]=a(g,.5)*o|0,d[f++]=a(g,1/3)*o|0;}for(t+="€";t.length%64-56;)t+="\0";for(i=0;i>8)return;l[i>>2]|=r<<(3-i)%4*8;}for(l[l.length]=c/o|0,l[l.length]=c,r=0;r>>3)+m[i-7]+(n(C,17)^n(C,19)^C>>>10)|0);u=[S+((n(I,2)^n(I,13)^n(I,22))+(I&u[1]^I&u[2]^u[1]&u[2]))|0].concat(u),u[4]=u[4]+S|0;}for(i=0;i<8;i++)u[i]=u[i]+h[i]|0;}for(i=0;i<8;i++)for(r=3;r+1;r--){var D=u[i]>>8*r&255;s+=(D<16?0:"")+D.toString(16);}return s},Be=function(e,t){return "SHA-256"!==t&&"SHA256"!==t&&"sha256"!==t&&"sha-256"!==t||(e=Ue(e)),e},Ge=function(e){return String(e).trim().toLowerCase()},Ye=Ve.OptIn;j.defineGlobalNamespace(),window.adobe.OptInCategories=Ye.Categories;var qe=function(t,n,i){function r(e){var t=e;return function(e){var n=e||v.location.href;try{var i=g._extractParamFromUri(n,t);if(i)return w.parsePipeDelimetedKeyValues(i)}catch(e){}}}function a(e){function t(e,t,n){e&&e.match(re.VALID_VISITOR_ID_REGEX)&&(n===A&&(I=!0),t(e));}t(e[A],g.setMarketingCloudVisitorID,A),g._setFieldExpire(k,-1),t(e[O],g.setAnalyticsVisitorID);}function o(e){e=e||{},g._supplementalDataIDCurrent=e.supplementalDataIDCurrent||"",g._supplementalDataIDCurrentConsumed=e.supplementalDataIDCurrentConsumed||{},g._supplementalDataIDLast=e.supplementalDataIDLast||"",g._supplementalDataIDLastConsumed=e.supplementalDataIDLastConsumed||{};}function s(e){function t(e,t,n){return n=n?n+="|":n,n+=e+"="+encodeURIComponent(t)}function n(e,n){var i=n[0],r=n[1];return null!=r&&r!==T&&(e=t(i,r,e)),e}var i=e.reduce(n,"");return function(e){var t=w.getTimestampInSeconds();return e=e?e+="|":e,e+="TS="+t}(i)}function l(e){var t=e.minutesToLive,n="";return (g.idSyncDisableSyncs||g.disableIdSyncs)&&(n=n||"Error: id syncs have been disabled"),"string"==typeof e.dpid&&e.dpid.length||(n=n||"Error: config.dpid is empty"),"string"==typeof e.url&&e.url.length||(n=n||"Error: config.url is empty"),void 0===t?t=20160:(t=parseInt(t,10),(isNaN(t)||t<=0)&&(n=n||"Error: config.minutesToLive needs to be a positive number")),{error:n,ttl:t}}function c(){return !!g.configs.doesOptInApply&&!(m.optIn.isComplete&&u())}function u(){return g.configs.isIabContext?m.optIn.isApproved(m.optIn.Categories.ECID)&&C:m.optIn.isApproved(m.optIn.Categories.ECID)}function d(e,t){if(C=!0,e)throw new Error("[IAB plugin] : "+e);t.gdprApplies&&(h=t.consentString),g.init(),p();}function f(){m.optIn.isApproved(m.optIn.Categories.ECID)&&(g.configs.isIabContext?m.optIn.execute({command:"iabPlugin.fetchConsentData",callback:d}):(g.init(),p()));}function p(){m.optIn.off("complete",f);}if(!i||i.split("").reverse().join("")!==t)throw new Error("Please use `Visitor.getInstance` to instantiate Visitor.");var g=this,m=window.adobe,h="",C=!1,I=!1;g.version="4.4.0";var v=_,S=v.Visitor;S.version=g.version,S.AuthState=E.AUTH_STATE,S.OptOut=E.OPT_OUT,v.s_c_in||(v.s_c_il=[],v.s_c_in=0),g._c="Visitor",g._il=v.s_c_il,g._in=v.s_c_in,g._il[g._in]=g,v.s_c_in++,g._instanceType="regular",g._log={requests:[]},g.marketingCloudOrgID=t,g.cookieName="AMCV_"+t,g.sessionCookieName="AMCVS_"+t,g.cookieDomain=$(),g.loadSSL=v.location.protocol.toLowerCase().indexOf("https")>=0,g.loadTimeout=3e4,g.CORSErrors=[],g.marketingCloudServer=g.audienceManagerServer="dpm.demdex.net",g.sdidParamExpiry=30;var D=null,A="MCMID",y="MCIDTS",b="A",O="MCAID",M="AAM",k="MCAAMB",T="NONE",L=function(e){return !Object.prototype[e]},P=ie(g);g.FIELDS=E.FIELDS,g.cookieRead=function(e){return Q.get(e)},g.cookieWrite=function(e,t,n){var i=g.cookieLifetime?(""+g.cookieLifetime).toUpperCase():"",r=!1;return g.configs&&g.configs.secureCookie&&"https:"===location.protocol&&(r=!0),Q.set(e,""+t,{expires:n,domain:g.cookieDomain,cookieLifetime:i,secure:r})},g.resetState=function(e){e?g._mergeServerState(e):o();},g._isAllowedDone=!1,g._isAllowedFlag=!1,g.isAllowed=function(){return g._isAllowedDone||(g._isAllowedDone=!0,(g.cookieRead(g.cookieName)||g.cookieWrite(g.cookieName,"T",1))&&(g._isAllowedFlag=!0)),"T"===g.cookieRead(g.cookieName)&&g._helpers.removeCookie(g.cookieName),g._isAllowedFlag},g.setMarketingCloudVisitorID=function(e){g._setMarketingCloudFields(e);},g._use1stPartyMarketingCloudServer=!1,g.getMarketingCloudVisitorID=function(e,t){g.marketingCloudServer&&g.marketingCloudServer.indexOf(".demdex.net")<0&&(g._use1stPartyMarketingCloudServer=!0);var n=g._getAudienceManagerURLData("_setMarketingCloudFields"),i=n.url;return g._getRemoteField(A,i,e,t,n)},g.getVisitorValues=function(e,t){var n={MCMID:{fn:g.getMarketingCloudVisitorID,args:[!0],context:g},MCOPTOUT:{fn:g.isOptedOut,args:[void 0,!0],context:g},MCAID:{fn:g.getAnalyticsVisitorID,args:[!0],context:g},MCAAMLH:{fn:g.getAudienceManagerLocationHint,args:[!0],context:g},MCAAMB:{fn:g.getAudienceManagerBlob,args:[!0],context:g}},i=t&&t.length?j.pluck(n,t):n;z(i,e);},g._currentCustomerIDs={},g._customerIDsHashChanged=!1,g._newCustomerIDsHash="",g.setCustomerIDs=function(t,n){function i(){g._customerIDsHashChanged=!1;}if(!g.isOptedOut()&&t){if(!j.isObject(t)||j.isObjectEmpty(t))return !1;g._readVisitor();var r,a,o;for(r in t)if(L(r)&&(a=t[r],n=a.hasOwnProperty("hashType")?a.hashType:n,a))if("object"===e(a)){var s={};if(a.id){if(n){if(!(o=Be(Ge(a.id),n)))return;a.id=o,s.hashType=n;}s.id=a.id;}void 0!=a.authState&&(s.authState=a.authState),g._currentCustomerIDs[r]=s;}else if(n){if(!(o=Be(Ge(a),n)))return;g._currentCustomerIDs[r]={id:o,hashType:n};}else g._currentCustomerIDs[r]={id:a};var l=g.getCustomerIDs(),c=g._getField("MCCIDH"),u="";c||(c=0);for(r in l)L(r)&&(a=l[r],u+=(u?"|":"")+r+"|"+(a.id?a.id:"")+(a.authState?a.authState:""));g._newCustomerIDsHash=String(g._hash(u)),g._newCustomerIDsHash!==c&&(g._customerIDsHashChanged=!0,g._mapCustomerIDs(i));}},g.getCustomerIDs=function(){g._readVisitor();var e,t,n={};for(e in g._currentCustomerIDs)L(e)&&(t=g._currentCustomerIDs[e],n[e]||(n[e]={}),t.id&&(n[e].id=t.id),void 0!=t.authState?n[e].authState=t.authState:n[e].authState=S.AuthState.UNKNOWN,t.hashType&&(n[e].hashType=t.hashType));return n},g.setAnalyticsVisitorID=function(e){g._setAnalyticsFields(e);},g.getAnalyticsVisitorID=function(e,t,n){if(!w.isTrackingServerPopulated()&&!n)return g._callCallback(e,[""]),"";var i="";if(n||(i=g.getMarketingCloudVisitorID(function(t){g.getAnalyticsVisitorID(e,!0);})),i||n){var r=n?g.marketingCloudServer:g.trackingServer,a="";g.loadSSL&&(n?g.marketingCloudServerSecure&&(r=g.marketingCloudServerSecure):g.trackingServerSecure&&(r=g.trackingServerSecure));var o={};if(r){var s="http"+(g.loadSSL?"s":"")+"://"+r+"/id",l="d_visid_ver="+g.version+"&mcorgid="+encodeURIComponent(g.marketingCloudOrgID)+(i?"&mid="+encodeURIComponent(i):"")+(g.idSyncDisable3rdPartySyncing||g.disableThirdPartyCookies?"&d_coppa=true":""),c=["s_c_il",g._in,"_set"+(n?"MarketingCloud":"Analytics")+"Fields"];a=s+"?"+l+"&callback=s_c_il%5B"+g._in+"%5D._set"+(n?"MarketingCloud":"Analytics")+"Fields",o.corsUrl=s+"?"+l,o.callback=c;}return o.url=a,g._getRemoteField(n?A:O,a,e,t,o)}return ""},g.getAudienceManagerLocationHint=function(e,t){if(g.getMarketingCloudVisitorID(function(t){g.getAudienceManagerLocationHint(e,!0);})){var n=g._getField(O);if(!n&&w.isTrackingServerPopulated()&&(n=g.getAnalyticsVisitorID(function(t){g.getAudienceManagerLocationHint(e,!0);})),n||!w.isTrackingServerPopulated()){var i=g._getAudienceManagerURLData(),r=i.url;return g._getRemoteField("MCAAMLH",r,e,t,i)}}return ""},g.getLocationHint=g.getAudienceManagerLocationHint,g.getAudienceManagerBlob=function(e,t){if(g.getMarketingCloudVisitorID(function(t){g.getAudienceManagerBlob(e,!0);})){var n=g._getField(O);if(!n&&w.isTrackingServerPopulated()&&(n=g.getAnalyticsVisitorID(function(t){g.getAudienceManagerBlob(e,!0);})),n||!w.isTrackingServerPopulated()){var i=g._getAudienceManagerURLData(),r=i.url;return g._customerIDsHashChanged&&g._setFieldExpire(k,-1),g._getRemoteField(k,r,e,t,i)}}return ""},g._supplementalDataIDCurrent="",g._supplementalDataIDCurrentConsumed={},g._supplementalDataIDLast="",g._supplementalDataIDLastConsumed={},g.getSupplementalDataID=function(e,t){g._supplementalDataIDCurrent||t||(g._supplementalDataIDCurrent=g._generateID(1));var n=g._supplementalDataIDCurrent;return g._supplementalDataIDLast&&!g._supplementalDataIDLastConsumed[e]?(n=g._supplementalDataIDLast,g._supplementalDataIDLastConsumed[e]=!0):n&&(g._supplementalDataIDCurrentConsumed[e]&&(g._supplementalDataIDLast=g._supplementalDataIDCurrent,g._supplementalDataIDLastConsumed=g._supplementalDataIDCurrentConsumed,g._supplementalDataIDCurrent=n=t?"":g._generateID(1),g._supplementalDataIDCurrentConsumed={}),n&&(g._supplementalDataIDCurrentConsumed[e]=!0)),n};var R=!1;g._liberatedOptOut=null,g.getOptOut=function(e,t){var n=g._getAudienceManagerURLData("_setMarketingCloudFields"),i=n.url;if(u())return g._getRemoteField("MCOPTOUT",i,e,t,n);if(g._registerCallback("liberatedOptOut",e),null!==g._liberatedOptOut)return g._callAllCallbacks("liberatedOptOut",[g._liberatedOptOut]),R=!1,g._liberatedOptOut;if(R)return null;R=!0;var r="liberatedGetOptOut";return n.corsUrl=n.corsUrl.replace(/dpm\.demdex\.net\/id\?/,"dpm.demdex.net/optOutStatus?"),n.callback=[r],_[r]=function(e){if(e===Object(e)){var t,n,i=j.parseOptOut(e,t,T);t=i.optOut,n=1e3*i.d_ottl,g._liberatedOptOut=t,setTimeout(function(){g._liberatedOptOut=null;},n);}g._callAllCallbacks("liberatedOptOut",[t]),R=!1;},P.fireCORS(n),null},g.isOptedOut=function(e,t,n){t||(t=S.OptOut.GLOBAL);var i=g.getOptOut(function(n){var i=n===S.OptOut.GLOBAL||n.indexOf(t)>=0;g._callCallback(e,[i]);},n);return i?i===S.OptOut.GLOBAL||i.indexOf(t)>=0:null},g._fields=null,g._fieldsExpired=null,g._hash=function(e){var t,n,i=0;if(e)for(t=0;t0;)g._callCallback(n.shift(),t);}},g._addQuerystringParam=function(e,t,n,i){var r=encodeURIComponent(t)+"="+encodeURIComponent(n),a=w.parseHash(e),o=w.hashlessUrl(e);if(-1===o.indexOf("?"))return o+"?"+r+a;var s=o.split("?"),l=s[0]+"?",c=s[1];return l+w.addQueryParamAtLocation(c,r,i)+a},g._extractParamFromUri=function(e,t){var n=new RegExp("[\\?&#]"+t+"=([^&#]*)"),i=n.exec(e);if(i&&i.length)return decodeURIComponent(i[1])},g._parseAdobeMcFromUrl=r(re.ADOBE_MC),g._parseAdobeMcSdidFromUrl=r(re.ADOBE_MC_SDID),g._attemptToPopulateSdidFromUrl=function(e){var n=g._parseAdobeMcSdidFromUrl(e),i=1e9;n&&n.TS&&(i=w.getTimestampInSeconds()-n.TS),n&&n.SDID&&n.MCORGID===t&&ire.ADOBE_MC_TTL_IN_MIN||e.MCORGID!==t)return;a(e);}},g._mergeServerState=function(e){if(e)try{if(e=function(e){return w.isObject(e)?e:JSON.parse(e)}(e),e[g.marketingCloudOrgID]){var t=e[g.marketingCloudOrgID];!function(e){w.isObject(e)&&g.setCustomerIDs(e);}(t.customerIDs),o(t.sdid);}}catch(e){throw new Error("`serverState` has an invalid format.")}},g._timeout=null,g._loadData=function(e,t,n,i){t=g._addQuerystringParam(t,"d_fieldgroup",e,1),i.url=g._addQuerystringParam(i.url,"d_fieldgroup",e,1),i.corsUrl=g._addQuerystringParam(i.corsUrl,"d_fieldgroup",e,1),N.fieldGroupObj[e]=!0,i===Object(i)&&i.corsUrl&&"XMLHttpRequest"===P.corsMetadata.corsType&&P.fireCORS(i,n,e);},g._clearTimeout=function(e){null!=g._timeout&&g._timeout[e]&&(clearTimeout(g._timeout[e]),g._timeout[e]=0);},g._settingsDigest=0,g._getSettingsDigest=function(){if(!g._settingsDigest){var e=g.version;g.audienceManagerServer&&(e+="|"+g.audienceManagerServer),g.audienceManagerServerSecure&&(e+="|"+g.audienceManagerServerSecure),g._settingsDigest=g._hash(e);}return g._settingsDigest},g._readVisitorDone=!1,g._readVisitor=function(){if(!g._readVisitorDone){g._readVisitorDone=!0;var e,t,n,i,r,a,o=g._getSettingsDigest(),s=!1,l=g.cookieRead(g.cookieName),c=new Date;if(l||I||g.discardTrackingServerECID||(l=g.cookieRead(re.FIRST_PARTY_SERVER_COOKIE)),null==g._fields&&(g._fields={}),l&&"T"!==l)for(l=l.split("|"),l[0].match(/^[\-0-9]+$/)&&(parseInt(l[0],10)!==o&&(s=!0),l.shift()),l.length%2==1&&l.pop(),e=0;e1?(r=parseInt(t[1],10),a=t[1].indexOf("s")>0):(r=0,a=!1),s&&("MCCIDH"===n&&(i=""),r>0&&(r=c.getTime()/1e3-60)),n&&i&&(g._setField(n,i,1),r>0&&(g._fields["expire"+n]=r+(a?"s":""),(c.getTime()>=1e3*r||a&&!g.cookieRead(g.sessionCookieName))&&(g._fieldsExpired||(g._fieldsExpired={}),g._fieldsExpired[n]=!0)));!g._getField(O)&&w.isTrackingServerPopulated()&&(l=g.cookieRead("s_vi"))&&(l=l.split("|"),l.length>1&&l[0].indexOf("v1")>=0&&(i=l[1],e=i.indexOf("["),e>=0&&(i=i.substring(0,e)),i&&i.match(re.VALID_VISITOR_ID_REGEX)&&g._setField(O,i)));}},g._appendVersionTo=function(e){var t="vVersion|"+g.version,n=e?g._getCookieVersion(e):null;return n?Z.areVersionsDifferent(n,g.version)&&(e=e.replace(re.VERSION_REGEX,t)):e+=(e?"|":"")+t,e},g._writeVisitor=function(){var e,t,n=g._getSettingsDigest();for(e in g._fields)L(e)&&g._fields[e]&&"expire"!==e.substring(0,6)&&(t=g._fields[e],n+=(n?"|":"")+e+(g._fields["expire"+e]?"-"+g._fields["expire"+e]:"")+"|"+t);n=g._appendVersionTo(n),g.cookieWrite(g.cookieName,n,1);},g._getField=function(e,t){return null==g._fields||!t&&g._fieldsExpired&&g._fieldsExpired[e]?null:g._fields[e]},g._setField=function(e,t,n){null==g._fields&&(g._fields={}),g._fields[e]=t,n||g._writeVisitor();},g._getFieldList=function(e,t){var n=g._getField(e,t);return n?n.split("*"):null},g._setFieldList=function(e,t,n){g._setField(e,t?t.join("*"):"",n);},g._getFieldMap=function(e,t){var n=g._getFieldList(e,t);if(n){var i,r={};for(i=0;i0?e.substr(t):""},hashlessUrl:function(e){var t=e.indexOf("#");return t>0?e.substr(0,t):e},addQueryParamAtLocation:function(e,t,n){var i=e.split("&");return n=null!=n?n:i.length,i.splice(n,0,t),i.join("&")},isFirstPartyAnalyticsVisitorIDCall:function(e,t,n){if(e!==O)return !1;var i;return t||(t=g.trackingServer),n||(n=g.trackingServerSecure),!("string"!=typeof(i=g.loadSSL?n:t)||!i.length)&&(i.indexOf("2o7.net")<0&&i.indexOf("omtrdc.net")<0)},isObject:function(e){return Boolean(e&&e===Object(e))},removeCookie:function(e){Q.remove(e,{domain:g.cookieDomain});},isTrackingServerPopulated:function(){return !!g.trackingServer||!!g.trackingServerSecure},getTimestampInSeconds:function(){return Math.round((new Date).getTime()/1e3)},parsePipeDelimetedKeyValues:function(e){return e.split("|").reduce(function(e,t){var n=t.split("=");return e[n[0]]=decodeURIComponent(n[1]),e},{})},generateRandomString:function(e){e=e||5;for(var t="",n="abcdefghijklmnopqrstuvwxyz0123456789";e--;)t+=n[Math.floor(Math.random()*n.length)];return t},normalizeBoolean:function(e){return "true"===e||"false"!==e&&e},parseBoolean:function(e){return "true"===e||"false"!==e&&null},replaceMethodsWithFunction:function(e,t){for(var n in e)e.hasOwnProperty(n)&&"function"==typeof e[n]&&(e[n]=t);return e}};g._helpers=w;var F=ae(g,S);g._destinationPublishing=F,g.timeoutMetricsLog=[];var N={isClientSideMarketingCloudVisitorID:null,MCIDCallTimedOut:null,AnalyticsIDCallTimedOut:null,AAMIDCallTimedOut:null,fieldGroupObj:{},setState:function(e,t){switch(e){case"MC":!1===t?!0!==this.MCIDCallTimedOut&&(this.MCIDCallTimedOut=!1):this.MCIDCallTimedOut=t;break;case b:!1===t?!0!==this.AnalyticsIDCallTimedOut&&(this.AnalyticsIDCallTimedOut=!1):this.AnalyticsIDCallTimedOut=t;break;case M:!1===t?!0!==this.AAMIDCallTimedOut&&(this.AAMIDCallTimedOut=!1):this.AAMIDCallTimedOut=t;}}};g.isClientSideMarketingCloudVisitorID=function(){return N.isClientSideMarketingCloudVisitorID},g.MCIDCallTimedOut=function(){return N.MCIDCallTimedOut},g.AnalyticsIDCallTimedOut=function(){return N.AnalyticsIDCallTimedOut},g.AAMIDCallTimedOut=function(){return N.AAMIDCallTimedOut},g.idSyncGetOnPageSyncInfo=function(){return g._readVisitor(),g._getField("MCSYNCSOP")},g.idSyncByURL=function(e){if(!g.isOptedOut()){var t=l(e||{});if(t.error)return t.error;var n,i,r=e.url,a=encodeURIComponent,o=F;return r=r.replace(/^https:/,"").replace(/^http:/,""),n=j.encodeAndBuildRequest(["",e.dpid,e.dpuuid||""],","),i=["ibs",a(e.dpid),"img",a(r),t.ttl,"",n],o.addMessage(i.join("|")),o.requestToProcess(),"Successfully queued"}},g.idSyncByDataSource=function(e){if(!g.isOptedOut())return e===Object(e)&&"string"==typeof e.dpuuid&&e.dpuuid.length?(e.url="//dpm.demdex.net/ibs:dpid="+e.dpid+"&dpuuid="+e.dpuuid,g.idSyncByURL(e)):"Error: config or config.dpuuid is empty"},He(g,F),g._getCookieVersion=function(e){e=e||g.cookieRead(g.cookieName);var t=re.VERSION_REGEX.exec(e);return t&&t.length>1?t[1]:null},g._resetAmcvCookie=function(e){var t=g._getCookieVersion();t&&!Z.isLessThan(t,e)||w.removeCookie(g.cookieName);},g.setAsCoopSafe=function(){D=!0;},g.setAsCoopUnsafe=function(){D=!1;},function(){if(g.configs=Object.create(null),w.isObject(n))for(var e in n)L(e)&&(g[e]=n[e],g.configs[e]=n[e]);}(),function(){[["getMarketingCloudVisitorID"],["setCustomerIDs",void 0],["getAnalyticsVisitorID"],["getAudienceManagerLocationHint"],["getLocationHint"],["getAudienceManagerBlob"]].forEach(function(e){var t=e[0],n=2===e.length?e[1]:"",i=g[t];g[t]=function(e){return u()&&g.isAllowed()?i.apply(g,arguments):("function"==typeof e&&g._callCallback(e,[n]),n)};});}(),g.init=function(){if(c())return m.optIn.fetchPermissions(f,!0);!function(){if(w.isObject(n)){g.idSyncContainerID=g.idSyncContainerID||0,D="boolean"==typeof g.isCoopSafe?g.isCoopSafe:w.parseBoolean(g.isCoopSafe),g.resetBeforeVersion&&g._resetAmcvCookie(g.resetBeforeVersion),g._attemptToPopulateIdsFromUrl(),g._attemptToPopulateSdidFromUrl(),g._readVisitor();var e=g._getField(y),t=Math.ceil((new Date).getTime()/re.MILLIS_PER_DAY);g.idSyncDisableSyncs||g.disableIdSyncs||!F.canMakeSyncIDCall(e,t)||(g._setFieldExpire(k,-1),g._setField(y,t)),g.getMarketingCloudVisitorID(),g.getAudienceManagerLocationHint(),g.getAudienceManagerBlob(),g._mergeServerState(g.serverState);}else g._attemptToPopulateIdsFromUrl(),g._attemptToPopulateSdidFromUrl();}(),function(){if(!g.idSyncDisableSyncs&&!g.disableIdSyncs){F.checkDPIframeSrc();var e=function(){var e=F;e.readyToAttachIframe()&&e.attachIframe();};v.addEventListener("load",function(){S.windowLoaded=!0,e();});try{te.receiveMessage(function(e){F.receiveMessage(e.data);},F.iframeHost);}catch(e){}}}(),function(){g.whitelistIframeDomains&&re.POST_MESSAGE_ENABLED&&(g.whitelistIframeDomains=g.whitelistIframeDomains instanceof Array?g.whitelistIframeDomains:[g.whitelistIframeDomains],g.whitelistIframeDomains.forEach(function(e){var n=new B(t,e),i=K(g,n);te.receiveMessage(i,e);}));}();};};qe.config=se,_.Visitor=qe;var Xe=qe,We=function(e){if(j.isObject(e))return Object.keys(e).filter(function(t){return ""!==e[t]}).reduce(function(t,n){var i="doesOptInApply"!==n?e[n]:se.normalizeConfig(e[n]),r=j.normalizeBoolean(i);return t[n]=r,t},Object.create(null))},Je=Ve.OptIn,Ke=Ve.IabPlugin;return Xe.getInstance=function(e,t){if(!e)throw new Error("Visitor requires Adobe Marketing Cloud Org ID.");e.indexOf("@")<0&&(e+="@AdobeOrg");var n=function(){var t=_.s_c_il;if(t)for(var n=0;na.indexOf(b)?a:a.split(b).join(d)};a.escape=function(c){var b,d;if(!c)return c;c=encodeURIComponent(c);for(b=0;7>b;b++)d="+~!*()'".substring(b,b+1),0<=c.indexOf(d)&&(c=a.replace(c,d,"%"+d.charCodeAt(0).toString(16).toUpperCase()));return c};a.unescape=function(c){if(!c)return c;c=0<=c.indexOf("+")?a.replace(c,"+"," "):c;try{return decodeURIComponent(c)}catch(b){}return unescape(c)};a.Mb=function(){var c=h.location.hostname,b=a.fpCookieDomainPeriods,d;b||(b=a.cookieDomainPeriods); +if(c&&!a.Ja&&!/^[0-9.]+$/.test(c)&&(b=b?parseInt(b):2,b=2d?"":a.unescape(b.substring(d+2+c.length,0>f?b.length:f));return "[[B]]"!=c?c:""};a.c_w=a.cookieWrite=function(c,b,d){var f=a.Mb(),e=a.cookieLifetime,g;b=""+b;e=e?(""+e).toUpperCase():"";d&&"SESSION"!=e&&"NONE"!= +e&&((g=""!=b?parseInt(e?e:0):-60)?(d=new Date,d.setTime(d.getTime()+1E3*g)):1===d&&(d=new Date,g=d.getYear(),d.setYear(g+2+(1900>g?1900:0))));return c&&"NONE"!=e?(a.d.cookie=a.escape(c)+"="+a.escape(""!=b?b:"[[B]]")+"; path=/;"+(d&&"SESSION"!=e?" expires="+d.toUTCString()+";":"")+(f?" domain="+f+";":"")+(a.writeSecureCookies?" secure;":""),a.cookieRead(c)==b):0};a.Jb=function(){var c=a.Util.getIeVersion();"number"===typeof c&&10>c&&(a.unsupportedBrowser=!0,a.wb(a,function(){}));};a.xa=function(){var a= +navigator.userAgent;return "Microsoft Internet Explorer"===navigator.appName||0<=a.indexOf("MSIE ")||0<=a.indexOf("Trident/")&&0<=a.indexOf("Windows NT 6")?!0:!1};a.wb=function(a,b){for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&"function"===typeof a[d]&&(a[d]=b);};a.K=[];a.ea=function(c,b,d){if(a.Ka)return 0;a.maxDelay||(a.maxDelay=250);var f=0,e=(new Date).getTime()+a.maxDelay,g=a.d.visibilityState,k=["webkitvisibilitychange","visibilitychange"];g||(g=a.d.webkitVisibilityState);if(g&&"prerender"== +g){if(!a.fa)for(a.fa=1,d=0;dc){a.K.unshift(d);setTimeout(a.delayReady,parseInt(a.maxDelay/2));break}a.Ka=1;a[d.m].apply(a, +d.a);a.Ka=0;}};a.setAccount=a.sa=function(c){var b,d;if(!a.ea("setAccount",arguments))if(a.account=c,a.allAccounts)for(b=a.allAccounts.concat(c.split(",")),a.allAccounts=[],b.sort(),d=0;de.indexOf(".contextData."))switch(h=k.substring(0,4),n=k.substring(4),k){case "transactionID":k="xact";break;case "channel":k="ch";break;case "campaign":k="v0";break;default:a.Qa(n)&&("prop"==h?k="c"+n:"eVar"==h?k="v"+n:"list"== +h?k="l"+n:"hier"==h&&(k="h"+n,l=l.substring(0,255)));}g+="&"+a.escape(k)+"="+a.escape(l);}}""!=g&&(g+="&."+c);}return g};a.usePostbacks=0;a.Pb=function(){var c="",b,d,f,e,g,k,l,h,n="",m="",p=e="",r=a.T();if(a.lightProfileID)b=a.O,(n=a.lightTrackVars)&&(n=","+n+","+a.ka.join(",")+",");else{b=a.g;if(a.pe||a.linkType)n=a.linkTrackVars,m=a.linkTrackEvents,a.pe&&(e=a.pe.substring(0,1).toUpperCase()+a.pe.substring(1),a[e]&&(n=a[e].cc,m=a[e].bc));n&&(n=","+n+","+a.F.join(",")+",");m&&(m=","+m+",",n&&(n+=",events,")); +a.events2&&(p+=(""!=p?",":"")+a.events2);}if(r&&r.getCustomerIDs){e=q;if(g=r.getCustomerIDs())for(d in g)Object.prototype[d]||(f=g[d],"object"==typeof f&&(e||(e={}),f.id&&(e[d+".id"]=f.id),f.authState&&(e[d+".as"]=f.authState)));e&&(c+=a.o("cid",e));}a.AudienceManagement&&a.AudienceManagement.isReady()&&(c+=a.o("d",a.AudienceManagement.getEventCallConfigParams()));for(d=0;df||0<=e&&f>e||0<=g&&f>g)&&(e=a.protocol&&1f?0:f)+"/":"")+d);return d};a.L=function(c){var b=a.B(c),d,f,e="",g=0;return b&&(d=c.protocol,f=c.onclick,!c.href||"A"!=b&&"AREA"!=b||f&&d&&!(0>d.toLowerCase().indexOf("javascript"))?f?(e=a.replace(a.replace(a.replace(a.replace(""+f,"\r",""),"\n",""),"\t","")," ",""),g=2):"INPUT"==b||"SUBMIT"==b?(c.value?e=c.value:c.innerText?e=c.innerText:c.textContent&&(e=c.textContent),g=3):"IMAGE"==b&&c.src&&(e=c.src):e=a.Ma(c),e)?{id:e.substring(0,100),type:g}:0};a.ic=function(c){for(var b=a.B(c),d=a.L(c);c&& +!d&&"BODY"!=b;)if(c=c.parentElement?c.parentElement:c.parentNode)b=a.B(c),d=a.L(c);d&&"BODY"!=b||(c=0);c&&(b=c.onclick?""+c.onclick:"",0<=b.indexOf(".tl(")||0<=b.indexOf(".trackLink("))&&(c=0);return c};a.Xb=function(){var c,b,d=a.linkObject,f=a.linkType,e=a.linkURL,g,k;a.la=1;d||(a.la=0,d=a.clickObject);if(d){c=a.B(d);for(b=a.L(d);d&&!b&&"BODY"!=c;)if(d=d.parentElement?d.parentElement:d.parentNode)c=a.B(d),b=a.L(d);b&&"BODY"!=c||(d=0);if(d&&!a.linkObject){var l=d.onclick?""+d.onclick:"";if(0<=l.indexOf(".tl(")|| +0<=l.indexOf(".trackLink("))d=0;}}else a.la=1;!e&&d&&(e=a.Ma(d));e&&!a.linkLeaveQueryString&&(g=e.indexOf("?"),0<=g&&(e=e.substring(0,g)));if(!f&&e){var m=0,n=0,p;if(a.trackDownloadLinks&&a.linkDownloadFileTypes)for(l=e.toLowerCase(),g=l.indexOf("?"),k=l.indexOf("#"),0<=g?0<=k&&kb)return 0}return 1};a.S=function(c,b){var d,f,e,g,k,h,m;m={};for(d=0;2>d;d++)for(f=0b;b++)for(d=0c.indexOf("-")){for(c=0;16>c;c++)f= +Math.floor(Math.random()*f),b+="0123456789ABCDEF".substring(f,f+1),f=Math.floor(Math.random()*e),d+="0123456789ABCDEF".substring(f,f+1),f=e=16;c=b+"-"+d;}a.cookieWrite("s_fid",c,1)||(c=0);return c};a.Ea=function(c){var b=new Date,d="s"+Math.floor(b.getTime()/108E5)%10+Math.floor(1E13*Math.random()),f=b.getYear(),f="t="+a.escape(b.getDate()+"/"+b.getMonth()+"/"+(1900>f?f+1900:f)+" "+b.getHours()+":"+b.getMinutes()+":"+b.getSeconds()+" "+b.getDay()+" "+b.getTimezoneOffset()),e=a.T(),g;c&&(g=a.S(c,1)); +a.Ub()&&!a.visitorOptedOut&&(a.wa()||(a.fid=a.Nb()),a.Xb(),a.usePlugins&&a.doPlugins&&a.doPlugins(a),a.account&&(a.abort||(a.trackOffline&&!a.timestamp&&(a.timestamp=Math.floor(b.getTime()/1E3)),c=h.location,a.pageURL||(a.pageURL=c.href?c.href:c),a.referrer||a.Za||(c=a.Util.getQueryParam("adobe_mc_ref",null,null,!0),a.referrer=c||void 0===c?void 0===c?"":c:p.document.referrer),a.Za=1,a.referrer=a.Lb(a.referrer),a.u("_g")),a.Qb()&&!a.abort&&(e&&a.V("TARGET")&&!a.supplementalDataID&&e.getSupplementalDataID&& +(a.supplementalDataID=e.getSupplementalDataID("AppMeasurement:"+a._in,a.expectSupplementalData?!1:!0)),a.V("AAM")||(a.contextData["cm.ssf"]=1),a.Rb(),a.vb(),f+=a.Pb(),a.rb(d,f),a.u("_t"),a.referrer="")));a.Ca();g&&a.S(g,1);};a.t=a.track=function(c,b){b&&a.S(b);a.Y=!0;a.isReadyToTrack()?null!=a.j&&0a.N&&a.Va(a.i),a.qa(500);else{var c=a.Eb();if(0=a.offlineThrottleDelay)return 0;c=a.A()-a.Ta;return a.offlineThrottleDelaya.N&&a.Va(a.i);a.ca();a.qa(500);};b.onreadystatechange=function(){4==b.readyState&&(200== +b.status?b.R():b.ga());};a.Ta=a.A();if(1===d)b.send(c);else if(2===d)f=c.indexOf("?"),d=c.substring(0,f),f=c.substring(f+1),f=f.replace(/&callback=[a-zA-Z0-9_.\[\]]+/,""),b.open("POST",d,!0),b.withCredentials=!0,b.send(f);else if(b.src=c,3===d){if(a.Ra)try{f.removeChild(a.Ra);}catch(e){}f.firstChild?f.insertBefore(b,f.firstChild):f.appendChild(b);a.Ra=a.v;}b.D=setTimeout(function(){b.D&&(b.complete?b.R():(a.trackOffline&&b.abort&&b.abort(),b.ga()));},5E3);a.Hb=c;a.v=h["s_i_"+a.replace(a.account,",","_")]= +b;if(a.useForcedLinkTracking&&a.J||a.bodyClickFunction)a.forcedLinkTrackingTimeout||(a.forcedLinkTrackingTimeout=250),a.da=setTimeout(a.ca,a.forcedLinkTrackingTimeout);};a.mb=function(c){var b=!1;navigator.sendBeacon&&(a.ob(c)?b=!0:a.useBeacon&&(b=!0));a.xb(c)&&(b=!1);return b};a.ob=function(a){return a&&0a.N))try{h.localStorage.removeItem(a.ma()),a.Sa=a.A();}catch(c){}};a.Va=function(c){if(a.oa()){a.Xa();try{h.localStorage.setItem(a.ma(),h.JSON.stringify(c)),a.N=a.A();}catch(b){}}};a.Xa=function(){if(a.trackOffline){if(!a.offlineLimit||0>=a.offlineLimit)a.offlineLimit=10;for(;a.i.length>a.offlineLimit;)a.La();}};a.forceOffline=function(){a.na=!0;};a.forceOnline=function(){a.na=!1;};a.ma=function(){return a.offlineFilename+"-"+a.visitorNamespace+a.account};a.A=function(){return (new Date).getTime()}; +a.Pa=function(a){a=a.toLowerCase();return 0!=a.indexOf("#")&&0!=a.indexOf("about:")&&0!=a.indexOf("opera:")&&0!=a.indexOf("javascript:")?!0:!1};a.setTagContainer=function(c){var b,d,f;a.$b=c;for(b=0;b(""+f[b]).indexOf("s_c_il"))&&(c[b]=f[b]);if(d.mmq)for(b= +0;be)return g;b=d+b.substring(e+1)+d;if(!f||!(0<=b.indexOf(d+c+d)||0<=b.indexOf(d+ +c+"="+d))){e=b.indexOf("#");0<=e&&(b=b.substr(0,e)+d);e=b.indexOf(d+c+"=");if(0>e)return g;b=b.substring(e+d.length+c.length+1);e=b.indexOf(d);0<=e&&(b=b.substring(0,e));0=m;m++)76>m&&(a.g.push("prop"+m),a.O.push("prop"+m)),a.g.push("eVar"+m),a.O.push("eVar"+m),6>m&&a.g.push("hier"+m),4>m&&a.g.push("list"+m);m="pe pev1 pev2 pev3 latitude longitude resolution colorDepth javascriptVersion javaEnabled cookiesEnabled browserWidth browserHeight connectionType homepage pageURLRest marketingCloudOrgID ms_a".split(" ");a.g=a.g.concat(m);a.F=a.F.concat(m);a.ssl=0<=h.location.protocol.toLowerCase().indexOf("https");a.charSet="UTF-8";a.contextData={};a.writeSecureCookies= +!1;a.offlineThrottleDelay=0;a.offlineFilename="AppMeasurement.offline";a.P="s_sq";a.Ta=0;a.ia=0;a.N=0;a.Sa=0;a.linkDownloadFileTypes="exe,zip,wav,mp3,mov,mpg,avi,wmv,pdf,doc,docx,xls,xlsx,ppt,pptx";a.w=h;a.d=h.document;a.ca=function(){a.da&&(h.clearTimeout(a.da),a.da=q);a.bodyClickTarget&&a.J&&a.bodyClickTarget.dispatchEvent(a.J);a.bodyClickFunction&&("function"==typeof a.bodyClickFunction?a.bodyClickFunction():a.bodyClickTarget&&a.bodyClickTarget.href&&(a.d.location=a.bodyClickTarget.href));a.bodyClickTarget= +a.J=a.bodyClickFunction=0;};a.Wa=function(){a.b=a.d.body;a.b?(a.r=function(c){var b,d,f,e,g;if(!(a.d&&a.d.getElementById("cppXYctnr")||c&&c["s_fe_"+a._in])){if(a.Ha)if(a.useForcedLinkTracking)a.b.removeEventListener("click",a.r,!1);else{a.b.removeEventListener("click",a.r,!0);a.Ha=a.useForcedLinkTracking=0;return}else a.useForcedLinkTracking=0;a.clickObject=c.srcElement?c.srcElement:c.target;try{if(!a.clickObject||a.M&&a.M==a.clickObject||!(a.clickObject.tagName||a.clickObject.parentElement||a.clickObject.parentNode))a.clickObject= +0;else{var k=a.M=a.clickObject;a.ha&&(clearTimeout(a.ha),a.ha=0);a.ha=setTimeout(function(){a.M==k&&(a.M=0);},1E4);f=a.Na();a.track();if(f 0) { + setMCIDOnIntegrationAttributes(mcID); + } + + return true; + } catch (e) { + return 'error initializing adobe: ' + e; + } + } + + function setMarketingCloudId(mcid) { + setMCIDOnIntegrationAttributes(mcid); + } + + function setMCIDOnIntegrationAttributes(mcid) { + var adobeIntegrationAttributes = {}; + adobeIntegrationAttributes[MARKETINGCLOUDIDKEY] = mcid; + mParticle.setIntegrationAttribute( + ADOBEMODULENUMBER, + adobeIntegrationAttributes + ); + mParticle._setIntegrationDelay(ADOBEMODULENUMBER, false); + } + + // Get the mapped value for custom events + function getEventMappingValue(event) { + var jsHash = calculateJSHash( + event.EventDataType, + event.EventCategory, + event.EventName + ); + return findValueInMapping(jsHash, eventsMapping); + } + + function calculateJSHash(eventDataType, eventCategory, name) { + var preHash = + '' + eventDataType + ('' + eventCategory) + '' + (name || ''); + + return mParticle.generateHash(preHash); + } + + function findValueInMapping(jsHash, mapping) { + if (mapping) { + var filteredArray = mapping.filter(function(mappingEntry) { + if ( + mappingEntry.jsmap && + mappingEntry.maptype && + mappingEntry.value + ) { + return mappingEntry.jsmap === jsHash.toString(); + } + + return { + result: false, + }; + }); + + if (filteredArray && filteredArray.length > 0) { + return { + result: true, + matches: filteredArray, + }; + } + } + return null; + } + + // for each type of event, we run setMappings which sets the eVars, props, hvars, and contextData values + // after each event is sent to the server (either using t() for pageViews or tl() for non-pageview events), clearVars() is run to wipe out + function resetVariables() { + appMeasurement.clearVars(); + appMeasurement.contextData = {}; + } + // any eVars, props, and hvars + function processEvent(event) { + var linkName, + pageName, + reportEvent = false, + linkTrackVars = []; + + appMeasurement.timestamp = timestampOption + ? Math.floor(new Date().getTime() / 1000) + : null; + appMeasurement.events = ''; + if (event.CustomFlags && event.CustomFlags.hasOwnProperty(LINK_NAME)) { + linkName = event.CustomFlags[LINK_NAME]; + } + if (event.CustomFlags && event.CustomFlags.hasOwnProperty(PAGE_NAME)) { + pageName = event.CustomFlags[PAGE_NAME]; + } + + if (isAdobeClientKitInitialized) { + try { + // First determine if an eventName is mapped, if so, log it as an event as opposed to a pageview or commerceview + // ex. If a pageview is mapped to an event, we logEvent instead of logging it as a pageview + var eventMapping = getEventMappingValue(event); + + if ( + eventMapping && + eventMapping.result && + eventMapping.matches + ) { + setMappings(event, true, linkTrackVars); + reportEvent = logEvent( + event, + linkTrackVars, + eventMapping.matches, + linkName, + pageName + ); + } else if (event.EventDataType === MessageType$1.PageView) { + setMappings(event, false); + reportEvent = logPageView(event, pageName); + } else if (event.EventDataType === MessageType$1.Commerce) { + setMappings(event, true, linkTrackVars); + reportEvent = processCommerceTransaction( + event, + linkTrackVars, + linkName, + pageName + ); + } else if (event.EventDataType === MessageType$1.Media) { + self.adobeMediaSDK.process(event); + } else { + return 'event name not mapped, aborting event logging'; + } + + if ( + reportEvent === true && + reportingService && + event.EventDataType + ) { + reportingService(self, event); + return 'Successfully sent to ' + name; + } + } catch (e) { + return 'Failed to send to: ' + name + ' ' + e; + } + } + + return 'Cannot send to forwarder ' + name + ', not initialized.'; + } + + function setMappings(event, includeTrackVars, linkTrackVars) { + if (includeTrackVars) { + setEvars(event, linkTrackVars); + setProps(event, linkTrackVars); + setHiers(event, linkTrackVars); + setContextData(event, linkTrackVars); + } else { + setEvars(event); + setProps(event); + setHiers(event); + setContextData(event); + } + } + + function processCommerceTransaction( + event, + linkTrackVars, + linkName, + pageName + ) { + if ( + event.EventCategory === mParticle.CommerceEventType.ProductPurchase + ) { + appMeasurement.events = 'purchase'; + appMeasurement.purchaseID = event.ProductAction.TransactionId; + appMeasurement.transactionID = event.ProductAction.TransactionId; + linkTrackVars.push('purchaseID', 'transactionID'); + } else if ( + event.EventCategory === + mParticle.CommerceEventType.ProductViewDetail + ) { + appMeasurement.events = 'prodView'; + } else if ( + event.EventCategory === mParticle.CommerceEventType.ProductAddToCart + ) { + appMeasurement.events = 'scAdd'; + } else if ( + event.EventCategory === + mParticle.CommerceEventType.ProductRemoveFromCart + ) { + appMeasurement.events = 'scRemove'; + } else if ( + event.EventCategory === mParticle.CommerceEventType.ProductCheckout + ) { + appMeasurement.events = 'scCheckout'; + } + appMeasurement.linkTrackEvents = appMeasurement.events || null; + processProductsAndSetEvents(event); + + linkTrackVars.push('products', 'events'); + setPageName(linkTrackVars, appMeasurement, pageName); + appMeasurement.linkTrackVars = linkTrackVars; + appMeasurement.tl(true, 'o', linkName); + + resetVariables(); + + return true; + } + + function processProductsAndSetEvents(event) { + try { + var productDetails, + incrementor, + merchandising, + productBuilder, + product, + allProducts = []; + + var expandedEvents = mParticle.eCommerce.expandCommerceEvent(event); + expandedEvents.forEach(function(expandedEvt) { + productBuilder = []; + productDetails = []; + incrementor = []; + merchandising = []; + + if (expandedEvt.EventName === 'eCommerce - purchase - Total') { + for (var eventAttributeKey in expandedEvt.EventAttributes) { + if ( + expandedEvt.EventAttributes.hasOwnProperty( + eventAttributeKey + ) + ) { + var jsHash = calculateJSHash( + event.EventDataType, + event.EventCategory, + eventAttributeKey + ); + var mapping = findValueInMapping( + jsHash, + eventsMapping + ); + if (mapping && mapping.result && mapping.matches) { + mapping.matches.forEach(function(mapping) { + if (mapping.value) { + if ( + appMeasurement.events.indexOf( + mapping.value + ) < 0 + ) { + appMeasurement.events += + ',' + + mapping.value + + '=' + + expandedEvt.EventAttributes[ + eventAttributeKey + ]; + } + } + }); + } + } + } + } else { + var productAttributes = expandedEvt.EventAttributes; + productDetails.push( + productAttributes.Category || '', + productAttributes.Name, + productAttributes.Id, + productAttributes.Quantity || 1, + productAttributes['Item Price'] || 0 + ); + for (var productAttributeKey in expandedEvt.EventAttributes) { + if ( + expandedEvt.EventAttributes.hasOwnProperty( + productAttributeKey + ) + ) { + productIncrementorMapping.forEach(function( + productIncrementorMap + ) { + if ( + productIncrementorMap.map === + productAttributeKey + ) { + incrementor.push( + productIncrementorMap.value + + '=' + + productAttributes[ + productAttributeKey + ] + ); + if ( + appMeasurement.events.indexOf( + productIncrementorMap.value + ) < 0 + ) { + appMeasurement.events += + ',' + productIncrementorMap.value; + } + } + }); + productMerchandisingMapping.forEach(function( + productMerchandisingMap + ) { + if ( + productMerchandisingMap.map === + productAttributeKey + ) { + merchandising.push( + productMerchandisingMap.value + + '=' + + productAttributes[ + productAttributeKey + ] + ); + } + }); + } + } + productBuilder.push( + productDetails.join(';'), + incrementor.join('|'), + merchandising.join('|') + ); + product = productBuilder.join(';'); + allProducts.push(product); + } + }); + + appMeasurement.products = allProducts.join(','); + } catch (e) { + window.console.log(e); + } + } + + function logPageView(event, pageName) { + try { + appMeasurement.pageName = + pageName || event.EventName || window.document.title; + appMeasurement.t(); + resetVariables(); + return true; + } catch (e) { + resetVariables(); + return { error: 'logPageView not called, error ' + e }; + } + } + + function logEvent( + event, + linkTrackVars, + mappingMatches, + linkName, + pageName + ) { + try { + if (mappingMatches) { + mappingMatches.forEach(function(match) { + if (appMeasurement.events.length === 0) { + appMeasurement.events += match.value; + } else { + appMeasurement.events += ',' + match.value; + } + }); + appMeasurement.linkTrackEvents = appMeasurement.events; + + linkTrackVars.push('events'); + setPageName(linkTrackVars, appMeasurement, pageName); + + appMeasurement.linkTrackVars = linkTrackVars; + + appMeasurement.tl(true, 'o', linkName); + resetVariables(); + return true; + } else { + resetVariables(); + window.console.log( + 'event name not mapped, aborting event logging' + ); + return false; + } + } catch (e) { + resetVariables(); + return { error: e }; + } + } + + // .map is the attribute passed through, .value is the eVar value + function setEvars(event, linkTrackVars) { + var eventAttributes = event.EventAttributes; + for (var eventAttributeKey in eventAttributes) { + if (eventAttributes.hasOwnProperty(eventAttributeKey)) { + eVarsMapping.forEach(function(eVarMap) { + if (eVarMap.map === eventAttributeKey) { + appMeasurement[eVarMap.value] = + eventAttributes[eventAttributeKey]; + if (linkTrackVars) { + linkTrackVars.push(eVarMap.value); + } + } + if (event.EventName === eVarMap.map) { + appMeasurement[eVarMap.value] = event.EventName; + } + }); + } + } + } + + // .map is the attribute passed through, .value is the prop value + function setProps(event, linkTrackVars) { + var eventAttributes = event.EventAttributes; + for (var eventAttributeKey in eventAttributes) { + if (eventAttributes.hasOwnProperty(eventAttributeKey)) { + propsMapping.forEach(function(propMap) { + if (propMap.map === eventAttributeKey) { + appMeasurement[propMap.value] = + eventAttributes[eventAttributeKey]; + if (linkTrackVars) { + linkTrackVars.push(propMap.value); + } + } + }); + } + } + } + + // .map is the attribute passed through, .value is the hier value + function setHiers(event, linkTrackVars) { + var eventAttributes = event.EventAttributes; + for (var eventAttributeKey in eventAttributes) { + if (eventAttributes.hasOwnProperty(eventAttributeKey)) { + var jsHash = calculateJSHash( + event.EventDataType, + event.EventCategory, + eventAttributeKey + ); + var mapping = findValueInMapping(jsHash, hiersMapping); + if (mapping && mapping.result && mapping.matches) { + mapping.matches.forEach(function(mapping) { + if (mapping.value) { + appMeasurement[mapping.value] = + eventAttributes[eventAttributeKey]; + if (linkTrackVars) { + linkTrackVars.push(mapping.value); + } + } + }); + } + } + } + } + + // .map is the attribute passed through, .value is the contextData value + function setContextData(event, linkTrackVars) { + var eventAttributes = event.EventAttributes; + for (var eventAttributeKey in eventAttributes) { + if (eventAttributes.hasOwnProperty(eventAttributeKey)) { + contextVariableMapping.forEach(function(contextVariableMap) { + if (contextVariableMap.map === eventAttributeKey) { + appMeasurement.contextData[contextVariableMap.value] = + eventAttributes[eventAttributeKey]; + if (linkTrackVars) { + linkTrackVars.push( + 'contextData.' + contextVariableMap.value + ); + } + } + }); + } + } + } + + function onUserIdentified(mpUserObject) { + if (isAdobeClientKitInitialized) { + var userIdentities = mpUserObject.getUserIdentities() + .userIdentities; + + var identitiesToSet = {}; + if (Object.keys(userIdentities).length) { + for (var identity in userIdentities) { + identitiesToSet[identity] = { + id: userIdentities[identity], + }; + } + } else { + // no user identities means there was a logout, so set all current customer ids to null + var currentAdobeCustomerIds = appMeasurement.visitor.getCustomerIDs(); + for (var currentIdentityKey in currentAdobeCustomerIds) { + identitiesToSet[currentIdentityKey] = null; + } + } + + try { + appMeasurement.visitor.setCustomerIDs(identitiesToSet); + } catch (e) { + return 'Error calling setCustomerIDs on adobe'; + } + } else { + return ( + 'Cannot call setUserIdentity on forwarder ' + + name + + ', not initialized' + ); + } + } + + function setPageName(linkTrackVars, appMeasurement, pageName) { + if (settings.enablePageName === 'True') { + appMeasurement.pageName = pageName || window.document.title; + linkTrackVars.push('pageName'); + } + } + + this.init = initForwarder; + this.onUserIdentified = onUserIdentified; + this.process = processEvent; +}; + +function getId() { + return moduleId; +} + +if (window && window.mParticle && window.mParticle.addForwarder) { + window.mParticle.addForwarder({ + name: name, + constructor: constructor$1, + getId: getId, + }); +} + +function register(config) { + if (!config) { + window.console.log( + 'You must pass a config object to register the kit ' + name + ); + return; + } + + if (!isObject(config)) { + window.console.log( + '`config` must be an object. You passed in a ' + typeof config + ); + return; + } + + if (isObject(config.kits)) { + config.kits[name] = { + constructor: constructor$1, + }; + } else { + config.kits = {}; + config.kits[name] = { + constructor: constructor$1, + }; + } + window.console.log( + 'Successfully registered ' + name + ' to your mParticle configuration' + ); +} + +function isObject(val) { + return ( + val != null && typeof val === 'object' && Array.isArray(val) === false + ); +} + +var AdobeClientSideKit_esm = { + register: register, +}; + +module.exports = AdobeClientSideKit_esm; diff --git a/kits/adobe/packages/AdobeClient/dist/AdobeClientSideKit.iife.js b/kits/adobe/packages/AdobeClient/dist/AdobeClientSideKit.iife.js new file mode 100644 index 000000000..e32217434 --- /dev/null +++ b/kits/adobe/packages/AdobeClient/dist/AdobeClientSideKit.iife.js @@ -0,0 +1,1326 @@ +var mParticleAdobeClient = (function () { + function Common() { + this.playheadPosition = 0; + this.startupTime = 0; + this.droppedFrames = 0; + this.bitRate = 0; + this.fps = 0; + } + + var common = Common; + + var MediaEventType = { + Play: 23, + Pause: 24, + ContentEnd: 25, + SessionStart: 30, + SessionEnd: 31, + SeekStart: 32, + SeekEnd: 33, + BufferStart: 34, + BufferEnd: 35, + UpdatePlayheadPosition: 36, + AdClick: 37, + AdBreakStart: 38, + AdBreakEnd: 39, + AdStart: 40, + AdEnd: 41, + AdSkip: 42, + SegmentStart: 43, + SegmentEnd: 44, + SegmentSkip: 45, + UpdateQoS: 46, + }; + + var ContentType = { + Audio: 'Audio', + Video: 'Video', + }; + + var StreamType = { + LiveStream: 'LiveStream', + OnDemand: 'OnDemand', + Linear: 'Linear', + Podcast: 'Podcast', + Audiobook: 'Audiobook', + }; + + function EventHandler(common) { + this.common = common || {}; + } + EventHandler.prototype.logEvent = function(event) { + var customAttributes = {}; + if (event && event.EventAttributes) { + customAttributes = event.EventAttributes; + } + + if (event && event.PlayheadPosition) { + this.common.playheadPosition = event.PlayheadPosition / 1000; + } + + switch (event.EventCategory) { + case MediaEventType.AdBreakStart: + var adBreakObject = this.common.MediaHeartbeat.createAdBreakObject( + event.AdBreak.title, + event.AdBreak.placement || 0, // TODO: Ad Break Object doesn't support placement yet + this.common.playheadPosition + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdBreakStart, + adBreakObject, + customAttributes + ); + break; + case MediaEventType.AdBreakEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdBreakComplete, + {}, + customAttributes + ); + break; + case MediaEventType.AdStart: + var adObject = this.common.MediaHeartbeat.createAdObject( + event.AdContent.title, + event.AdContent.id, + event.AdContent.position, + event.AdContent.duration / 1000 + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdStart, + adObject, + customAttributes + ); + break; + case MediaEventType.AdEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdComplete, + {}, + customAttributes + ); + break; + case MediaEventType.AdSkip: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdSkip, + {}, + customAttributes + ); + break; + case MediaEventType.AdClick: + // This is not supported in Adobe Heartbeat + console.warn('Ad Click is not a supported Adobe Heartbeat Event'); + break; + case MediaEventType.BufferStart: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.BufferStart, + {}, + customAttributes + ); + break; + case MediaEventType.BufferEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.BufferComplete, + {}, + customAttributes + ); + break; + case MediaEventType.ContentEnd: + this.common.mediaHeartbeat.trackComplete(); + break; + case MediaEventType.SessionStart: + var streamType = getStreamType( + event.StreamType, + event.ContentType, + this.common.MediaHeartbeat.StreamType + ); + + var adobeMediaObject = this.common.MediaHeartbeat.createMediaObject( + event.ContentTitle, + event.ContentId, + event.Duration / 1000, + streamType, + event.ContentType + ); + + var combinedAttributes = getAdobeMetadataKeys( + customAttributes, + this.common.MediaHeartbeat + ); + + this.common.mediaHeartbeat.trackSessionStart( + adobeMediaObject, + combinedAttributes + ); + break; + + case MediaEventType.SessionEnd: + this.common.mediaHeartbeat.trackSessionEnd(); + break; + case MediaEventType.Play: + this.common.mediaHeartbeat.trackPlay(); + break; + case MediaEventType.Pause: + this.common.mediaHeartbeat.trackPause(); + break; + case MediaEventType.UpdatePlayheadPosition: + // This is commented out because we're updating playhead position + // for all events and Adobe does not have a relevant playhead + // update position function + break; + case MediaEventType.SeekStart: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.SeekStart, + {}, + customAttributes + ); + break; + case MediaEventType.SeekEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.SeekComplete, + {}, + customAttributes + ); + break; + case MediaEventType.SegmentStart: + var chapterObject = this.common.MediaHeartbeat.createChapterObject( + event.Segment.title, + event.Segment.index, + event.Segment.duration / 1000, + this.common.playheadPosition + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.ChapterStart, + chapterObject, + customAttributes + ); + break; + case MediaEventType.SegmentEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.ChapterComplete, + {}, + customAttributes + ); + break; + case MediaEventType.SegmentSkip: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.ChapterSkip, + {}, + customAttributes + ); + break; + case MediaEventType.UpdateQoS: + this.common.startupTime = event.QoS.startupTime / 1000; + this.common.droppedFrames = event.QoS.droppedFrames; + this.common.bitRate = event.QoS.bitRate; + this.common.fps = event.QoS.fps; + + var qosObject = this.common.MediaHeartbeat.createQoSObject( + this.common.bitRate, + this.common.startupTime, + this.common.fps, + this.common.droppedFrames + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.BitrateChange, + qosObject, + customAttributes + ); + break; + default: + console.error('Unknown Event Type', event); + return false; + } + }; + + var getAdobeMetadataKeys = function(attributes, Heartbeat) { + var AdobeMetadataLookupTable = { + // Ad Meta Data + ad_content_advertiser: Heartbeat.AdMetadataKeys.ADVERTISER, + ad_content_campaign: Heartbeat.AdMetadataKeys.CAMPAIGN_ID, + ad_content_creative: Heartbeat.AdMetadataKeys.CREATIVE_ID, + ad_content_placement: Heartbeat.AdMetadataKeys.PLACEMENT_ID, + ad_content_site_id: Heartbeat.AdMetadataKeys.SITE_ID, + ad_content_creative_url: Heartbeat.AdMetadataKeys.CREATIVE_URL, + + // Audio Meta + content_artist: Heartbeat.AudioMetadataKeys.ARTIST, + content_album: Heartbeat.AudioMetadataKeys.ALBUM, + content_label: Heartbeat.AudioMetadataKeys.LABEL, + content_author: Heartbeat.AudioMetadataKeys.AUTHOR, + content_station: Heartbeat.AudioMetadataKeys.STATION, + content_publisher: Heartbeat.AudioMetadataKeys.PUBLISHER, + + // Video Meta + content_show: Heartbeat.VideoMetadataKeys.SHOW, + stream_format: Heartbeat.VideoMetadataKeys.STREAM_FORMAT, + content_season: Heartbeat.VideoMetadataKeys.SEASON, + content_episode: Heartbeat.VideoMetadataKeys.EPISODE, + content_asset_id: Heartbeat.VideoMetadataKeys.ASSET_ID, + content_genre: Heartbeat.VideoMetadataKeys.GENRE, + content_first_air_date: Heartbeat.VideoMetadataKeys.FIRST_AIR_DATE, + content_digital_date: Heartbeat.VideoMetadataKeys.FIRST_DIGITAL_DATE, + content_rating: Heartbeat.VideoMetadataKeys.RATING, + content_originator: Heartbeat.VideoMetadataKeys.ORIGINATOR, + content_network: Heartbeat.VideoMetadataKeys.NETWORK, + content_show_type: Heartbeat.VideoMetadataKeys.SHOW_TYPE, + content_ad_load: Heartbeat.VideoMetadataKeys.AD_LOAD, + content_mvpd: Heartbeat.VideoMetadataKeys.MVPD, + content_authorized: Heartbeat.VideoMetadataKeys.AUTHORIZED, + content_daypart: Heartbeat.VideoMetadataKeys.DAY_PART, + content_feed: Heartbeat.VideoMetadataKeys.FEED, + }; + + var adobeMetadataKeys = {}; + for (var attribute in attributes) { + var key = attribute; + if (AdobeMetadataLookupTable[attribute]) { + key = AdobeMetadataLookupTable[attribute]; + } + adobeMetadataKeys[key] = attributes[attribute]; + } + + return adobeMetadataKeys; + }; + + var getStreamType = function(streamType, contentType, types) { + switch (streamType) { + case StreamType.OnDemand: + return contentType === ContentType.Video ? types.VOD : types.AOD; + case StreamType.LiveStream: + return types.LIVE; + case StreamType.Linear: + return types.LINEAR; + case StreamType.Podcast: + return types.PODCAST; + case StreamType.Audiobook: + return types.AUDIOBOOK; + default: + // If it's an unknown type, just pass it through to Adobe + return streamType; + } + }; + + var eventHandler = EventHandler; + + var Initialization = { + name: 'AdobeHeartbeat', + moduleId: 124, + initForwarder: function( + settings, + testMode, + userAttributes, + userIdentities, + processEvent, + eventQueue, + common, + initForwarderCallback + ) { + var self = this; + if (!window.mParticle.isTestEnvironment || !window.ADB) { + /* Load your Web SDK here using a variant of your snippet from your readme that your customers would generally put into their tags + Generally, our integrations create script tags and append them to the . Please follow the following format as a guide: + */ + var adobeHeartbeatSdk = document.createElement('script'); + adobeHeartbeatSdk.type = 'text/javascript'; + adobeHeartbeatSdk.async = true; + adobeHeartbeatSdk.src = + 'https://static.mparticle.com/sdk/web/adobe/MediaSDK.min.js'; + ( + document.getElementsByTagName('head')[0] || + document.getElementsByTagName('body')[0] + ).appendChild(adobeHeartbeatSdk); + adobeHeartbeatSdk.onload = function() { + if (ADB) { + self.initHeartbeat( + settings, + common, + ADB, + testMode, + initForwarderCallback + ); + if (eventQueue.length > 0) { + // Process any events that may have been queued up while forwarder was being initialized. + for (var i = 0; i < eventQueue.length; i++) { + processEvent(eventQueue[i]); + } + // now that each queued event is processed, we empty the eventQueue + eventQueue = []; + } + } + }; + } else { + // For testing, you should fill out this section in order to ensure any required initialization calls are made, + // clientSDKObject.initialize(forwarderSettings.apiKey) + self.initHeartbeat( + settings, + common, + ADB, + testMode, + initForwarderCallback + ); + } + }, + initHeartbeat: function( + settings, + common, + adobeSDK, + testMode, + initHeartbeatCallback + ) { + try { + // Init App Measurement with Visitor + var appMeasurement = new AppMeasurement(settings.reportSuiteIDs); + var visitorOptions = {}; + if (settings.audienceManagerServer) { + visitorOptions.audienceManagerServer = + settings.audienceManagerServer; + } + + appMeasurement.visitor = Visitor.getInstance( + settings.organizationID, + visitorOptions + ); + appMeasurement.trackingServer = settings.trackingServer; + appMeasurement.account = settings.reportSuiteIDs; + appMeasurement.pageName = document.title; + appMeasurement.charSet = 'UTF­8'; + + // Init Media Heartbeat + + var MediaHeartbeat = adobeSDK.va.MediaHeartbeat; + var MediaHeartbeatConfig = adobeSDK.va.MediaHeartbeatConfig; + var MediaHeartbeatDelegate = adobeSDK.va.MediaHeartbeatDelegate; + var mediaConfig = new MediaHeartbeatConfig(); + common.MediaHeartbeat = MediaHeartbeat; + + mediaConfig.trackingServer = settings.mediaTrackingServer; + mediaConfig.ssl = settings.useSSL === 'True'; + mediaConfig.playerName = 'mParticle Media SDK'; + + var mediaDelegate = new MediaHeartbeatDelegate(); + + mediaDelegate.getCurrentPlaybackTime = function() { + return common.playheadPosition; + }; + + mediaDelegate.getQoSObject = function() { + return MediaHeartbeat.createQoSObject( + common.bitRate, + common.startupTime, + common.fps, + common.droppedFrames + ); + }; + + var mediaHeartbeat = new MediaHeartbeat( + mediaDelegate, + mediaConfig, + appMeasurement + ); + common.mediaHeartbeat = mediaHeartbeat; + } catch (e) { + console.error(e); + } + + initHeartbeatCallback(); + }, + }; + + var initialization = Initialization; + + // =============== REACH OUT TO MPARTICLE IF YOU HAVE ANY QUESTIONS =============== + // + // Copyright 2018 mParticle, Inc. + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + + + + + + var MessageType = { + SessionStart: 1, + SessionEnd: 2, + PageView: 3, + PageEvent: 4, + CrashReport: 5, + OptOut: 6, + Commerce: 16, + Media: 20, + }; + + function constructor() { + var self = this, + isAdobeMediaSDKInitialized = false, + reportingService, + eventQueue = [], + name = 'AdobeHeartbeatKit'; + + self.moduleId = initialization.moduleId; + self.common = new common(); + + var initForwarderCallback = function() { + isAdobeMediaSDKInitialized = true; + }; + + function initForwarder( + settings, + service, + testMode, + trackerId, + userAttributes, + userIdentities + ) { + if (window.mParticle.isTestEnvironment) { + reportingService = function() {}; + } else { + reportingService = service; + } + + try { + initialization.initForwarder( + settings, + testMode, + userAttributes, + userIdentities, + processEvent, + eventQueue, + self.common, + initForwarderCallback + ); + self.eventHandler = new eventHandler(self.common); + } catch (e) { + console.error('Failed to initialize ' + name, e); + } + } + + function processEvent(event) { + var reportEvent = false; + if (isAdobeMediaSDKInitialized) { + try { + if (event.EventDataType === MessageType.Media) { + // Kits should just treat Media Events as generic Events + reportEvent = logEvent(event); + } + if (reportEvent === true && reportingService) { + reportingService(self, event); + return 'Successfully sent to ' + name; + } else { + return ( + 'Error logging event or event type not supported on forwarder ' + + name + ); + } + } catch (e) { + return 'Failed to send to ' + name + ' ' + e; + } + } else { + eventQueue.push(event); + return ( + 'Cannot send to forwarder ' + + name + + ', not initialized. Event added to queue.' + ); + } + } + + function logEvent(event) { + try { + self.eventHandler.logEvent(event); + return true; + } catch (e) { + return { + error: 'Error logging event on forwarder ' + name + '; ' + e, + }; + } + } + + this.init = initForwarder; + this.process = processEvent; + } + + if (window.mParticle && window.mParticle.registerHBK) { + window.mParticle.registerHBK({ constructor: constructor }); + } + + var src = { + AdobeHbkConstructor: constructor, + }; + var src_1 = src.AdobeHbkConstructor; + + /** + * @license + * Adobe Visitor API for JavaScript version: 4.4.0 + * Copyright 2019 Adobe, Inc. All Rights Reserved + * More info available at https://marketing.adobe.com/resources/help/en_US/mcvid/ + */ + var e=function(){function e(t){return (e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(){return {callbacks:{},add:function(e,t){this.callbacks[e]=this.callbacks[e]||[];var n=this.callbacks[e].push(t)-1,i=this;return function(){i.callbacks[e].splice(n,1);}},execute:function(e,t){if(this.callbacks[e]){t=void 0===t?[]:t,t=t instanceof Array?t:[t];try{for(;this.callbacks[e].length;){var n=this.callbacks[e].shift();"function"==typeof n?n.apply(null,t):n instanceof Array&&n[1].apply(n[0],t);}delete this.callbacks[e];}catch(e){}}},executeAll:function(e,t){(t||e&&!j.isObjectEmpty(e))&&Object.keys(this.callbacks).forEach(function(t){var n=void 0!==e[t]?e[t]:"";this.execute(t,n);},this);},hasCallbacks:function(){return Boolean(Object.keys(this.callbacks).length)}}}function i(e,t,n){var i=null==e?void 0:e[t];return void 0===i?n:i}function r(e){for(var t=/^\d+$/,n=0,i=e.length;nr)return 1;if(r>i)return -1}return 0}function s(e,t){if(e===t)return 0;var n=e.toString().split("."),i=t.toString().split(".");return r(n.concat(i))?(a(n,i),o(n,i)):NaN}function l(e){return e===Object(e)&&0===Object.keys(e).length}function c(e){return "function"==typeof e||e instanceof Array&&e.length}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){return !0};this.log=_e("log",e,t),this.warn=_e("warn",e,t),this.error=_e("error",e,t);}function d(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.isEnabled,n=e.cookieName,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i.cookies;return t&&n&&r?{remove:function(){r.remove(n);},get:function(){var e=r.get(n),t={};try{t=JSON.parse(e);}catch(e){t={};}return t},set:function(e,t){t=t||{},r.set(n,JSON.stringify(e),{domain:t.optInCookieDomain||"",cookieLifetime:t.optInStorageExpiry||3419e4,expires:!0});}}:{get:Le,set:Le,remove:Le}}function f(e){this.name=this.constructor.name,this.message=e,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error(e).stack;}function p(){function e(e,t){var n=Se(e);return n.length?n.every(function(e){return !!t[e]}):De(t)}function t(){M(b),O(ce.COMPLETE),_(h.status,h.permissions),m.set(h.permissions,{optInCookieDomain:l,optInStorageExpiry:c}),C.execute(xe);}function n(e){return function(n,i){if(!Ae(n))throw new Error("[OptIn] Invalid category(-ies). Please use the `OptIn.Categories` enum.");return O(ce.CHANGED),Object.assign(b,ye(Se(n),e)),i||t(),h}}var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.doesOptInApply,a=i.previousPermissions,o=i.preOptInApprovals,s=i.isOptInStorageEnabled,l=i.optInCookieDomain,c=i.optInStorageExpiry,u=i.isIabContext,f=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},p=f.cookies,g=Pe(a);Re(g,"Invalid `previousPermissions`!"),Re(o,"Invalid `preOptInApprovals`!");var m=d({isEnabled:!!s,cookieName:"adobeujs-optin"},{cookies:p}),h=this,_=le(h),C=ge(),I=Me(g),v=Me(o),S=m.get(),D={},A=function(e,t){return ke(e)||t&&ke(t)?ce.COMPLETE:ce.PENDING}(I,S),y=function(e,t,n){var i=ye(pe,!r);return r?Object.assign({},i,e,t,n):i}(v,I,S),b=be(y),O=function(e){return A=e},M=function(e){return y=e};h.deny=n(!1),h.approve=n(!0),h.denyAll=h.deny.bind(h,pe),h.approveAll=h.approve.bind(h,pe),h.isApproved=function(t){return e(t,h.permissions)},h.isPreApproved=function(t){return e(t,v)},h.fetchPermissions=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=t?h.on(ce.COMPLETE,e):Le;return !r||r&&h.isComplete||!!o?e(h.permissions):t||C.add(xe,function(){return e(h.permissions)}),n},h.complete=function(){h.status===ce.CHANGED&&t();},h.registerPlugin=function(e){if(!e||!e.name||"function"!=typeof e.onRegister)throw new Error(je);D[e.name]||(D[e.name]=e,e.onRegister.call(e,h));},h.execute=Ne(D),Object.defineProperties(h,{permissions:{get:function(){return y}},status:{get:function(){return A}},Categories:{get:function(){return ue}},doesOptInApply:{get:function(){return !!r}},isPending:{get:function(){return h.status===ce.PENDING}},isComplete:{get:function(){return h.status===ce.COMPLETE}},__plugins:{get:function(){return Object.keys(D)}},isIabContext:{get:function(){return u}}});}function g(e,t){function n(){r=null,e.call(e,new f("The call took longer than you wanted!"));}function i(){r&&(clearTimeout(r),e.apply(e,arguments));}if(void 0===t)return e;var r=setTimeout(n,t);return i}function m(){if(window.__cmp)return window.__cmp;var e=window;if(e===window.top)return void Ie.error("__cmp not found");for(var t;!t;){e=e.parent;try{e.frames.__cmpLocator&&(t=e);}catch(e){}if(e===window.top)break}if(!t)return void Ie.error("__cmp not found");var n={};return window.__cmp=function(e,i,r){var a=Math.random()+"",o={__cmpCall:{command:e,parameter:i,callId:a}};n[a]=r,t.postMessage(o,"*");},window.addEventListener("message",function(e){var t=e.data;if("string"==typeof t)try{t=JSON.parse(e.data);}catch(e){}if(t.__cmpReturn){var i=t.__cmpReturn;n[i.callId]&&(n[i.callId](i.returnValue,i.success),delete n[i.callId]);}},!1),window.__cmp}function h(){var e=this;e.name="iabPlugin",e.version="0.0.1";var t=ge(),n={allConsentData:null},i=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return n[e]=t};e.fetchConsentData=function(e){var t=e.callback,n=e.timeout,i=g(t,n);r({callback:i});},e.isApproved=function(e){var t=e.callback,i=e.category,a=e.timeout;if(n.allConsentData)return t(null,s(i,n.allConsentData.vendorConsents,n.allConsentData.purposeConsents));var o=g(function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.vendorConsents,a=n.purposeConsents;t(e,s(i,r,a));},a);r({category:i,callback:o});},e.onRegister=function(t){var n=Object.keys(de),i=function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i.purposeConsents,a=i.gdprApplies,o=i.vendorConsents;!e&&a&&o&&r&&(n.forEach(function(e){var n=s(e,o,r);t[n?"approve":"deny"](e,!0);}),t.complete());};e.fetchConsentData({callback:i});};var r=function(e){var r=e.callback;if(n.allConsentData)return r(null,n.allConsentData);t.add("FETCH_CONSENT_DATA",r);var s={};o(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.purposeConsents,o=e.gdprApplies,l=e.vendorConsents;(arguments.length>1?arguments[1]:void 0)&&(s={purposeConsents:r,gdprApplies:o,vendorConsents:l},i("allConsentData",s)),a(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(arguments.length>1?arguments[1]:void 0)&&(s.consentString=e.consentData,i("allConsentData",s)),t.execute("FETCH_CONSENT_DATA",[null,n.allConsentData]);});});},a=function(e){var t=m();t&&t("getConsentData",null,e);},o=function(e){var t=Fe(de),n=m();n&&n("getVendorConsents",t,e);},s=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=!!t[de[e]];return i&&function(){return fe[e].every(function(e){return n[e]})}()};}var _="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};Object.assign=Object.assign||function(e){for(var t,n,i=1;i4;e--){var t=document.createElement("div");if(t.innerHTML="\x3c!--[if IE "+e+"]>=0;n--)if(t=i.slice(n).join("."),Q.set("test","cookie",{domain:t}))return Q.remove("test",{domain:t}),t;return ""},Z={compare:s,isLessThan:function(e,t){return s(e,t)<0},areVersionsDifferent:function(e,t){return 0!==s(e,t)},isGreaterThan:function(e,t){return s(e,t)>0},isEqual:function(e,t){return 0===s(e,t)}},ee=!!_.postMessage,te={postMessage:function(e,t,n){var i=1;t&&(ee?n.postMessage(e,t.replace(/([^:]+:\/\/[^\/]+).*/,"$1")):t&&(n.location=t.replace(/#.*$/,"")+"#"+ +new Date+i+++"&"+e));},receiveMessage:function(e,t){var n;try{ee&&(e&&(n=function(n){if("string"==typeof t&&n.origin!==t||"[object Function]"===Object.prototype.toString.call(t)&&!1===t(n.origin))return !1;e(n);}),_.addEventListener?_[e?"addEventListener":"removeEventListener"]("message",n):_[e?"attachEvent":"detachEvent"]("onmessage",n));}catch(e){}}},ne=function(e){var t,n,i="0123456789",r="",a="",o=8,s=10,l=10;if(1==e){for(i+="ABCDEF",t=0;16>t;t++)n=Math.floor(Math.random()*o),r+=i.substring(n,n+1),n=Math.floor(Math.random()*o),a+=i.substring(n,n+1),o=16;return r+"-"+a}for(t=0;19>t;t++)n=Math.floor(Math.random()*s),r+=i.substring(n,n+1),0===t&&9==n?s=3:(1==t||2==t)&&10!=s&&2>n?s=10:2n?l=10:20&&(t=!1)),{corsType:e,corsCookiesEnabled:t}}(),getCORSInstance:function(){return "none"===this.corsMetadata.corsType?null:new _[this.corsMetadata.corsType]},fireCORS:function(t,n,i){function r(e){var n;try{if((n=JSON.parse(e))!==Object(n))return void a.handleCORSError(t,null,"Response is not JSON")}catch(e){return void a.handleCORSError(t,e,"Error parsing response as JSON")}try{for(var i=t.callback,r=_,o=0;o=a&&(e.splice(r,1),r--);return {dataPresent:o,dataValid:s}},manageSyncsSize:function(e){if(e.join("*").length>this.MAX_SYNCS_LENGTH)for(e.sort(function(e,t){return parseInt(e.split("-")[1],10)-parseInt(t.split("-")[1],10)});e.join("*").length>this.MAX_SYNCS_LENGTH;)e.shift();},fireSync:function(t,n,i,r,a,o){var s=this;if(t){if("img"===n.tag){var l,c,u,d,f=n.url,p=e.loadSSL?"https:":"http:";for(l=0,c=f.length;lre.DAYS_BETWEEN_SYNC_ID_CALLS},attachIframeASAP:function(){function e(){t.startedAttachingIframe||(n.body?t.attachIframe():setTimeout(e,30));}var t=this;e();}}},oe={audienceManagerServer:{},audienceManagerServerSecure:{},cookieDomain:{},cookieLifetime:{},cookieName:{},doesOptInApply:{},disableThirdPartyCalls:{},discardTrackingServerECID:{},idSyncAfterIDCallResult:{},idSyncAttachIframeOnWindowLoad:{},idSyncContainerID:{},idSyncDisable3rdPartySyncing:{},disableThirdPartyCookies:{},idSyncDisableSyncs:{},disableIdSyncs:{},idSyncIDCallResult:{},idSyncSSLUseAkamai:{},isCoopSafe:{},isIabContext:{},isOptInStorageEnabled:{},loadSSL:{},loadTimeout:{},marketingCloudServer:{},marketingCloudServerSecure:{},optInCookieDomain:{},optInStorageExpiry:{},overwriteCrossDomainMCIDAndAID:{},preOptInApprovals:{},previousPermissions:{},resetBeforeVersion:{},sdidParamExpiry:{},serverState:{},sessionCookieName:{},secureCookie:{},takeTimeoutMetrics:{},trackingServer:{},trackingServerSecure:{},whitelistIframeDomains:{},whitelistParentDomain:{}},se={getConfigNames:function(){return Object.keys(oe)},getConfigs:function(){return oe},normalizeConfig:function(e){return "function"!=typeof e?e:e()}},le=function(e){var t={};return e.on=function(e,n,i){if(!n||"function"!=typeof n)throw new Error("[ON] Callback should be a function.");t.hasOwnProperty(e)||(t[e]=[]);var r=t[e].push({callback:n,context:i})-1;return function(){t[e].splice(r,1),t[e].length||delete t[e];}},e.off=function(e,n){t.hasOwnProperty(e)&&(t[e]=t[e].filter(function(e){if(e.callback!==n)return e}));},e.publish=function(e){if(t.hasOwnProperty(e)){var n=[].slice.call(arguments,1);t[e].slice(0).forEach(function(e){e.callback.apply(e.context,n);});}},e.publish},ce={PENDING:"pending",CHANGED:"changed",COMPLETE:"complete"},ue={AAM:"aam",ADCLOUD:"adcloud",ANALYTICS:"aa",CAMPAIGN:"campaign",ECID:"ecid",LIVEFYRE:"livefyre",TARGET:"target",VIDEO_ANALYTICS:"videoaa"},de=(C={},t(C,ue.AAM,565),t(C,ue.ECID,565),C),fe=(I={},t(I,ue.AAM,[1,2,5]),t(I,ue.ECID,[1,2,5]),I),pe=function(e){return Object.keys(e).map(function(t){return e[t]})}(ue),ge=function(){var e={};return e.callbacks=Object.create(null),e.add=function(t,n){if(!c(n))throw new Error("[callbackRegistryFactory] Make sure callback is a function or an array of functions.");e.callbacks[t]=e.callbacks[t]||[];var i=e.callbacks[t].push(n)-1;return function(){e.callbacks[t].splice(i,1);}},e.execute=function(t,n){if(e.callbacks[t]){n=void 0===n?[]:n,n=n instanceof Array?n:[n];try{for(;e.callbacks[t].length;){var i=e.callbacks[t].shift();"function"==typeof i?i.apply(null,n):i instanceof Array&&i[1].apply(i[0],n);}delete e.callbacks[t];}catch(e){}}},e.executeAll=function(t,n){(n||t&&!l(t))&&Object.keys(e.callbacks).forEach(function(n){var i=void 0!==t[n]?t[n]:"";e.execute(n,i);},e);},e.hasCallbacks=function(){return Boolean(Object.keys(e.callbacks).length)},e},me=function(){},he=function(e){var t=window,n=t.console;return !!n&&"function"==typeof n[e]},_e=function(e,t,n){return n()?function(){if(he(e)){for(var n=arguments.length,i=new Array(n),r=0;r-1})},ye=function(e,t){return e.reduce(function(e,n){return e[n]=t,e},{})},be=function(e){return JSON.parse(JSON.stringify(e))},Oe=function(e){return "[object Array]"===Object.prototype.toString.call(e)&&!e.length},Me=function(e){if(Te(e))return e;try{return JSON.parse(e)}catch(e){return {}}},ke=function(e){return void 0===e||(Te(e)?Ae(Object.keys(e)):Ee(e))},Ee=function(e){try{var t=JSON.parse(e);return !!e&&ve(e,"string")&&Ae(Object.keys(t))}catch(e){return !1}},Te=function(e){return null!==e&&ve(e,"object")&&!1===Array.isArray(e)},Le=function(){},Pe=function(e){return ve(e,"function")?e():e},Re=function(e,t){ke(e)||Ie.error("".concat(t));},we=function(e){return Object.keys(e).map(function(t){return e[t]})},Fe=function(e){return we(e).filter(function(e,t,n){return n.indexOf(e)===t})},Ne=function(e){return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.command,i=t.params,r=void 0===i?{}:i,a=t.callback,o=void 0===a?Le:a;if(!n||-1===n.indexOf("."))throw new Error("[OptIn.execute] Please provide a valid command.");try{var s=n.split("."),l=e[s[0]],c=s[1];if(!l||"function"!=typeof l[c])throw new Error("Make sure the plugin and API name exist.");var u=Object.assign(r,{callback:o});l[c].call(l,u);}catch(e){Ie.error("[execute] Something went wrong: "+e.message);}}};f.prototype=Object.create(Error.prototype),f.prototype.constructor=f;var xe="fetchPermissions",je="[OptIn#registerPlugin] Plugin is invalid.";p.Categories=ue,p.TimeoutError=f;var Ve=Object.freeze({OptIn:p,IabPlugin:h}),He=function(e,t){e.publishDestinations=function(n){var i=arguments[1],r=arguments[2];try{r="function"==typeof r?r:n.callback;}catch(e){r=function(){};}var a=t;if(!a.readyToAttachIframePreliminary())return void r({error:"The destination publishing iframe is disabled in the Visitor library."});if("string"==typeof n){if(!n.length)return void r({error:"subdomain is not a populated string."});if(!(i instanceof Array&&i.length))return void r({error:"messages is not a populated array."});var o=!1;if(i.forEach(function(e){ + "string"==typeof e&&e.length&&(a.addMessage(e),o=!0);}),!o)return void r({error:"None of the messages are populated strings."})}else{if(!j.isObject(n))return void r({error:"Invalid parameters passed."});var s=n;if("string"!=typeof(n=s.subdomain)||!n.length)return void r({error:"config.subdomain is not a populated string."});var l=s.urlDestinations;if(!(l instanceof Array&&l.length))return void r({error:"config.urlDestinations is not a populated array."});var c=[];l.forEach(function(e){j.isObject(e)&&(e.hideReferrer?e.message&&a.addMessage(e.message):c.push(e));});!function e(){c.length&&setTimeout(function(){var t=new Image,n=c.shift();t.src=n.url,a.onPageDestinationsFired.push(n),e();},100);}();}a.iframe?(r({message:"The destination publishing iframe is already attached and loaded."}),a.requestToProcess()):!e.subdomain&&e._getField("MCMID")?(a.subdomain=n,a.doAttachIframe=!0,a.url=a.getUrl(),a.readyToAttachIframe()?(a.iframeLoadedCallbacks.push(function(e){r({message:"Attempted to attach and load the destination publishing iframe through this API call. Result: "+(e.message||"no result")});}),a.attachIframe()):r({error:"Encountered a problem in attempting to attach and load the destination publishing iframe through this API call."})):a.iframeLoadedCallbacks.push(function(e){r({message:"Attempted to attach and load the destination publishing iframe through normal Visitor API processing. Result: "+(e.message||"no result")});});};},Ue=function e(t){function n(e,t){return e>>>t|e<<32-t}for(var i,r,a=Math.pow,o=a(2,32),s="",l=[],c=8*t.length,u=e.h=e.h||[],d=e.k=e.k||[],f=d.length,p={},g=2;f<64;g++)if(!p[g]){for(i=0;i<313;i+=g)p[i]=g;u[f]=a(g,.5)*o|0,d[f++]=a(g,1/3)*o|0;}for(t+="€";t.length%64-56;)t+="\0";for(i=0;i>8)return;l[i>>2]|=r<<(3-i)%4*8;}for(l[l.length]=c/o|0,l[l.length]=c,r=0;r>>3)+m[i-7]+(n(C,17)^n(C,19)^C>>>10)|0);u=[S+((n(I,2)^n(I,13)^n(I,22))+(I&u[1]^I&u[2]^u[1]&u[2]))|0].concat(u),u[4]=u[4]+S|0;}for(i=0;i<8;i++)u[i]=u[i]+h[i]|0;}for(i=0;i<8;i++)for(r=3;r+1;r--){var D=u[i]>>8*r&255;s+=(D<16?0:"")+D.toString(16);}return s},Be=function(e,t){return "SHA-256"!==t&&"SHA256"!==t&&"sha256"!==t&&"sha-256"!==t||(e=Ue(e)),e},Ge=function(e){return String(e).trim().toLowerCase()},Ye=Ve.OptIn;j.defineGlobalNamespace(),window.adobe.OptInCategories=Ye.Categories;var qe=function(t,n,i){function r(e){var t=e;return function(e){var n=e||v.location.href;try{var i=g._extractParamFromUri(n,t);if(i)return w.parsePipeDelimetedKeyValues(i)}catch(e){}}}function a(e){function t(e,t,n){e&&e.match(re.VALID_VISITOR_ID_REGEX)&&(n===A&&(I=!0),t(e));}t(e[A],g.setMarketingCloudVisitorID,A),g._setFieldExpire(k,-1),t(e[O],g.setAnalyticsVisitorID);}function o(e){e=e||{},g._supplementalDataIDCurrent=e.supplementalDataIDCurrent||"",g._supplementalDataIDCurrentConsumed=e.supplementalDataIDCurrentConsumed||{},g._supplementalDataIDLast=e.supplementalDataIDLast||"",g._supplementalDataIDLastConsumed=e.supplementalDataIDLastConsumed||{};}function s(e){function t(e,t,n){return n=n?n+="|":n,n+=e+"="+encodeURIComponent(t)}function n(e,n){var i=n[0],r=n[1];return null!=r&&r!==T&&(e=t(i,r,e)),e}var i=e.reduce(n,"");return function(e){var t=w.getTimestampInSeconds();return e=e?e+="|":e,e+="TS="+t}(i)}function l(e){var t=e.minutesToLive,n="";return (g.idSyncDisableSyncs||g.disableIdSyncs)&&(n=n||"Error: id syncs have been disabled"),"string"==typeof e.dpid&&e.dpid.length||(n=n||"Error: config.dpid is empty"),"string"==typeof e.url&&e.url.length||(n=n||"Error: config.url is empty"),void 0===t?t=20160:(t=parseInt(t,10),(isNaN(t)||t<=0)&&(n=n||"Error: config.minutesToLive needs to be a positive number")),{error:n,ttl:t}}function c(){return !!g.configs.doesOptInApply&&!(m.optIn.isComplete&&u())}function u(){return g.configs.isIabContext?m.optIn.isApproved(m.optIn.Categories.ECID)&&C:m.optIn.isApproved(m.optIn.Categories.ECID)}function d(e,t){if(C=!0,e)throw new Error("[IAB plugin] : "+e);t.gdprApplies&&(h=t.consentString),g.init(),p();}function f(){m.optIn.isApproved(m.optIn.Categories.ECID)&&(g.configs.isIabContext?m.optIn.execute({command:"iabPlugin.fetchConsentData",callback:d}):(g.init(),p()));}function p(){m.optIn.off("complete",f);}if(!i||i.split("").reverse().join("")!==t)throw new Error("Please use `Visitor.getInstance` to instantiate Visitor.");var g=this,m=window.adobe,h="",C=!1,I=!1;g.version="4.4.0";var v=_,S=v.Visitor;S.version=g.version,S.AuthState=E.AUTH_STATE,S.OptOut=E.OPT_OUT,v.s_c_in||(v.s_c_il=[],v.s_c_in=0),g._c="Visitor",g._il=v.s_c_il,g._in=v.s_c_in,g._il[g._in]=g,v.s_c_in++,g._instanceType="regular",g._log={requests:[]},g.marketingCloudOrgID=t,g.cookieName="AMCV_"+t,g.sessionCookieName="AMCVS_"+t,g.cookieDomain=$(),g.loadSSL=v.location.protocol.toLowerCase().indexOf("https")>=0,g.loadTimeout=3e4,g.CORSErrors=[],g.marketingCloudServer=g.audienceManagerServer="dpm.demdex.net",g.sdidParamExpiry=30;var D=null,A="MCMID",y="MCIDTS",b="A",O="MCAID",M="AAM",k="MCAAMB",T="NONE",L=function(e){return !Object.prototype[e]},P=ie(g);g.FIELDS=E.FIELDS,g.cookieRead=function(e){return Q.get(e)},g.cookieWrite=function(e,t,n){var i=g.cookieLifetime?(""+g.cookieLifetime).toUpperCase():"",r=!1;return g.configs&&g.configs.secureCookie&&"https:"===location.protocol&&(r=!0),Q.set(e,""+t,{expires:n,domain:g.cookieDomain,cookieLifetime:i,secure:r})},g.resetState=function(e){e?g._mergeServerState(e):o();},g._isAllowedDone=!1,g._isAllowedFlag=!1,g.isAllowed=function(){return g._isAllowedDone||(g._isAllowedDone=!0,(g.cookieRead(g.cookieName)||g.cookieWrite(g.cookieName,"T",1))&&(g._isAllowedFlag=!0)),"T"===g.cookieRead(g.cookieName)&&g._helpers.removeCookie(g.cookieName),g._isAllowedFlag},g.setMarketingCloudVisitorID=function(e){g._setMarketingCloudFields(e);},g._use1stPartyMarketingCloudServer=!1,g.getMarketingCloudVisitorID=function(e,t){g.marketingCloudServer&&g.marketingCloudServer.indexOf(".demdex.net")<0&&(g._use1stPartyMarketingCloudServer=!0);var n=g._getAudienceManagerURLData("_setMarketingCloudFields"),i=n.url;return g._getRemoteField(A,i,e,t,n)},g.getVisitorValues=function(e,t){var n={MCMID:{fn:g.getMarketingCloudVisitorID,args:[!0],context:g},MCOPTOUT:{fn:g.isOptedOut,args:[void 0,!0],context:g},MCAID:{fn:g.getAnalyticsVisitorID,args:[!0],context:g},MCAAMLH:{fn:g.getAudienceManagerLocationHint,args:[!0],context:g},MCAAMB:{fn:g.getAudienceManagerBlob,args:[!0],context:g}},i=t&&t.length?j.pluck(n,t):n;z(i,e);},g._currentCustomerIDs={},g._customerIDsHashChanged=!1,g._newCustomerIDsHash="",g.setCustomerIDs=function(t,n){function i(){g._customerIDsHashChanged=!1;}if(!g.isOptedOut()&&t){if(!j.isObject(t)||j.isObjectEmpty(t))return !1;g._readVisitor();var r,a,o;for(r in t)if(L(r)&&(a=t[r],n=a.hasOwnProperty("hashType")?a.hashType:n,a))if("object"===e(a)){var s={};if(a.id){if(n){if(!(o=Be(Ge(a.id),n)))return;a.id=o,s.hashType=n;}s.id=a.id;}void 0!=a.authState&&(s.authState=a.authState),g._currentCustomerIDs[r]=s;}else if(n){if(!(o=Be(Ge(a),n)))return;g._currentCustomerIDs[r]={id:o,hashType:n};}else g._currentCustomerIDs[r]={id:a};var l=g.getCustomerIDs(),c=g._getField("MCCIDH"),u="";c||(c=0);for(r in l)L(r)&&(a=l[r],u+=(u?"|":"")+r+"|"+(a.id?a.id:"")+(a.authState?a.authState:""));g._newCustomerIDsHash=String(g._hash(u)),g._newCustomerIDsHash!==c&&(g._customerIDsHashChanged=!0,g._mapCustomerIDs(i));}},g.getCustomerIDs=function(){g._readVisitor();var e,t,n={};for(e in g._currentCustomerIDs)L(e)&&(t=g._currentCustomerIDs[e],n[e]||(n[e]={}),t.id&&(n[e].id=t.id),void 0!=t.authState?n[e].authState=t.authState:n[e].authState=S.AuthState.UNKNOWN,t.hashType&&(n[e].hashType=t.hashType));return n},g.setAnalyticsVisitorID=function(e){g._setAnalyticsFields(e);},g.getAnalyticsVisitorID=function(e,t,n){if(!w.isTrackingServerPopulated()&&!n)return g._callCallback(e,[""]),"";var i="";if(n||(i=g.getMarketingCloudVisitorID(function(t){g.getAnalyticsVisitorID(e,!0);})),i||n){var r=n?g.marketingCloudServer:g.trackingServer,a="";g.loadSSL&&(n?g.marketingCloudServerSecure&&(r=g.marketingCloudServerSecure):g.trackingServerSecure&&(r=g.trackingServerSecure));var o={};if(r){var s="http"+(g.loadSSL?"s":"")+"://"+r+"/id",l="d_visid_ver="+g.version+"&mcorgid="+encodeURIComponent(g.marketingCloudOrgID)+(i?"&mid="+encodeURIComponent(i):"")+(g.idSyncDisable3rdPartySyncing||g.disableThirdPartyCookies?"&d_coppa=true":""),c=["s_c_il",g._in,"_set"+(n?"MarketingCloud":"Analytics")+"Fields"];a=s+"?"+l+"&callback=s_c_il%5B"+g._in+"%5D._set"+(n?"MarketingCloud":"Analytics")+"Fields",o.corsUrl=s+"?"+l,o.callback=c;}return o.url=a,g._getRemoteField(n?A:O,a,e,t,o)}return ""},g.getAudienceManagerLocationHint=function(e,t){if(g.getMarketingCloudVisitorID(function(t){g.getAudienceManagerLocationHint(e,!0);})){var n=g._getField(O);if(!n&&w.isTrackingServerPopulated()&&(n=g.getAnalyticsVisitorID(function(t){g.getAudienceManagerLocationHint(e,!0);})),n||!w.isTrackingServerPopulated()){var i=g._getAudienceManagerURLData(),r=i.url;return g._getRemoteField("MCAAMLH",r,e,t,i)}}return ""},g.getLocationHint=g.getAudienceManagerLocationHint,g.getAudienceManagerBlob=function(e,t){if(g.getMarketingCloudVisitorID(function(t){g.getAudienceManagerBlob(e,!0);})){var n=g._getField(O);if(!n&&w.isTrackingServerPopulated()&&(n=g.getAnalyticsVisitorID(function(t){g.getAudienceManagerBlob(e,!0);})),n||!w.isTrackingServerPopulated()){var i=g._getAudienceManagerURLData(),r=i.url;return g._customerIDsHashChanged&&g._setFieldExpire(k,-1),g._getRemoteField(k,r,e,t,i)}}return ""},g._supplementalDataIDCurrent="",g._supplementalDataIDCurrentConsumed={},g._supplementalDataIDLast="",g._supplementalDataIDLastConsumed={},g.getSupplementalDataID=function(e,t){g._supplementalDataIDCurrent||t||(g._supplementalDataIDCurrent=g._generateID(1));var n=g._supplementalDataIDCurrent;return g._supplementalDataIDLast&&!g._supplementalDataIDLastConsumed[e]?(n=g._supplementalDataIDLast,g._supplementalDataIDLastConsumed[e]=!0):n&&(g._supplementalDataIDCurrentConsumed[e]&&(g._supplementalDataIDLast=g._supplementalDataIDCurrent,g._supplementalDataIDLastConsumed=g._supplementalDataIDCurrentConsumed,g._supplementalDataIDCurrent=n=t?"":g._generateID(1),g._supplementalDataIDCurrentConsumed={}),n&&(g._supplementalDataIDCurrentConsumed[e]=!0)),n};var R=!1;g._liberatedOptOut=null,g.getOptOut=function(e,t){var n=g._getAudienceManagerURLData("_setMarketingCloudFields"),i=n.url;if(u())return g._getRemoteField("MCOPTOUT",i,e,t,n);if(g._registerCallback("liberatedOptOut",e),null!==g._liberatedOptOut)return g._callAllCallbacks("liberatedOptOut",[g._liberatedOptOut]),R=!1,g._liberatedOptOut;if(R)return null;R=!0;var r="liberatedGetOptOut";return n.corsUrl=n.corsUrl.replace(/dpm\.demdex\.net\/id\?/,"dpm.demdex.net/optOutStatus?"),n.callback=[r],_[r]=function(e){if(e===Object(e)){var t,n,i=j.parseOptOut(e,t,T);t=i.optOut,n=1e3*i.d_ottl,g._liberatedOptOut=t,setTimeout(function(){g._liberatedOptOut=null;},n);}g._callAllCallbacks("liberatedOptOut",[t]),R=!1;},P.fireCORS(n),null},g.isOptedOut=function(e,t,n){t||(t=S.OptOut.GLOBAL);var i=g.getOptOut(function(n){var i=n===S.OptOut.GLOBAL||n.indexOf(t)>=0;g._callCallback(e,[i]);},n);return i?i===S.OptOut.GLOBAL||i.indexOf(t)>=0:null},g._fields=null,g._fieldsExpired=null,g._hash=function(e){var t,n,i=0;if(e)for(t=0;t0;)g._callCallback(n.shift(),t);}},g._addQuerystringParam=function(e,t,n,i){var r=encodeURIComponent(t)+"="+encodeURIComponent(n),a=w.parseHash(e),o=w.hashlessUrl(e);if(-1===o.indexOf("?"))return o+"?"+r+a;var s=o.split("?"),l=s[0]+"?",c=s[1];return l+w.addQueryParamAtLocation(c,r,i)+a},g._extractParamFromUri=function(e,t){var n=new RegExp("[\\?&#]"+t+"=([^&#]*)"),i=n.exec(e);if(i&&i.length)return decodeURIComponent(i[1])},g._parseAdobeMcFromUrl=r(re.ADOBE_MC),g._parseAdobeMcSdidFromUrl=r(re.ADOBE_MC_SDID),g._attemptToPopulateSdidFromUrl=function(e){var n=g._parseAdobeMcSdidFromUrl(e),i=1e9;n&&n.TS&&(i=w.getTimestampInSeconds()-n.TS),n&&n.SDID&&n.MCORGID===t&&ire.ADOBE_MC_TTL_IN_MIN||e.MCORGID!==t)return;a(e);}},g._mergeServerState=function(e){if(e)try{if(e=function(e){return w.isObject(e)?e:JSON.parse(e)}(e),e[g.marketingCloudOrgID]){var t=e[g.marketingCloudOrgID];!function(e){w.isObject(e)&&g.setCustomerIDs(e);}(t.customerIDs),o(t.sdid);}}catch(e){throw new Error("`serverState` has an invalid format.")}},g._timeout=null,g._loadData=function(e,t,n,i){t=g._addQuerystringParam(t,"d_fieldgroup",e,1),i.url=g._addQuerystringParam(i.url,"d_fieldgroup",e,1),i.corsUrl=g._addQuerystringParam(i.corsUrl,"d_fieldgroup",e,1),N.fieldGroupObj[e]=!0,i===Object(i)&&i.corsUrl&&"XMLHttpRequest"===P.corsMetadata.corsType&&P.fireCORS(i,n,e);},g._clearTimeout=function(e){null!=g._timeout&&g._timeout[e]&&(clearTimeout(g._timeout[e]),g._timeout[e]=0);},g._settingsDigest=0,g._getSettingsDigest=function(){if(!g._settingsDigest){var e=g.version;g.audienceManagerServer&&(e+="|"+g.audienceManagerServer),g.audienceManagerServerSecure&&(e+="|"+g.audienceManagerServerSecure),g._settingsDigest=g._hash(e);}return g._settingsDigest},g._readVisitorDone=!1,g._readVisitor=function(){if(!g._readVisitorDone){g._readVisitorDone=!0;var e,t,n,i,r,a,o=g._getSettingsDigest(),s=!1,l=g.cookieRead(g.cookieName),c=new Date;if(l||I||g.discardTrackingServerECID||(l=g.cookieRead(re.FIRST_PARTY_SERVER_COOKIE)),null==g._fields&&(g._fields={}),l&&"T"!==l)for(l=l.split("|"),l[0].match(/^[\-0-9]+$/)&&(parseInt(l[0],10)!==o&&(s=!0),l.shift()),l.length%2==1&&l.pop(),e=0;e1?(r=parseInt(t[1],10),a=t[1].indexOf("s")>0):(r=0,a=!1),s&&("MCCIDH"===n&&(i=""),r>0&&(r=c.getTime()/1e3-60)),n&&i&&(g._setField(n,i,1),r>0&&(g._fields["expire"+n]=r+(a?"s":""),(c.getTime()>=1e3*r||a&&!g.cookieRead(g.sessionCookieName))&&(g._fieldsExpired||(g._fieldsExpired={}),g._fieldsExpired[n]=!0)));!g._getField(O)&&w.isTrackingServerPopulated()&&(l=g.cookieRead("s_vi"))&&(l=l.split("|"),l.length>1&&l[0].indexOf("v1")>=0&&(i=l[1],e=i.indexOf("["),e>=0&&(i=i.substring(0,e)),i&&i.match(re.VALID_VISITOR_ID_REGEX)&&g._setField(O,i)));}},g._appendVersionTo=function(e){var t="vVersion|"+g.version,n=e?g._getCookieVersion(e):null;return n?Z.areVersionsDifferent(n,g.version)&&(e=e.replace(re.VERSION_REGEX,t)):e+=(e?"|":"")+t,e},g._writeVisitor=function(){var e,t,n=g._getSettingsDigest();for(e in g._fields)L(e)&&g._fields[e]&&"expire"!==e.substring(0,6)&&(t=g._fields[e],n+=(n?"|":"")+e+(g._fields["expire"+e]?"-"+g._fields["expire"+e]:"")+"|"+t);n=g._appendVersionTo(n),g.cookieWrite(g.cookieName,n,1);},g._getField=function(e,t){return null==g._fields||!t&&g._fieldsExpired&&g._fieldsExpired[e]?null:g._fields[e]},g._setField=function(e,t,n){null==g._fields&&(g._fields={}),g._fields[e]=t,n||g._writeVisitor();},g._getFieldList=function(e,t){var n=g._getField(e,t);return n?n.split("*"):null},g._setFieldList=function(e,t,n){g._setField(e,t?t.join("*"):"",n);},g._getFieldMap=function(e,t){var n=g._getFieldList(e,t);if(n){var i,r={};for(i=0;i0?e.substr(t):""},hashlessUrl:function(e){var t=e.indexOf("#");return t>0?e.substr(0,t):e},addQueryParamAtLocation:function(e,t,n){var i=e.split("&");return n=null!=n?n:i.length,i.splice(n,0,t),i.join("&")},isFirstPartyAnalyticsVisitorIDCall:function(e,t,n){if(e!==O)return !1;var i;return t||(t=g.trackingServer),n||(n=g.trackingServerSecure),!("string"!=typeof(i=g.loadSSL?n:t)||!i.length)&&(i.indexOf("2o7.net")<0&&i.indexOf("omtrdc.net")<0)},isObject:function(e){return Boolean(e&&e===Object(e))},removeCookie:function(e){Q.remove(e,{domain:g.cookieDomain});},isTrackingServerPopulated:function(){return !!g.trackingServer||!!g.trackingServerSecure},getTimestampInSeconds:function(){return Math.round((new Date).getTime()/1e3)},parsePipeDelimetedKeyValues:function(e){return e.split("|").reduce(function(e,t){var n=t.split("=");return e[n[0]]=decodeURIComponent(n[1]),e},{})},generateRandomString:function(e){e=e||5;for(var t="",n="abcdefghijklmnopqrstuvwxyz0123456789";e--;)t+=n[Math.floor(Math.random()*n.length)];return t},normalizeBoolean:function(e){return "true"===e||"false"!==e&&e},parseBoolean:function(e){return "true"===e||"false"!==e&&null},replaceMethodsWithFunction:function(e,t){for(var n in e)e.hasOwnProperty(n)&&"function"==typeof e[n]&&(e[n]=t);return e}};g._helpers=w;var F=ae(g,S);g._destinationPublishing=F,g.timeoutMetricsLog=[];var N={isClientSideMarketingCloudVisitorID:null,MCIDCallTimedOut:null,AnalyticsIDCallTimedOut:null,AAMIDCallTimedOut:null,fieldGroupObj:{},setState:function(e,t){switch(e){case"MC":!1===t?!0!==this.MCIDCallTimedOut&&(this.MCIDCallTimedOut=!1):this.MCIDCallTimedOut=t;break;case b:!1===t?!0!==this.AnalyticsIDCallTimedOut&&(this.AnalyticsIDCallTimedOut=!1):this.AnalyticsIDCallTimedOut=t;break;case M:!1===t?!0!==this.AAMIDCallTimedOut&&(this.AAMIDCallTimedOut=!1):this.AAMIDCallTimedOut=t;}}};g.isClientSideMarketingCloudVisitorID=function(){return N.isClientSideMarketingCloudVisitorID},g.MCIDCallTimedOut=function(){return N.MCIDCallTimedOut},g.AnalyticsIDCallTimedOut=function(){return N.AnalyticsIDCallTimedOut},g.AAMIDCallTimedOut=function(){return N.AAMIDCallTimedOut},g.idSyncGetOnPageSyncInfo=function(){return g._readVisitor(),g._getField("MCSYNCSOP")},g.idSyncByURL=function(e){if(!g.isOptedOut()){var t=l(e||{});if(t.error)return t.error;var n,i,r=e.url,a=encodeURIComponent,o=F;return r=r.replace(/^https:/,"").replace(/^http:/,""),n=j.encodeAndBuildRequest(["",e.dpid,e.dpuuid||""],","),i=["ibs",a(e.dpid),"img",a(r),t.ttl,"",n],o.addMessage(i.join("|")),o.requestToProcess(),"Successfully queued"}},g.idSyncByDataSource=function(e){if(!g.isOptedOut())return e===Object(e)&&"string"==typeof e.dpuuid&&e.dpuuid.length?(e.url="//dpm.demdex.net/ibs:dpid="+e.dpid+"&dpuuid="+e.dpuuid,g.idSyncByURL(e)):"Error: config or config.dpuuid is empty"},He(g,F),g._getCookieVersion=function(e){e=e||g.cookieRead(g.cookieName);var t=re.VERSION_REGEX.exec(e);return t&&t.length>1?t[1]:null},g._resetAmcvCookie=function(e){var t=g._getCookieVersion();t&&!Z.isLessThan(t,e)||w.removeCookie(g.cookieName);},g.setAsCoopSafe=function(){D=!0;},g.setAsCoopUnsafe=function(){D=!1;},function(){if(g.configs=Object.create(null),w.isObject(n))for(var e in n)L(e)&&(g[e]=n[e],g.configs[e]=n[e]);}(),function(){[["getMarketingCloudVisitorID"],["setCustomerIDs",void 0],["getAnalyticsVisitorID"],["getAudienceManagerLocationHint"],["getLocationHint"],["getAudienceManagerBlob"]].forEach(function(e){var t=e[0],n=2===e.length?e[1]:"",i=g[t];g[t]=function(e){return u()&&g.isAllowed()?i.apply(g,arguments):("function"==typeof e&&g._callCallback(e,[n]),n)};});}(),g.init=function(){if(c())return m.optIn.fetchPermissions(f,!0);!function(){if(w.isObject(n)){g.idSyncContainerID=g.idSyncContainerID||0,D="boolean"==typeof g.isCoopSafe?g.isCoopSafe:w.parseBoolean(g.isCoopSafe),g.resetBeforeVersion&&g._resetAmcvCookie(g.resetBeforeVersion),g._attemptToPopulateIdsFromUrl(),g._attemptToPopulateSdidFromUrl(),g._readVisitor();var e=g._getField(y),t=Math.ceil((new Date).getTime()/re.MILLIS_PER_DAY);g.idSyncDisableSyncs||g.disableIdSyncs||!F.canMakeSyncIDCall(e,t)||(g._setFieldExpire(k,-1),g._setField(y,t)),g.getMarketingCloudVisitorID(),g.getAudienceManagerLocationHint(),g.getAudienceManagerBlob(),g._mergeServerState(g.serverState);}else g._attemptToPopulateIdsFromUrl(),g._attemptToPopulateSdidFromUrl();}(),function(){if(!g.idSyncDisableSyncs&&!g.disableIdSyncs){F.checkDPIframeSrc();var e=function(){var e=F;e.readyToAttachIframe()&&e.attachIframe();};v.addEventListener("load",function(){S.windowLoaded=!0,e();});try{te.receiveMessage(function(e){F.receiveMessage(e.data);},F.iframeHost);}catch(e){}}}(),function(){g.whitelistIframeDomains&&re.POST_MESSAGE_ENABLED&&(g.whitelistIframeDomains=g.whitelistIframeDomains instanceof Array?g.whitelistIframeDomains:[g.whitelistIframeDomains],g.whitelistIframeDomains.forEach(function(e){var n=new B(t,e),i=K(g,n);te.receiveMessage(i,e);}));}();};};qe.config=se,_.Visitor=qe;var Xe=qe,We=function(e){if(j.isObject(e))return Object.keys(e).filter(function(t){return ""!==e[t]}).reduce(function(t,n){var i="doesOptInApply"!==n?e[n]:se.normalizeConfig(e[n]),r=j.normalizeBoolean(i);return t[n]=r,t},Object.create(null))},Je=Ve.OptIn,Ke=Ve.IabPlugin;return Xe.getInstance=function(e,t){if(!e)throw new Error("Visitor requires Adobe Marketing Cloud Org ID.");e.indexOf("@")<0&&(e+="@AdobeOrg");var n=function(){var t=_.s_c_il;if(t)for(var n=0;na.indexOf(b)?a:a.split(b).join(d)};a.escape=function(c){var b,d;if(!c)return c;c=encodeURIComponent(c);for(b=0;7>b;b++)d="+~!*()'".substring(b,b+1),0<=c.indexOf(d)&&(c=a.replace(c,d,"%"+d.charCodeAt(0).toString(16).toUpperCase()));return c};a.unescape=function(c){if(!c)return c;c=0<=c.indexOf("+")?a.replace(c,"+"," "):c;try{return decodeURIComponent(c)}catch(b){}return unescape(c)};a.Mb=function(){var c=h.location.hostname,b=a.fpCookieDomainPeriods,d;b||(b=a.cookieDomainPeriods); + if(c&&!a.Ja&&!/^[0-9.]+$/.test(c)&&(b=b?parseInt(b):2,b=2d?"":a.unescape(b.substring(d+2+c.length,0>f?b.length:f));return "[[B]]"!=c?c:""};a.c_w=a.cookieWrite=function(c,b,d){var f=a.Mb(),e=a.cookieLifetime,g;b=""+b;e=e?(""+e).toUpperCase():"";d&&"SESSION"!=e&&"NONE"!= + e&&((g=""!=b?parseInt(e?e:0):-60)?(d=new Date,d.setTime(d.getTime()+1E3*g)):1===d&&(d=new Date,g=d.getYear(),d.setYear(g+2+(1900>g?1900:0))));return c&&"NONE"!=e?(a.d.cookie=a.escape(c)+"="+a.escape(""!=b?b:"[[B]]")+"; path=/;"+(d&&"SESSION"!=e?" expires="+d.toUTCString()+";":"")+(f?" domain="+f+";":"")+(a.writeSecureCookies?" secure;":""),a.cookieRead(c)==b):0};a.Jb=function(){var c=a.Util.getIeVersion();"number"===typeof c&&10>c&&(a.unsupportedBrowser=!0,a.wb(a,function(){}));};a.xa=function(){var a= + navigator.userAgent;return "Microsoft Internet Explorer"===navigator.appName||0<=a.indexOf("MSIE ")||0<=a.indexOf("Trident/")&&0<=a.indexOf("Windows NT 6")?!0:!1};a.wb=function(a,b){for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&"function"===typeof a[d]&&(a[d]=b);};a.K=[];a.ea=function(c,b,d){if(a.Ka)return 0;a.maxDelay||(a.maxDelay=250);var f=0,e=(new Date).getTime()+a.maxDelay,g=a.d.visibilityState,k=["webkitvisibilitychange","visibilitychange"];g||(g=a.d.webkitVisibilityState);if(g&&"prerender"== + g){if(!a.fa)for(a.fa=1,d=0;dc){a.K.unshift(d);setTimeout(a.delayReady,parseInt(a.maxDelay/2));break}a.Ka=1;a[d.m].apply(a, + d.a);a.Ka=0;}};a.setAccount=a.sa=function(c){var b,d;if(!a.ea("setAccount",arguments))if(a.account=c,a.allAccounts)for(b=a.allAccounts.concat(c.split(",")),a.allAccounts=[],b.sort(),d=0;de.indexOf(".contextData."))switch(h=k.substring(0,4),n=k.substring(4),k){case "transactionID":k="xact";break;case "channel":k="ch";break;case "campaign":k="v0";break;default:a.Qa(n)&&("prop"==h?k="c"+n:"eVar"==h?k="v"+n:"list"== + h?k="l"+n:"hier"==h&&(k="h"+n,l=l.substring(0,255)));}g+="&"+a.escape(k)+"="+a.escape(l);}}""!=g&&(g+="&."+c);}return g};a.usePostbacks=0;a.Pb=function(){var c="",b,d,f,e,g,k,l,h,n="",m="",p=e="",r=a.T();if(a.lightProfileID)b=a.O,(n=a.lightTrackVars)&&(n=","+n+","+a.ka.join(",")+",");else{b=a.g;if(a.pe||a.linkType)n=a.linkTrackVars,m=a.linkTrackEvents,a.pe&&(e=a.pe.substring(0,1).toUpperCase()+a.pe.substring(1),a[e]&&(n=a[e].cc,m=a[e].bc));n&&(n=","+n+","+a.F.join(",")+",");m&&(m=","+m+",",n&&(n+=",events,")); + a.events2&&(p+=(""!=p?",":"")+a.events2);}if(r&&r.getCustomerIDs){e=q;if(g=r.getCustomerIDs())for(d in g)Object.prototype[d]||(f=g[d],"object"==typeof f&&(e||(e={}),f.id&&(e[d+".id"]=f.id),f.authState&&(e[d+".as"]=f.authState)));e&&(c+=a.o("cid",e));}a.AudienceManagement&&a.AudienceManagement.isReady()&&(c+=a.o("d",a.AudienceManagement.getEventCallConfigParams()));for(d=0;df||0<=e&&f>e||0<=g&&f>g)&&(e=a.protocol&&1f?0:f)+"/":"")+d);return d};a.L=function(c){var b=a.B(c),d,f,e="",g=0;return b&&(d=c.protocol,f=c.onclick,!c.href||"A"!=b&&"AREA"!=b||f&&d&&!(0>d.toLowerCase().indexOf("javascript"))?f?(e=a.replace(a.replace(a.replace(a.replace(""+f,"\r",""),"\n",""),"\t","")," ",""),g=2):"INPUT"==b||"SUBMIT"==b?(c.value?e=c.value:c.innerText?e=c.innerText:c.textContent&&(e=c.textContent),g=3):"IMAGE"==b&&c.src&&(e=c.src):e=a.Ma(c),e)?{id:e.substring(0,100),type:g}:0};a.ic=function(c){for(var b=a.B(c),d=a.L(c);c&& + !d&&"BODY"!=b;)if(c=c.parentElement?c.parentElement:c.parentNode)b=a.B(c),d=a.L(c);d&&"BODY"!=b||(c=0);c&&(b=c.onclick?""+c.onclick:"",0<=b.indexOf(".tl(")||0<=b.indexOf(".trackLink("))&&(c=0);return c};a.Xb=function(){var c,b,d=a.linkObject,f=a.linkType,e=a.linkURL,g,k;a.la=1;d||(a.la=0,d=a.clickObject);if(d){c=a.B(d);for(b=a.L(d);d&&!b&&"BODY"!=c;)if(d=d.parentElement?d.parentElement:d.parentNode)c=a.B(d),b=a.L(d);b&&"BODY"!=c||(d=0);if(d&&!a.linkObject){var l=d.onclick?""+d.onclick:"";if(0<=l.indexOf(".tl(")|| + 0<=l.indexOf(".trackLink("))d=0;}}else a.la=1;!e&&d&&(e=a.Ma(d));e&&!a.linkLeaveQueryString&&(g=e.indexOf("?"),0<=g&&(e=e.substring(0,g)));if(!f&&e){var m=0,n=0,p;if(a.trackDownloadLinks&&a.linkDownloadFileTypes)for(l=e.toLowerCase(),g=l.indexOf("?"),k=l.indexOf("#"),0<=g?0<=k&&kb)return 0}return 1};a.S=function(c,b){var d,f,e,g,k,h,m;m={};for(d=0;2>d;d++)for(f=0b;b++)for(d=0c.indexOf("-")){for(c=0;16>c;c++)f= + Math.floor(Math.random()*f),b+="0123456789ABCDEF".substring(f,f+1),f=Math.floor(Math.random()*e),d+="0123456789ABCDEF".substring(f,f+1),f=e=16;c=b+"-"+d;}a.cookieWrite("s_fid",c,1)||(c=0);return c};a.Ea=function(c){var b=new Date,d="s"+Math.floor(b.getTime()/108E5)%10+Math.floor(1E13*Math.random()),f=b.getYear(),f="t="+a.escape(b.getDate()+"/"+b.getMonth()+"/"+(1900>f?f+1900:f)+" "+b.getHours()+":"+b.getMinutes()+":"+b.getSeconds()+" "+b.getDay()+" "+b.getTimezoneOffset()),e=a.T(),g;c&&(g=a.S(c,1)); + a.Ub()&&!a.visitorOptedOut&&(a.wa()||(a.fid=a.Nb()),a.Xb(),a.usePlugins&&a.doPlugins&&a.doPlugins(a),a.account&&(a.abort||(a.trackOffline&&!a.timestamp&&(a.timestamp=Math.floor(b.getTime()/1E3)),c=h.location,a.pageURL||(a.pageURL=c.href?c.href:c),a.referrer||a.Za||(c=a.Util.getQueryParam("adobe_mc_ref",null,null,!0),a.referrer=c||void 0===c?void 0===c?"":c:p.document.referrer),a.Za=1,a.referrer=a.Lb(a.referrer),a.u("_g")),a.Qb()&&!a.abort&&(e&&a.V("TARGET")&&!a.supplementalDataID&&e.getSupplementalDataID&& + (a.supplementalDataID=e.getSupplementalDataID("AppMeasurement:"+a._in,a.expectSupplementalData?!1:!0)),a.V("AAM")||(a.contextData["cm.ssf"]=1),a.Rb(),a.vb(),f+=a.Pb(),a.rb(d,f),a.u("_t"),a.referrer="")));a.Ca();g&&a.S(g,1);};a.t=a.track=function(c,b){b&&a.S(b);a.Y=!0;a.isReadyToTrack()?null!=a.j&&0a.N&&a.Va(a.i),a.qa(500);else{var c=a.Eb();if(0=a.offlineThrottleDelay)return 0;c=a.A()-a.Ta;return a.offlineThrottleDelaya.N&&a.Va(a.i);a.ca();a.qa(500);};b.onreadystatechange=function(){4==b.readyState&&(200== + b.status?b.R():b.ga());};a.Ta=a.A();if(1===d)b.send(c);else if(2===d)f=c.indexOf("?"),d=c.substring(0,f),f=c.substring(f+1),f=f.replace(/&callback=[a-zA-Z0-9_.\[\]]+/,""),b.open("POST",d,!0),b.withCredentials=!0,b.send(f);else if(b.src=c,3===d){if(a.Ra)try{f.removeChild(a.Ra);}catch(e){}f.firstChild?f.insertBefore(b,f.firstChild):f.appendChild(b);a.Ra=a.v;}b.D=setTimeout(function(){b.D&&(b.complete?b.R():(a.trackOffline&&b.abort&&b.abort(),b.ga()));},5E3);a.Hb=c;a.v=h["s_i_"+a.replace(a.account,",","_")]= + b;if(a.useForcedLinkTracking&&a.J||a.bodyClickFunction)a.forcedLinkTrackingTimeout||(a.forcedLinkTrackingTimeout=250),a.da=setTimeout(a.ca,a.forcedLinkTrackingTimeout);};a.mb=function(c){var b=!1;navigator.sendBeacon&&(a.ob(c)?b=!0:a.useBeacon&&(b=!0));a.xb(c)&&(b=!1);return b};a.ob=function(a){return a&&0a.N))try{h.localStorage.removeItem(a.ma()),a.Sa=a.A();}catch(c){}};a.Va=function(c){if(a.oa()){a.Xa();try{h.localStorage.setItem(a.ma(),h.JSON.stringify(c)),a.N=a.A();}catch(b){}}};a.Xa=function(){if(a.trackOffline){if(!a.offlineLimit||0>=a.offlineLimit)a.offlineLimit=10;for(;a.i.length>a.offlineLimit;)a.La();}};a.forceOffline=function(){a.na=!0;};a.forceOnline=function(){a.na=!1;};a.ma=function(){return a.offlineFilename+"-"+a.visitorNamespace+a.account};a.A=function(){return (new Date).getTime()}; + a.Pa=function(a){a=a.toLowerCase();return 0!=a.indexOf("#")&&0!=a.indexOf("about:")&&0!=a.indexOf("opera:")&&0!=a.indexOf("javascript:")?!0:!1};a.setTagContainer=function(c){var b,d,f;a.$b=c;for(b=0;b(""+f[b]).indexOf("s_c_il"))&&(c[b]=f[b]);if(d.mmq)for(b= + 0;be)return g;b=d+b.substring(e+1)+d;if(!f||!(0<=b.indexOf(d+c+d)||0<=b.indexOf(d+ + c+"="+d))){e=b.indexOf("#");0<=e&&(b=b.substr(0,e)+d);e=b.indexOf(d+c+"=");if(0>e)return g;b=b.substring(e+d.length+c.length+1);e=b.indexOf(d);0<=e&&(b=b.substring(0,e));0=m;m++)76>m&&(a.g.push("prop"+m),a.O.push("prop"+m)),a.g.push("eVar"+m),a.O.push("eVar"+m),6>m&&a.g.push("hier"+m),4>m&&a.g.push("list"+m);m="pe pev1 pev2 pev3 latitude longitude resolution colorDepth javascriptVersion javaEnabled cookiesEnabled browserWidth browserHeight connectionType homepage pageURLRest marketingCloudOrgID ms_a".split(" ");a.g=a.g.concat(m);a.F=a.F.concat(m);a.ssl=0<=h.location.protocol.toLowerCase().indexOf("https");a.charSet="UTF-8";a.contextData={};a.writeSecureCookies= + !1;a.offlineThrottleDelay=0;a.offlineFilename="AppMeasurement.offline";a.P="s_sq";a.Ta=0;a.ia=0;a.N=0;a.Sa=0;a.linkDownloadFileTypes="exe,zip,wav,mp3,mov,mpg,avi,wmv,pdf,doc,docx,xls,xlsx,ppt,pptx";a.w=h;a.d=h.document;a.ca=function(){a.da&&(h.clearTimeout(a.da),a.da=q);a.bodyClickTarget&&a.J&&a.bodyClickTarget.dispatchEvent(a.J);a.bodyClickFunction&&("function"==typeof a.bodyClickFunction?a.bodyClickFunction():a.bodyClickTarget&&a.bodyClickTarget.href&&(a.d.location=a.bodyClickTarget.href));a.bodyClickTarget= + a.J=a.bodyClickFunction=0;};a.Wa=function(){a.b=a.d.body;a.b?(a.r=function(c){var b,d,f,e,g;if(!(a.d&&a.d.getElementById("cppXYctnr")||c&&c["s_fe_"+a._in])){if(a.Ha)if(a.useForcedLinkTracking)a.b.removeEventListener("click",a.r,!1);else{a.b.removeEventListener("click",a.r,!0);a.Ha=a.useForcedLinkTracking=0;return}else a.useForcedLinkTracking=0;a.clickObject=c.srcElement?c.srcElement:c.target;try{if(!a.clickObject||a.M&&a.M==a.clickObject||!(a.clickObject.tagName||a.clickObject.parentElement||a.clickObject.parentNode))a.clickObject= + 0;else{var k=a.M=a.clickObject;a.ha&&(clearTimeout(a.ha),a.ha=0);a.ha=setTimeout(function(){a.M==k&&(a.M=0);},1E4);f=a.Na();a.track();if(f 0) { + setMCIDOnIntegrationAttributes(mcID); + } + + return true; + } catch (e) { + return 'error initializing adobe: ' + e; + } + } + + function setMarketingCloudId(mcid) { + setMCIDOnIntegrationAttributes(mcid); + } + + function setMCIDOnIntegrationAttributes(mcid) { + var adobeIntegrationAttributes = {}; + adobeIntegrationAttributes[MARKETINGCLOUDIDKEY] = mcid; + mParticle.setIntegrationAttribute( + ADOBEMODULENUMBER, + adobeIntegrationAttributes + ); + mParticle._setIntegrationDelay(ADOBEMODULENUMBER, false); + } + + // Get the mapped value for custom events + function getEventMappingValue(event) { + var jsHash = calculateJSHash( + event.EventDataType, + event.EventCategory, + event.EventName + ); + return findValueInMapping(jsHash, eventsMapping); + } + + function calculateJSHash(eventDataType, eventCategory, name) { + var preHash = + '' + eventDataType + ('' + eventCategory) + '' + (name || ''); + + return mParticle.generateHash(preHash); + } + + function findValueInMapping(jsHash, mapping) { + if (mapping) { + var filteredArray = mapping.filter(function(mappingEntry) { + if ( + mappingEntry.jsmap && + mappingEntry.maptype && + mappingEntry.value + ) { + return mappingEntry.jsmap === jsHash.toString(); + } + + return { + result: false, + }; + }); + + if (filteredArray && filteredArray.length > 0) { + return { + result: true, + matches: filteredArray, + }; + } + } + return null; + } + + // for each type of event, we run setMappings which sets the eVars, props, hvars, and contextData values + // after each event is sent to the server (either using t() for pageViews or tl() for non-pageview events), clearVars() is run to wipe out + function resetVariables() { + appMeasurement.clearVars(); + appMeasurement.contextData = {}; + } + // any eVars, props, and hvars + function processEvent(event) { + var linkName, + pageName, + reportEvent = false, + linkTrackVars = []; + + appMeasurement.timestamp = timestampOption + ? Math.floor(new Date().getTime() / 1000) + : null; + appMeasurement.events = ''; + if (event.CustomFlags && event.CustomFlags.hasOwnProperty(LINK_NAME)) { + linkName = event.CustomFlags[LINK_NAME]; + } + if (event.CustomFlags && event.CustomFlags.hasOwnProperty(PAGE_NAME)) { + pageName = event.CustomFlags[PAGE_NAME]; + } + + if (isAdobeClientKitInitialized) { + try { + // First determine if an eventName is mapped, if so, log it as an event as opposed to a pageview or commerceview + // ex. If a pageview is mapped to an event, we logEvent instead of logging it as a pageview + var eventMapping = getEventMappingValue(event); + + if ( + eventMapping && + eventMapping.result && + eventMapping.matches + ) { + setMappings(event, true, linkTrackVars); + reportEvent = logEvent( + event, + linkTrackVars, + eventMapping.matches, + linkName, + pageName + ); + } else if (event.EventDataType === MessageType$1.PageView) { + setMappings(event, false); + reportEvent = logPageView(event, pageName); + } else if (event.EventDataType === MessageType$1.Commerce) { + setMappings(event, true, linkTrackVars); + reportEvent = processCommerceTransaction( + event, + linkTrackVars, + linkName, + pageName + ); + } else if (event.EventDataType === MessageType$1.Media) { + self.adobeMediaSDK.process(event); + } else { + return 'event name not mapped, aborting event logging'; + } + + if ( + reportEvent === true && + reportingService && + event.EventDataType + ) { + reportingService(self, event); + return 'Successfully sent to ' + name; + } + } catch (e) { + return 'Failed to send to: ' + name + ' ' + e; + } + } + + return 'Cannot send to forwarder ' + name + ', not initialized.'; + } + + function setMappings(event, includeTrackVars, linkTrackVars) { + if (includeTrackVars) { + setEvars(event, linkTrackVars); + setProps(event, linkTrackVars); + setHiers(event, linkTrackVars); + setContextData(event, linkTrackVars); + } else { + setEvars(event); + setProps(event); + setHiers(event); + setContextData(event); + } + } + + function processCommerceTransaction( + event, + linkTrackVars, + linkName, + pageName + ) { + if ( + event.EventCategory === mParticle.CommerceEventType.ProductPurchase + ) { + appMeasurement.events = 'purchase'; + appMeasurement.purchaseID = event.ProductAction.TransactionId; + appMeasurement.transactionID = event.ProductAction.TransactionId; + linkTrackVars.push('purchaseID', 'transactionID'); + } else if ( + event.EventCategory === + mParticle.CommerceEventType.ProductViewDetail + ) { + appMeasurement.events = 'prodView'; + } else if ( + event.EventCategory === mParticle.CommerceEventType.ProductAddToCart + ) { + appMeasurement.events = 'scAdd'; + } else if ( + event.EventCategory === + mParticle.CommerceEventType.ProductRemoveFromCart + ) { + appMeasurement.events = 'scRemove'; + } else if ( + event.EventCategory === mParticle.CommerceEventType.ProductCheckout + ) { + appMeasurement.events = 'scCheckout'; + } + appMeasurement.linkTrackEvents = appMeasurement.events || null; + processProductsAndSetEvents(event); + + linkTrackVars.push('products', 'events'); + setPageName(linkTrackVars, appMeasurement, pageName); + appMeasurement.linkTrackVars = linkTrackVars; + appMeasurement.tl(true, 'o', linkName); + + resetVariables(); + + return true; + } + + function processProductsAndSetEvents(event) { + try { + var productDetails, + incrementor, + merchandising, + productBuilder, + product, + allProducts = []; + + var expandedEvents = mParticle.eCommerce.expandCommerceEvent(event); + expandedEvents.forEach(function(expandedEvt) { + productBuilder = []; + productDetails = []; + incrementor = []; + merchandising = []; + + if (expandedEvt.EventName === 'eCommerce - purchase - Total') { + for (var eventAttributeKey in expandedEvt.EventAttributes) { + if ( + expandedEvt.EventAttributes.hasOwnProperty( + eventAttributeKey + ) + ) { + var jsHash = calculateJSHash( + event.EventDataType, + event.EventCategory, + eventAttributeKey + ); + var mapping = findValueInMapping( + jsHash, + eventsMapping + ); + if (mapping && mapping.result && mapping.matches) { + mapping.matches.forEach(function(mapping) { + if (mapping.value) { + if ( + appMeasurement.events.indexOf( + mapping.value + ) < 0 + ) { + appMeasurement.events += + ',' + + mapping.value + + '=' + + expandedEvt.EventAttributes[ + eventAttributeKey + ]; + } + } + }); + } + } + } + } else { + var productAttributes = expandedEvt.EventAttributes; + productDetails.push( + productAttributes.Category || '', + productAttributes.Name, + productAttributes.Id, + productAttributes.Quantity || 1, + productAttributes['Item Price'] || 0 + ); + for (var productAttributeKey in expandedEvt.EventAttributes) { + if ( + expandedEvt.EventAttributes.hasOwnProperty( + productAttributeKey + ) + ) { + productIncrementorMapping.forEach(function( + productIncrementorMap + ) { + if ( + productIncrementorMap.map === + productAttributeKey + ) { + incrementor.push( + productIncrementorMap.value + + '=' + + productAttributes[ + productAttributeKey + ] + ); + if ( + appMeasurement.events.indexOf( + productIncrementorMap.value + ) < 0 + ) { + appMeasurement.events += + ',' + productIncrementorMap.value; + } + } + }); + productMerchandisingMapping.forEach(function( + productMerchandisingMap + ) { + if ( + productMerchandisingMap.map === + productAttributeKey + ) { + merchandising.push( + productMerchandisingMap.value + + '=' + + productAttributes[ + productAttributeKey + ] + ); + } + }); + } + } + productBuilder.push( + productDetails.join(';'), + incrementor.join('|'), + merchandising.join('|') + ); + product = productBuilder.join(';'); + allProducts.push(product); + } + }); + + appMeasurement.products = allProducts.join(','); + } catch (e) { + window.console.log(e); + } + } + + function logPageView(event, pageName) { + try { + appMeasurement.pageName = + pageName || event.EventName || window.document.title; + appMeasurement.t(); + resetVariables(); + return true; + } catch (e) { + resetVariables(); + return { error: 'logPageView not called, error ' + e }; + } + } + + function logEvent( + event, + linkTrackVars, + mappingMatches, + linkName, + pageName + ) { + try { + if (mappingMatches) { + mappingMatches.forEach(function(match) { + if (appMeasurement.events.length === 0) { + appMeasurement.events += match.value; + } else { + appMeasurement.events += ',' + match.value; + } + }); + appMeasurement.linkTrackEvents = appMeasurement.events; + + linkTrackVars.push('events'); + setPageName(linkTrackVars, appMeasurement, pageName); + + appMeasurement.linkTrackVars = linkTrackVars; + + appMeasurement.tl(true, 'o', linkName); + resetVariables(); + return true; + } else { + resetVariables(); + window.console.log( + 'event name not mapped, aborting event logging' + ); + return false; + } + } catch (e) { + resetVariables(); + return { error: e }; + } + } + + // .map is the attribute passed through, .value is the eVar value + function setEvars(event, linkTrackVars) { + var eventAttributes = event.EventAttributes; + for (var eventAttributeKey in eventAttributes) { + if (eventAttributes.hasOwnProperty(eventAttributeKey)) { + eVarsMapping.forEach(function(eVarMap) { + if (eVarMap.map === eventAttributeKey) { + appMeasurement[eVarMap.value] = + eventAttributes[eventAttributeKey]; + if (linkTrackVars) { + linkTrackVars.push(eVarMap.value); + } + } + if (event.EventName === eVarMap.map) { + appMeasurement[eVarMap.value] = event.EventName; + } + }); + } + } + } + + // .map is the attribute passed through, .value is the prop value + function setProps(event, linkTrackVars) { + var eventAttributes = event.EventAttributes; + for (var eventAttributeKey in eventAttributes) { + if (eventAttributes.hasOwnProperty(eventAttributeKey)) { + propsMapping.forEach(function(propMap) { + if (propMap.map === eventAttributeKey) { + appMeasurement[propMap.value] = + eventAttributes[eventAttributeKey]; + if (linkTrackVars) { + linkTrackVars.push(propMap.value); + } + } + }); + } + } + } + + // .map is the attribute passed through, .value is the hier value + function setHiers(event, linkTrackVars) { + var eventAttributes = event.EventAttributes; + for (var eventAttributeKey in eventAttributes) { + if (eventAttributes.hasOwnProperty(eventAttributeKey)) { + var jsHash = calculateJSHash( + event.EventDataType, + event.EventCategory, + eventAttributeKey + ); + var mapping = findValueInMapping(jsHash, hiersMapping); + if (mapping && mapping.result && mapping.matches) { + mapping.matches.forEach(function(mapping) { + if (mapping.value) { + appMeasurement[mapping.value] = + eventAttributes[eventAttributeKey]; + if (linkTrackVars) { + linkTrackVars.push(mapping.value); + } + } + }); + } + } + } + } + + // .map is the attribute passed through, .value is the contextData value + function setContextData(event, linkTrackVars) { + var eventAttributes = event.EventAttributes; + for (var eventAttributeKey in eventAttributes) { + if (eventAttributes.hasOwnProperty(eventAttributeKey)) { + contextVariableMapping.forEach(function(contextVariableMap) { + if (contextVariableMap.map === eventAttributeKey) { + appMeasurement.contextData[contextVariableMap.value] = + eventAttributes[eventAttributeKey]; + if (linkTrackVars) { + linkTrackVars.push( + 'contextData.' + contextVariableMap.value + ); + } + } + }); + } + } + } + + function onUserIdentified(mpUserObject) { + if (isAdobeClientKitInitialized) { + var userIdentities = mpUserObject.getUserIdentities() + .userIdentities; + + var identitiesToSet = {}; + if (Object.keys(userIdentities).length) { + for (var identity in userIdentities) { + identitiesToSet[identity] = { + id: userIdentities[identity], + }; + } + } else { + // no user identities means there was a logout, so set all current customer ids to null + var currentAdobeCustomerIds = appMeasurement.visitor.getCustomerIDs(); + for (var currentIdentityKey in currentAdobeCustomerIds) { + identitiesToSet[currentIdentityKey] = null; + } + } + + try { + appMeasurement.visitor.setCustomerIDs(identitiesToSet); + } catch (e) { + return 'Error calling setCustomerIDs on adobe'; + } + } else { + return ( + 'Cannot call setUserIdentity on forwarder ' + + name + + ', not initialized' + ); + } + } + + function setPageName(linkTrackVars, appMeasurement, pageName) { + if (settings.enablePageName === 'True') { + appMeasurement.pageName = pageName || window.document.title; + linkTrackVars.push('pageName'); + } + } + + this.init = initForwarder; + this.onUserIdentified = onUserIdentified; + this.process = processEvent; + }; + + function getId() { + return moduleId; + } + + if (window && window.mParticle && window.mParticle.addForwarder) { + window.mParticle.addForwarder({ + name: name, + constructor: constructor$1, + getId: getId, + }); + } + + function register(config) { + if (!config) { + window.console.log( + 'You must pass a config object to register the kit ' + name + ); + return; + } + + if (!isObject(config)) { + window.console.log( + '`config` must be an object. You passed in a ' + typeof config + ); + return; + } + + if (isObject(config.kits)) { + config.kits[name] = { + constructor: constructor$1, + }; + } else { + config.kits = {}; + config.kits[name] = { + constructor: constructor$1, + }; + } + window.console.log( + 'Successfully registered ' + name + ' to your mParticle configuration' + ); + } + + function isObject(val) { + return ( + val != null && typeof val === 'object' && Array.isArray(val) === false + ); + } + + var AdobeClientSideKit_esm = { + register: register, + }; + + return AdobeClientSideKit_esm; + +}()); diff --git a/kits/adobe/packages/AdobeServer/dist/AdobeServerSideKit.common.js b/kits/adobe/packages/AdobeServer/dist/AdobeServerSideKit.common.js new file mode 100644 index 000000000..dea162211 --- /dev/null +++ b/kits/adobe/packages/AdobeServer/dist/AdobeServerSideKit.common.js @@ -0,0 +1,778 @@ +function Common() { + this.playheadPosition = 0; + this.startupTime = 0; + this.droppedFrames = 0; + this.bitRate = 0; + this.fps = 0; +} + +var common = Common; + +var MediaEventType = { + Play: 23, + Pause: 24, + ContentEnd: 25, + SessionStart: 30, + SessionEnd: 31, + SeekStart: 32, + SeekEnd: 33, + BufferStart: 34, + BufferEnd: 35, + UpdatePlayheadPosition: 36, + AdClick: 37, + AdBreakStart: 38, + AdBreakEnd: 39, + AdStart: 40, + AdEnd: 41, + AdSkip: 42, + SegmentStart: 43, + SegmentEnd: 44, + SegmentSkip: 45, + UpdateQoS: 46, +}; + +var ContentType = { + Audio: 'Audio', + Video: 'Video', +}; + +var StreamType = { + LiveStream: 'LiveStream', + OnDemand: 'OnDemand', + Linear: 'Linear', + Podcast: 'Podcast', + Audiobook: 'Audiobook', +}; + +function EventHandler(common) { + this.common = common || {}; +} +EventHandler.prototype.logEvent = function(event) { + var customAttributes = {}; + if (event && event.EventAttributes) { + customAttributes = event.EventAttributes; + } + + if (event && event.PlayheadPosition) { + this.common.playheadPosition = event.PlayheadPosition / 1000; + } + + switch (event.EventCategory) { + case MediaEventType.AdBreakStart: + var adBreakObject = this.common.MediaHeartbeat.createAdBreakObject( + event.AdBreak.title, + event.AdBreak.placement || 0, // TODO: Ad Break Object doesn't support placement yet + this.common.playheadPosition + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdBreakStart, + adBreakObject, + customAttributes + ); + break; + case MediaEventType.AdBreakEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdBreakComplete, + {}, + customAttributes + ); + break; + case MediaEventType.AdStart: + var adObject = this.common.MediaHeartbeat.createAdObject( + event.AdContent.title, + event.AdContent.id, + event.AdContent.position, + event.AdContent.duration / 1000 + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdStart, + adObject, + customAttributes + ); + break; + case MediaEventType.AdEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdComplete, + {}, + customAttributes + ); + break; + case MediaEventType.AdSkip: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdSkip, + {}, + customAttributes + ); + break; + case MediaEventType.AdClick: + // This is not supported in Adobe Heartbeat + console.warn('Ad Click is not a supported Adobe Heartbeat Event'); + break; + case MediaEventType.BufferStart: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.BufferStart, + {}, + customAttributes + ); + break; + case MediaEventType.BufferEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.BufferComplete, + {}, + customAttributes + ); + break; + case MediaEventType.ContentEnd: + this.common.mediaHeartbeat.trackComplete(); + break; + case MediaEventType.SessionStart: + var streamType = getStreamType( + event.StreamType, + event.ContentType, + this.common.MediaHeartbeat.StreamType + ); + + var adobeMediaObject = this.common.MediaHeartbeat.createMediaObject( + event.ContentTitle, + event.ContentId, + event.Duration / 1000, + streamType, + event.ContentType + ); + + var combinedAttributes = getAdobeMetadataKeys( + customAttributes, + this.common.MediaHeartbeat + ); + + this.common.mediaHeartbeat.trackSessionStart( + adobeMediaObject, + combinedAttributes + ); + break; + + case MediaEventType.SessionEnd: + this.common.mediaHeartbeat.trackSessionEnd(); + break; + case MediaEventType.Play: + this.common.mediaHeartbeat.trackPlay(); + break; + case MediaEventType.Pause: + this.common.mediaHeartbeat.trackPause(); + break; + case MediaEventType.UpdatePlayheadPosition: + // This is commented out because we're updating playhead position + // for all events and Adobe does not have a relevant playhead + // update position function + break; + case MediaEventType.SeekStart: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.SeekStart, + {}, + customAttributes + ); + break; + case MediaEventType.SeekEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.SeekComplete, + {}, + customAttributes + ); + break; + case MediaEventType.SegmentStart: + var chapterObject = this.common.MediaHeartbeat.createChapterObject( + event.Segment.title, + event.Segment.index, + event.Segment.duration / 1000, + this.common.playheadPosition + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.ChapterStart, + chapterObject, + customAttributes + ); + break; + case MediaEventType.SegmentEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.ChapterComplete, + {}, + customAttributes + ); + break; + case MediaEventType.SegmentSkip: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.ChapterSkip, + {}, + customAttributes + ); + break; + case MediaEventType.UpdateQoS: + this.common.startupTime = event.QoS.startupTime / 1000; + this.common.droppedFrames = event.QoS.droppedFrames; + this.common.bitRate = event.QoS.bitRate; + this.common.fps = event.QoS.fps; + + var qosObject = this.common.MediaHeartbeat.createQoSObject( + this.common.bitRate, + this.common.startupTime, + this.common.fps, + this.common.droppedFrames + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.BitrateChange, + qosObject, + customAttributes + ); + break; + default: + console.error('Unknown Event Type', event); + return false; + } +}; + +var getAdobeMetadataKeys = function(attributes, Heartbeat) { + var AdobeMetadataLookupTable = { + // Ad Meta Data + ad_content_advertiser: Heartbeat.AdMetadataKeys.ADVERTISER, + ad_content_campaign: Heartbeat.AdMetadataKeys.CAMPAIGN_ID, + ad_content_creative: Heartbeat.AdMetadataKeys.CREATIVE_ID, + ad_content_placement: Heartbeat.AdMetadataKeys.PLACEMENT_ID, + ad_content_site_id: Heartbeat.AdMetadataKeys.SITE_ID, + ad_content_creative_url: Heartbeat.AdMetadataKeys.CREATIVE_URL, + + // Audio Meta + content_artist: Heartbeat.AudioMetadataKeys.ARTIST, + content_album: Heartbeat.AudioMetadataKeys.ALBUM, + content_label: Heartbeat.AudioMetadataKeys.LABEL, + content_author: Heartbeat.AudioMetadataKeys.AUTHOR, + content_station: Heartbeat.AudioMetadataKeys.STATION, + content_publisher: Heartbeat.AudioMetadataKeys.PUBLISHER, + + // Video Meta + content_show: Heartbeat.VideoMetadataKeys.SHOW, + stream_format: Heartbeat.VideoMetadataKeys.STREAM_FORMAT, + content_season: Heartbeat.VideoMetadataKeys.SEASON, + content_episode: Heartbeat.VideoMetadataKeys.EPISODE, + content_asset_id: Heartbeat.VideoMetadataKeys.ASSET_ID, + content_genre: Heartbeat.VideoMetadataKeys.GENRE, + content_first_air_date: Heartbeat.VideoMetadataKeys.FIRST_AIR_DATE, + content_digital_date: Heartbeat.VideoMetadataKeys.FIRST_DIGITAL_DATE, + content_rating: Heartbeat.VideoMetadataKeys.RATING, + content_originator: Heartbeat.VideoMetadataKeys.ORIGINATOR, + content_network: Heartbeat.VideoMetadataKeys.NETWORK, + content_show_type: Heartbeat.VideoMetadataKeys.SHOW_TYPE, + content_ad_load: Heartbeat.VideoMetadataKeys.AD_LOAD, + content_mvpd: Heartbeat.VideoMetadataKeys.MVPD, + content_authorized: Heartbeat.VideoMetadataKeys.AUTHORIZED, + content_daypart: Heartbeat.VideoMetadataKeys.DAY_PART, + content_feed: Heartbeat.VideoMetadataKeys.FEED, + }; + + var adobeMetadataKeys = {}; + for (var attribute in attributes) { + var key = attribute; + if (AdobeMetadataLookupTable[attribute]) { + key = AdobeMetadataLookupTable[attribute]; + } + adobeMetadataKeys[key] = attributes[attribute]; + } + + return adobeMetadataKeys; +}; + +var getStreamType = function(streamType, contentType, types) { + switch (streamType) { + case StreamType.OnDemand: + return contentType === ContentType.Video ? types.VOD : types.AOD; + case StreamType.LiveStream: + return types.LIVE; + case StreamType.Linear: + return types.LINEAR; + case StreamType.Podcast: + return types.PODCAST; + case StreamType.Audiobook: + return types.AUDIOBOOK; + default: + // If it's an unknown type, just pass it through to Adobe + return streamType; + } +}; + +var eventHandler = EventHandler; + +var Initialization = { + name: 'AdobeHeartbeat', + moduleId: 124, + initForwarder: function( + settings, + testMode, + userAttributes, + userIdentities, + processEvent, + eventQueue, + common, + initForwarderCallback + ) { + var self = this; + if (!window.mParticle.isTestEnvironment || !window.ADB) { + /* Load your Web SDK here using a variant of your snippet from your readme that your customers would generally put into their tags + Generally, our integrations create script tags and append them to the . Please follow the following format as a guide: + */ + var adobeHeartbeatSdk = document.createElement('script'); + adobeHeartbeatSdk.type = 'text/javascript'; + adobeHeartbeatSdk.async = true; + adobeHeartbeatSdk.src = + 'https://static.mparticle.com/sdk/web/adobe/MediaSDK.min.js'; + ( + document.getElementsByTagName('head')[0] || + document.getElementsByTagName('body')[0] + ).appendChild(adobeHeartbeatSdk); + adobeHeartbeatSdk.onload = function() { + if (ADB) { + self.initHeartbeat( + settings, + common, + ADB, + testMode, + initForwarderCallback + ); + if (eventQueue.length > 0) { + // Process any events that may have been queued up while forwarder was being initialized. + for (var i = 0; i < eventQueue.length; i++) { + processEvent(eventQueue[i]); + } + // now that each queued event is processed, we empty the eventQueue + eventQueue = []; + } + } + }; + } else { + // For testing, you should fill out this section in order to ensure any required initialization calls are made, + // clientSDKObject.initialize(forwarderSettings.apiKey) + self.initHeartbeat( + settings, + common, + ADB, + testMode, + initForwarderCallback + ); + } + }, + initHeartbeat: function( + settings, + common, + adobeSDK, + testMode, + initHeartbeatCallback + ) { + try { + // Init App Measurement with Visitor + var appMeasurement = new AppMeasurement(settings.reportSuiteIDs); + var visitorOptions = {}; + if (settings.audienceManagerServer) { + visitorOptions.audienceManagerServer = + settings.audienceManagerServer; + } + + appMeasurement.visitor = Visitor.getInstance( + settings.organizationID, + visitorOptions + ); + appMeasurement.trackingServer = settings.trackingServer; + appMeasurement.account = settings.reportSuiteIDs; + appMeasurement.pageName = document.title; + appMeasurement.charSet = 'UTF­8'; + + // Init Media Heartbeat + + var MediaHeartbeat = adobeSDK.va.MediaHeartbeat; + var MediaHeartbeatConfig = adobeSDK.va.MediaHeartbeatConfig; + var MediaHeartbeatDelegate = adobeSDK.va.MediaHeartbeatDelegate; + var mediaConfig = new MediaHeartbeatConfig(); + common.MediaHeartbeat = MediaHeartbeat; + + mediaConfig.trackingServer = settings.mediaTrackingServer; + mediaConfig.ssl = settings.useSSL === 'True'; + mediaConfig.playerName = 'mParticle Media SDK'; + + var mediaDelegate = new MediaHeartbeatDelegate(); + + mediaDelegate.getCurrentPlaybackTime = function() { + return common.playheadPosition; + }; + + mediaDelegate.getQoSObject = function() { + return MediaHeartbeat.createQoSObject( + common.bitRate, + common.startupTime, + common.fps, + common.droppedFrames + ); + }; + + var mediaHeartbeat = new MediaHeartbeat( + mediaDelegate, + mediaConfig, + appMeasurement + ); + common.mediaHeartbeat = mediaHeartbeat; + } catch (e) { + console.error(e); + } + + initHeartbeatCallback(); + }, +}; + +var initialization = Initialization; + +// =============== REACH OUT TO MPARTICLE IF YOU HAVE ANY QUESTIONS =============== +// +// Copyright 2018 mParticle, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + + + + +var MessageType = { + SessionStart: 1, + SessionEnd: 2, + PageView: 3, + PageEvent: 4, + CrashReport: 5, + OptOut: 6, + Commerce: 16, + Media: 20, +}; + +function constructor() { + var self = this, + isAdobeMediaSDKInitialized = false, + reportingService, + eventQueue = [], + name = 'AdobeHeartbeatKit'; + + self.moduleId = initialization.moduleId; + self.common = new common(); + + var initForwarderCallback = function() { + isAdobeMediaSDKInitialized = true; + }; + + function initForwarder( + settings, + service, + testMode, + trackerId, + userAttributes, + userIdentities + ) { + if (window.mParticle.isTestEnvironment) { + reportingService = function() {}; + } else { + reportingService = service; + } + + try { + initialization.initForwarder( + settings, + testMode, + userAttributes, + userIdentities, + processEvent, + eventQueue, + self.common, + initForwarderCallback + ); + self.eventHandler = new eventHandler(self.common); + } catch (e) { + console.error('Failed to initialize ' + name, e); + } + } + + function processEvent(event) { + var reportEvent = false; + if (isAdobeMediaSDKInitialized) { + try { + if (event.EventDataType === MessageType.Media) { + // Kits should just treat Media Events as generic Events + reportEvent = logEvent(event); + } + if (reportEvent === true && reportingService) { + reportingService(self, event); + return 'Successfully sent to ' + name; + } else { + return ( + 'Error logging event or event type not supported on forwarder ' + + name + ); + } + } catch (e) { + return 'Failed to send to ' + name + ' ' + e; + } + } else { + eventQueue.push(event); + return ( + 'Cannot send to forwarder ' + + name + + ', not initialized. Event added to queue.' + ); + } + } + + function logEvent(event) { + try { + self.eventHandler.logEvent(event); + return true; + } catch (e) { + return { + error: 'Error logging event on forwarder ' + name + '; ' + e, + }; + } + } + + this.init = initForwarder; + this.process = processEvent; +} + +if (window.mParticle && window.mParticle.registerHBK) { + window.mParticle.registerHBK({ constructor: constructor }); +} + +var src = { + AdobeHbkConstructor: constructor, +}; +var src_1 = src.AdobeHbkConstructor; + +/** + * @license + * Adobe Visitor API for JavaScript version: 4.4.0 + * Copyright 2019 Adobe, Inc. All Rights Reserved + * More info available at https://marketing.adobe.com/resources/help/en_US/mcvid/ + */ +var e=function(){function e(t){return (e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(){return {callbacks:{},add:function(e,t){this.callbacks[e]=this.callbacks[e]||[];var n=this.callbacks[e].push(t)-1,i=this;return function(){i.callbacks[e].splice(n,1);}},execute:function(e,t){if(this.callbacks[e]){t=void 0===t?[]:t,t=t instanceof Array?t:[t];try{for(;this.callbacks[e].length;){var n=this.callbacks[e].shift();"function"==typeof n?n.apply(null,t):n instanceof Array&&n[1].apply(n[0],t);}delete this.callbacks[e];}catch(e){}}},executeAll:function(e,t){(t||e&&!j.isObjectEmpty(e))&&Object.keys(this.callbacks).forEach(function(t){var n=void 0!==e[t]?e[t]:"";this.execute(t,n);},this);},hasCallbacks:function(){return Boolean(Object.keys(this.callbacks).length)}}}function i(e,t,n){var i=null==e?void 0:e[t];return void 0===i?n:i}function r(e){for(var t=/^\d+$/,n=0,i=e.length;nr)return 1;if(r>i)return -1}return 0}function s(e,t){if(e===t)return 0;var n=e.toString().split("."),i=t.toString().split(".");return r(n.concat(i))?(a(n,i),o(n,i)):NaN}function l(e){return e===Object(e)&&0===Object.keys(e).length}function c(e){return "function"==typeof e||e instanceof Array&&e.length}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){return !0};this.log=_e("log",e,t),this.warn=_e("warn",e,t),this.error=_e("error",e,t);}function d(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.isEnabled,n=e.cookieName,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i.cookies;return t&&n&&r?{remove:function(){r.remove(n);},get:function(){var e=r.get(n),t={};try{t=JSON.parse(e);}catch(e){t={};}return t},set:function(e,t){t=t||{},r.set(n,JSON.stringify(e),{domain:t.optInCookieDomain||"",cookieLifetime:t.optInStorageExpiry||3419e4,expires:!0});}}:{get:Le,set:Le,remove:Le}}function f(e){this.name=this.constructor.name,this.message=e,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error(e).stack;}function p(){function e(e,t){var n=Se(e);return n.length?n.every(function(e){return !!t[e]}):De(t)}function t(){M(b),O(ce.COMPLETE),_(h.status,h.permissions),m.set(h.permissions,{optInCookieDomain:l,optInStorageExpiry:c}),C.execute(xe);}function n(e){return function(n,i){if(!Ae(n))throw new Error("[OptIn] Invalid category(-ies). Please use the `OptIn.Categories` enum.");return O(ce.CHANGED),Object.assign(b,ye(Se(n),e)),i||t(),h}}var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.doesOptInApply,a=i.previousPermissions,o=i.preOptInApprovals,s=i.isOptInStorageEnabled,l=i.optInCookieDomain,c=i.optInStorageExpiry,u=i.isIabContext,f=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},p=f.cookies,g=Pe(a);Re(g,"Invalid `previousPermissions`!"),Re(o,"Invalid `preOptInApprovals`!");var m=d({isEnabled:!!s,cookieName:"adobeujs-optin"},{cookies:p}),h=this,_=le(h),C=ge(),I=Me(g),v=Me(o),S=m.get(),D={},A=function(e,t){return ke(e)||t&&ke(t)?ce.COMPLETE:ce.PENDING}(I,S),y=function(e,t,n){var i=ye(pe,!r);return r?Object.assign({},i,e,t,n):i}(v,I,S),b=be(y),O=function(e){return A=e},M=function(e){return y=e};h.deny=n(!1),h.approve=n(!0),h.denyAll=h.deny.bind(h,pe),h.approveAll=h.approve.bind(h,pe),h.isApproved=function(t){return e(t,h.permissions)},h.isPreApproved=function(t){return e(t,v)},h.fetchPermissions=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=t?h.on(ce.COMPLETE,e):Le;return !r||r&&h.isComplete||!!o?e(h.permissions):t||C.add(xe,function(){return e(h.permissions)}),n},h.complete=function(){h.status===ce.CHANGED&&t();},h.registerPlugin=function(e){if(!e||!e.name||"function"!=typeof e.onRegister)throw new Error(je);D[e.name]||(D[e.name]=e,e.onRegister.call(e,h));},h.execute=Ne(D),Object.defineProperties(h,{permissions:{get:function(){return y}},status:{get:function(){return A}},Categories:{get:function(){return ue}},doesOptInApply:{get:function(){return !!r}},isPending:{get:function(){return h.status===ce.PENDING}},isComplete:{get:function(){return h.status===ce.COMPLETE}},__plugins:{get:function(){return Object.keys(D)}},isIabContext:{get:function(){return u}}});}function g(e,t){function n(){r=null,e.call(e,new f("The call took longer than you wanted!"));}function i(){r&&(clearTimeout(r),e.apply(e,arguments));}if(void 0===t)return e;var r=setTimeout(n,t);return i}function m(){if(window.__cmp)return window.__cmp;var e=window;if(e===window.top)return void Ie.error("__cmp not found");for(var t;!t;){e=e.parent;try{e.frames.__cmpLocator&&(t=e);}catch(e){}if(e===window.top)break}if(!t)return void Ie.error("__cmp not found");var n={};return window.__cmp=function(e,i,r){var a=Math.random()+"",o={__cmpCall:{command:e,parameter:i,callId:a}};n[a]=r,t.postMessage(o,"*");},window.addEventListener("message",function(e){var t=e.data;if("string"==typeof t)try{t=JSON.parse(e.data);}catch(e){}if(t.__cmpReturn){var i=t.__cmpReturn;n[i.callId]&&(n[i.callId](i.returnValue,i.success),delete n[i.callId]);}},!1),window.__cmp}function h(){var e=this;e.name="iabPlugin",e.version="0.0.1";var t=ge(),n={allConsentData:null},i=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return n[e]=t};e.fetchConsentData=function(e){var t=e.callback,n=e.timeout,i=g(t,n);r({callback:i});},e.isApproved=function(e){var t=e.callback,i=e.category,a=e.timeout;if(n.allConsentData)return t(null,s(i,n.allConsentData.vendorConsents,n.allConsentData.purposeConsents));var o=g(function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.vendorConsents,a=n.purposeConsents;t(e,s(i,r,a));},a);r({category:i,callback:o});},e.onRegister=function(t){var n=Object.keys(de),i=function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i.purposeConsents,a=i.gdprApplies,o=i.vendorConsents;!e&&a&&o&&r&&(n.forEach(function(e){var n=s(e,o,r);t[n?"approve":"deny"](e,!0);}),t.complete());};e.fetchConsentData({callback:i});};var r=function(e){var r=e.callback;if(n.allConsentData)return r(null,n.allConsentData);t.add("FETCH_CONSENT_DATA",r);var s={};o(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.purposeConsents,o=e.gdprApplies,l=e.vendorConsents;(arguments.length>1?arguments[1]:void 0)&&(s={purposeConsents:r,gdprApplies:o,vendorConsents:l},i("allConsentData",s)),a(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(arguments.length>1?arguments[1]:void 0)&&(s.consentString=e.consentData,i("allConsentData",s)),t.execute("FETCH_CONSENT_DATA",[null,n.allConsentData]);});});},a=function(e){var t=m();t&&t("getConsentData",null,e);},o=function(e){var t=Fe(de),n=m();n&&n("getVendorConsents",t,e);},s=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=!!t[de[e]];return i&&function(){return fe[e].every(function(e){return n[e]})}()};}var _="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};Object.assign=Object.assign||function(e){for(var t,n,i=1;i4;e--){var t=document.createElement("div");if(t.innerHTML="\x3c!--[if IE "+e+"]>=0;n--)if(t=i.slice(n).join("."),Q.set("test","cookie",{domain:t}))return Q.remove("test",{domain:t}),t;return ""},Z={compare:s,isLessThan:function(e,t){return s(e,t)<0},areVersionsDifferent:function(e,t){return 0!==s(e,t)},isGreaterThan:function(e,t){return s(e,t)>0},isEqual:function(e,t){return 0===s(e,t)}},ee=!!_.postMessage,te={postMessage:function(e,t,n){var i=1;t&&(ee?n.postMessage(e,t.replace(/([^:]+:\/\/[^\/]+).*/,"$1")):t&&(n.location=t.replace(/#.*$/,"")+"#"+ +new Date+i+++"&"+e));},receiveMessage:function(e,t){var n;try{ee&&(e&&(n=function(n){if("string"==typeof t&&n.origin!==t||"[object Function]"===Object.prototype.toString.call(t)&&!1===t(n.origin))return !1;e(n);}),_.addEventListener?_[e?"addEventListener":"removeEventListener"]("message",n):_[e?"attachEvent":"detachEvent"]("onmessage",n));}catch(e){}}},ne=function(e){var t,n,i="0123456789",r="",a="",o=8,s=10,l=10;if(1==e){for(i+="ABCDEF",t=0;16>t;t++)n=Math.floor(Math.random()*o),r+=i.substring(n,n+1),n=Math.floor(Math.random()*o),a+=i.substring(n,n+1),o=16;return r+"-"+a}for(t=0;19>t;t++)n=Math.floor(Math.random()*s),r+=i.substring(n,n+1),0===t&&9==n?s=3:(1==t||2==t)&&10!=s&&2>n?s=10:2n?l=10:20&&(t=!1)),{corsType:e,corsCookiesEnabled:t}}(),getCORSInstance:function(){return "none"===this.corsMetadata.corsType?null:new _[this.corsMetadata.corsType]},fireCORS:function(t,n,i){function r(e){var n;try{if((n=JSON.parse(e))!==Object(n))return void a.handleCORSError(t,null,"Response is not JSON")}catch(e){return void a.handleCORSError(t,e,"Error parsing response as JSON")}try{for(var i=t.callback,r=_,o=0;o=a&&(e.splice(r,1),r--);return {dataPresent:o,dataValid:s}},manageSyncsSize:function(e){if(e.join("*").length>this.MAX_SYNCS_LENGTH)for(e.sort(function(e,t){return parseInt(e.split("-")[1],10)-parseInt(t.split("-")[1],10)});e.join("*").length>this.MAX_SYNCS_LENGTH;)e.shift();},fireSync:function(t,n,i,r,a,o){var s=this;if(t){if("img"===n.tag){var l,c,u,d,f=n.url,p=e.loadSSL?"https:":"http:";for(l=0,c=f.length;lre.DAYS_BETWEEN_SYNC_ID_CALLS},attachIframeASAP:function(){function e(){t.startedAttachingIframe||(n.body?t.attachIframe():setTimeout(e,30));}var t=this;e();}}},oe={audienceManagerServer:{},audienceManagerServerSecure:{},cookieDomain:{},cookieLifetime:{},cookieName:{},doesOptInApply:{},disableThirdPartyCalls:{},discardTrackingServerECID:{},idSyncAfterIDCallResult:{},idSyncAttachIframeOnWindowLoad:{},idSyncContainerID:{},idSyncDisable3rdPartySyncing:{},disableThirdPartyCookies:{},idSyncDisableSyncs:{},disableIdSyncs:{},idSyncIDCallResult:{},idSyncSSLUseAkamai:{},isCoopSafe:{},isIabContext:{},isOptInStorageEnabled:{},loadSSL:{},loadTimeout:{},marketingCloudServer:{},marketingCloudServerSecure:{},optInCookieDomain:{},optInStorageExpiry:{},overwriteCrossDomainMCIDAndAID:{},preOptInApprovals:{},previousPermissions:{},resetBeforeVersion:{},sdidParamExpiry:{},serverState:{},sessionCookieName:{},secureCookie:{},takeTimeoutMetrics:{},trackingServer:{},trackingServerSecure:{},whitelistIframeDomains:{},whitelistParentDomain:{}},se={getConfigNames:function(){return Object.keys(oe)},getConfigs:function(){return oe},normalizeConfig:function(e){return "function"!=typeof e?e:e()}},le=function(e){var t={};return e.on=function(e,n,i){if(!n||"function"!=typeof n)throw new Error("[ON] Callback should be a function.");t.hasOwnProperty(e)||(t[e]=[]);var r=t[e].push({callback:n,context:i})-1;return function(){t[e].splice(r,1),t[e].length||delete t[e];}},e.off=function(e,n){t.hasOwnProperty(e)&&(t[e]=t[e].filter(function(e){if(e.callback!==n)return e}));},e.publish=function(e){if(t.hasOwnProperty(e)){var n=[].slice.call(arguments,1);t[e].slice(0).forEach(function(e){e.callback.apply(e.context,n);});}},e.publish},ce={PENDING:"pending",CHANGED:"changed",COMPLETE:"complete"},ue={AAM:"aam",ADCLOUD:"adcloud",ANALYTICS:"aa",CAMPAIGN:"campaign",ECID:"ecid",LIVEFYRE:"livefyre",TARGET:"target",VIDEO_ANALYTICS:"videoaa"},de=(C={},t(C,ue.AAM,565),t(C,ue.ECID,565),C),fe=(I={},t(I,ue.AAM,[1,2,5]),t(I,ue.ECID,[1,2,5]),I),pe=function(e){return Object.keys(e).map(function(t){return e[t]})}(ue),ge=function(){var e={};return e.callbacks=Object.create(null),e.add=function(t,n){if(!c(n))throw new Error("[callbackRegistryFactory] Make sure callback is a function or an array of functions.");e.callbacks[t]=e.callbacks[t]||[];var i=e.callbacks[t].push(n)-1;return function(){e.callbacks[t].splice(i,1);}},e.execute=function(t,n){if(e.callbacks[t]){n=void 0===n?[]:n,n=n instanceof Array?n:[n];try{for(;e.callbacks[t].length;){var i=e.callbacks[t].shift();"function"==typeof i?i.apply(null,n):i instanceof Array&&i[1].apply(i[0],n);}delete e.callbacks[t];}catch(e){}}},e.executeAll=function(t,n){(n||t&&!l(t))&&Object.keys(e.callbacks).forEach(function(n){var i=void 0!==t[n]?t[n]:"";e.execute(n,i);},e);},e.hasCallbacks=function(){return Boolean(Object.keys(e.callbacks).length)},e},me=function(){},he=function(e){var t=window,n=t.console;return !!n&&"function"==typeof n[e]},_e=function(e,t,n){return n()?function(){if(he(e)){for(var n=arguments.length,i=new Array(n),r=0;r-1})},ye=function(e,t){return e.reduce(function(e,n){return e[n]=t,e},{})},be=function(e){return JSON.parse(JSON.stringify(e))},Oe=function(e){return "[object Array]"===Object.prototype.toString.call(e)&&!e.length},Me=function(e){if(Te(e))return e;try{return JSON.parse(e)}catch(e){return {}}},ke=function(e){return void 0===e||(Te(e)?Ae(Object.keys(e)):Ee(e))},Ee=function(e){try{var t=JSON.parse(e);return !!e&&ve(e,"string")&&Ae(Object.keys(t))}catch(e){return !1}},Te=function(e){return null!==e&&ve(e,"object")&&!1===Array.isArray(e)},Le=function(){},Pe=function(e){return ve(e,"function")?e():e},Re=function(e,t){ke(e)||Ie.error("".concat(t));},we=function(e){return Object.keys(e).map(function(t){return e[t]})},Fe=function(e){return we(e).filter(function(e,t,n){return n.indexOf(e)===t})},Ne=function(e){return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.command,i=t.params,r=void 0===i?{}:i,a=t.callback,o=void 0===a?Le:a;if(!n||-1===n.indexOf("."))throw new Error("[OptIn.execute] Please provide a valid command.");try{var s=n.split("."),l=e[s[0]],c=s[1];if(!l||"function"!=typeof l[c])throw new Error("Make sure the plugin and API name exist.");var u=Object.assign(r,{callback:o});l[c].call(l,u);}catch(e){Ie.error("[execute] Something went wrong: "+e.message);}}};f.prototype=Object.create(Error.prototype),f.prototype.constructor=f;var xe="fetchPermissions",je="[OptIn#registerPlugin] Plugin is invalid.";p.Categories=ue,p.TimeoutError=f;var Ve=Object.freeze({OptIn:p,IabPlugin:h}),He=function(e,t){e.publishDestinations=function(n){var i=arguments[1],r=arguments[2];try{r="function"==typeof r?r:n.callback;}catch(e){r=function(){};}var a=t;if(!a.readyToAttachIframePreliminary())return void r({error:"The destination publishing iframe is disabled in the Visitor library."});if("string"==typeof n){if(!n.length)return void r({error:"subdomain is not a populated string."});if(!(i instanceof Array&&i.length))return void r({error:"messages is not a populated array."});var o=!1;if(i.forEach(function(e){ +"string"==typeof e&&e.length&&(a.addMessage(e),o=!0);}),!o)return void r({error:"None of the messages are populated strings."})}else{if(!j.isObject(n))return void r({error:"Invalid parameters passed."});var s=n;if("string"!=typeof(n=s.subdomain)||!n.length)return void r({error:"config.subdomain is not a populated string."});var l=s.urlDestinations;if(!(l instanceof Array&&l.length))return void r({error:"config.urlDestinations is not a populated array."});var c=[];l.forEach(function(e){j.isObject(e)&&(e.hideReferrer?e.message&&a.addMessage(e.message):c.push(e));});!function e(){c.length&&setTimeout(function(){var t=new Image,n=c.shift();t.src=n.url,a.onPageDestinationsFired.push(n),e();},100);}();}a.iframe?(r({message:"The destination publishing iframe is already attached and loaded."}),a.requestToProcess()):!e.subdomain&&e._getField("MCMID")?(a.subdomain=n,a.doAttachIframe=!0,a.url=a.getUrl(),a.readyToAttachIframe()?(a.iframeLoadedCallbacks.push(function(e){r({message:"Attempted to attach and load the destination publishing iframe through this API call. Result: "+(e.message||"no result")});}),a.attachIframe()):r({error:"Encountered a problem in attempting to attach and load the destination publishing iframe through this API call."})):a.iframeLoadedCallbacks.push(function(e){r({message:"Attempted to attach and load the destination publishing iframe through normal Visitor API processing. Result: "+(e.message||"no result")});});};},Ue=function e(t){function n(e,t){return e>>>t|e<<32-t}for(var i,r,a=Math.pow,o=a(2,32),s="",l=[],c=8*t.length,u=e.h=e.h||[],d=e.k=e.k||[],f=d.length,p={},g=2;f<64;g++)if(!p[g]){for(i=0;i<313;i+=g)p[i]=g;u[f]=a(g,.5)*o|0,d[f++]=a(g,1/3)*o|0;}for(t+="€";t.length%64-56;)t+="\0";for(i=0;i>8)return;l[i>>2]|=r<<(3-i)%4*8;}for(l[l.length]=c/o|0,l[l.length]=c,r=0;r>>3)+m[i-7]+(n(C,17)^n(C,19)^C>>>10)|0);u=[S+((n(I,2)^n(I,13)^n(I,22))+(I&u[1]^I&u[2]^u[1]&u[2]))|0].concat(u),u[4]=u[4]+S|0;}for(i=0;i<8;i++)u[i]=u[i]+h[i]|0;}for(i=0;i<8;i++)for(r=3;r+1;r--){var D=u[i]>>8*r&255;s+=(D<16?0:"")+D.toString(16);}return s},Be=function(e,t){return "SHA-256"!==t&&"SHA256"!==t&&"sha256"!==t&&"sha-256"!==t||(e=Ue(e)),e},Ge=function(e){return String(e).trim().toLowerCase()},Ye=Ve.OptIn;j.defineGlobalNamespace(),window.adobe.OptInCategories=Ye.Categories;var qe=function(t,n,i){function r(e){var t=e;return function(e){var n=e||v.location.href;try{var i=g._extractParamFromUri(n,t);if(i)return w.parsePipeDelimetedKeyValues(i)}catch(e){}}}function a(e){function t(e,t,n){e&&e.match(re.VALID_VISITOR_ID_REGEX)&&(n===A&&(I=!0),t(e));}t(e[A],g.setMarketingCloudVisitorID,A),g._setFieldExpire(k,-1),t(e[O],g.setAnalyticsVisitorID);}function o(e){e=e||{},g._supplementalDataIDCurrent=e.supplementalDataIDCurrent||"",g._supplementalDataIDCurrentConsumed=e.supplementalDataIDCurrentConsumed||{},g._supplementalDataIDLast=e.supplementalDataIDLast||"",g._supplementalDataIDLastConsumed=e.supplementalDataIDLastConsumed||{};}function s(e){function t(e,t,n){return n=n?n+="|":n,n+=e+"="+encodeURIComponent(t)}function n(e,n){var i=n[0],r=n[1];return null!=r&&r!==T&&(e=t(i,r,e)),e}var i=e.reduce(n,"");return function(e){var t=w.getTimestampInSeconds();return e=e?e+="|":e,e+="TS="+t}(i)}function l(e){var t=e.minutesToLive,n="";return (g.idSyncDisableSyncs||g.disableIdSyncs)&&(n=n||"Error: id syncs have been disabled"),"string"==typeof e.dpid&&e.dpid.length||(n=n||"Error: config.dpid is empty"),"string"==typeof e.url&&e.url.length||(n=n||"Error: config.url is empty"),void 0===t?t=20160:(t=parseInt(t,10),(isNaN(t)||t<=0)&&(n=n||"Error: config.minutesToLive needs to be a positive number")),{error:n,ttl:t}}function c(){return !!g.configs.doesOptInApply&&!(m.optIn.isComplete&&u())}function u(){return g.configs.isIabContext?m.optIn.isApproved(m.optIn.Categories.ECID)&&C:m.optIn.isApproved(m.optIn.Categories.ECID)}function d(e,t){if(C=!0,e)throw new Error("[IAB plugin] : "+e);t.gdprApplies&&(h=t.consentString),g.init(),p();}function f(){m.optIn.isApproved(m.optIn.Categories.ECID)&&(g.configs.isIabContext?m.optIn.execute({command:"iabPlugin.fetchConsentData",callback:d}):(g.init(),p()));}function p(){m.optIn.off("complete",f);}if(!i||i.split("").reverse().join("")!==t)throw new Error("Please use `Visitor.getInstance` to instantiate Visitor.");var g=this,m=window.adobe,h="",C=!1,I=!1;g.version="4.4.0";var v=_,S=v.Visitor;S.version=g.version,S.AuthState=E.AUTH_STATE,S.OptOut=E.OPT_OUT,v.s_c_in||(v.s_c_il=[],v.s_c_in=0),g._c="Visitor",g._il=v.s_c_il,g._in=v.s_c_in,g._il[g._in]=g,v.s_c_in++,g._instanceType="regular",g._log={requests:[]},g.marketingCloudOrgID=t,g.cookieName="AMCV_"+t,g.sessionCookieName="AMCVS_"+t,g.cookieDomain=$(),g.loadSSL=v.location.protocol.toLowerCase().indexOf("https")>=0,g.loadTimeout=3e4,g.CORSErrors=[],g.marketingCloudServer=g.audienceManagerServer="dpm.demdex.net",g.sdidParamExpiry=30;var D=null,A="MCMID",y="MCIDTS",b="A",O="MCAID",M="AAM",k="MCAAMB",T="NONE",L=function(e){return !Object.prototype[e]},P=ie(g);g.FIELDS=E.FIELDS,g.cookieRead=function(e){return Q.get(e)},g.cookieWrite=function(e,t,n){var i=g.cookieLifetime?(""+g.cookieLifetime).toUpperCase():"",r=!1;return g.configs&&g.configs.secureCookie&&"https:"===location.protocol&&(r=!0),Q.set(e,""+t,{expires:n,domain:g.cookieDomain,cookieLifetime:i,secure:r})},g.resetState=function(e){e?g._mergeServerState(e):o();},g._isAllowedDone=!1,g._isAllowedFlag=!1,g.isAllowed=function(){return g._isAllowedDone||(g._isAllowedDone=!0,(g.cookieRead(g.cookieName)||g.cookieWrite(g.cookieName,"T",1))&&(g._isAllowedFlag=!0)),"T"===g.cookieRead(g.cookieName)&&g._helpers.removeCookie(g.cookieName),g._isAllowedFlag},g.setMarketingCloudVisitorID=function(e){g._setMarketingCloudFields(e);},g._use1stPartyMarketingCloudServer=!1,g.getMarketingCloudVisitorID=function(e,t){g.marketingCloudServer&&g.marketingCloudServer.indexOf(".demdex.net")<0&&(g._use1stPartyMarketingCloudServer=!0);var n=g._getAudienceManagerURLData("_setMarketingCloudFields"),i=n.url;return g._getRemoteField(A,i,e,t,n)},g.getVisitorValues=function(e,t){var n={MCMID:{fn:g.getMarketingCloudVisitorID,args:[!0],context:g},MCOPTOUT:{fn:g.isOptedOut,args:[void 0,!0],context:g},MCAID:{fn:g.getAnalyticsVisitorID,args:[!0],context:g},MCAAMLH:{fn:g.getAudienceManagerLocationHint,args:[!0],context:g},MCAAMB:{fn:g.getAudienceManagerBlob,args:[!0],context:g}},i=t&&t.length?j.pluck(n,t):n;z(i,e);},g._currentCustomerIDs={},g._customerIDsHashChanged=!1,g._newCustomerIDsHash="",g.setCustomerIDs=function(t,n){function i(){g._customerIDsHashChanged=!1;}if(!g.isOptedOut()&&t){if(!j.isObject(t)||j.isObjectEmpty(t))return !1;g._readVisitor();var r,a,o;for(r in t)if(L(r)&&(a=t[r],n=a.hasOwnProperty("hashType")?a.hashType:n,a))if("object"===e(a)){var s={};if(a.id){if(n){if(!(o=Be(Ge(a.id),n)))return;a.id=o,s.hashType=n;}s.id=a.id;}void 0!=a.authState&&(s.authState=a.authState),g._currentCustomerIDs[r]=s;}else if(n){if(!(o=Be(Ge(a),n)))return;g._currentCustomerIDs[r]={id:o,hashType:n};}else g._currentCustomerIDs[r]={id:a};var l=g.getCustomerIDs(),c=g._getField("MCCIDH"),u="";c||(c=0);for(r in l)L(r)&&(a=l[r],u+=(u?"|":"")+r+"|"+(a.id?a.id:"")+(a.authState?a.authState:""));g._newCustomerIDsHash=String(g._hash(u)),g._newCustomerIDsHash!==c&&(g._customerIDsHashChanged=!0,g._mapCustomerIDs(i));}},g.getCustomerIDs=function(){g._readVisitor();var e,t,n={};for(e in g._currentCustomerIDs)L(e)&&(t=g._currentCustomerIDs[e],n[e]||(n[e]={}),t.id&&(n[e].id=t.id),void 0!=t.authState?n[e].authState=t.authState:n[e].authState=S.AuthState.UNKNOWN,t.hashType&&(n[e].hashType=t.hashType));return n},g.setAnalyticsVisitorID=function(e){g._setAnalyticsFields(e);},g.getAnalyticsVisitorID=function(e,t,n){if(!w.isTrackingServerPopulated()&&!n)return g._callCallback(e,[""]),"";var i="";if(n||(i=g.getMarketingCloudVisitorID(function(t){g.getAnalyticsVisitorID(e,!0);})),i||n){var r=n?g.marketingCloudServer:g.trackingServer,a="";g.loadSSL&&(n?g.marketingCloudServerSecure&&(r=g.marketingCloudServerSecure):g.trackingServerSecure&&(r=g.trackingServerSecure));var o={};if(r){var s="http"+(g.loadSSL?"s":"")+"://"+r+"/id",l="d_visid_ver="+g.version+"&mcorgid="+encodeURIComponent(g.marketingCloudOrgID)+(i?"&mid="+encodeURIComponent(i):"")+(g.idSyncDisable3rdPartySyncing||g.disableThirdPartyCookies?"&d_coppa=true":""),c=["s_c_il",g._in,"_set"+(n?"MarketingCloud":"Analytics")+"Fields"];a=s+"?"+l+"&callback=s_c_il%5B"+g._in+"%5D._set"+(n?"MarketingCloud":"Analytics")+"Fields",o.corsUrl=s+"?"+l,o.callback=c;}return o.url=a,g._getRemoteField(n?A:O,a,e,t,o)}return ""},g.getAudienceManagerLocationHint=function(e,t){if(g.getMarketingCloudVisitorID(function(t){g.getAudienceManagerLocationHint(e,!0);})){var n=g._getField(O);if(!n&&w.isTrackingServerPopulated()&&(n=g.getAnalyticsVisitorID(function(t){g.getAudienceManagerLocationHint(e,!0);})),n||!w.isTrackingServerPopulated()){var i=g._getAudienceManagerURLData(),r=i.url;return g._getRemoteField("MCAAMLH",r,e,t,i)}}return ""},g.getLocationHint=g.getAudienceManagerLocationHint,g.getAudienceManagerBlob=function(e,t){if(g.getMarketingCloudVisitorID(function(t){g.getAudienceManagerBlob(e,!0);})){var n=g._getField(O);if(!n&&w.isTrackingServerPopulated()&&(n=g.getAnalyticsVisitorID(function(t){g.getAudienceManagerBlob(e,!0);})),n||!w.isTrackingServerPopulated()){var i=g._getAudienceManagerURLData(),r=i.url;return g._customerIDsHashChanged&&g._setFieldExpire(k,-1),g._getRemoteField(k,r,e,t,i)}}return ""},g._supplementalDataIDCurrent="",g._supplementalDataIDCurrentConsumed={},g._supplementalDataIDLast="",g._supplementalDataIDLastConsumed={},g.getSupplementalDataID=function(e,t){g._supplementalDataIDCurrent||t||(g._supplementalDataIDCurrent=g._generateID(1));var n=g._supplementalDataIDCurrent;return g._supplementalDataIDLast&&!g._supplementalDataIDLastConsumed[e]?(n=g._supplementalDataIDLast,g._supplementalDataIDLastConsumed[e]=!0):n&&(g._supplementalDataIDCurrentConsumed[e]&&(g._supplementalDataIDLast=g._supplementalDataIDCurrent,g._supplementalDataIDLastConsumed=g._supplementalDataIDCurrentConsumed,g._supplementalDataIDCurrent=n=t?"":g._generateID(1),g._supplementalDataIDCurrentConsumed={}),n&&(g._supplementalDataIDCurrentConsumed[e]=!0)),n};var R=!1;g._liberatedOptOut=null,g.getOptOut=function(e,t){var n=g._getAudienceManagerURLData("_setMarketingCloudFields"),i=n.url;if(u())return g._getRemoteField("MCOPTOUT",i,e,t,n);if(g._registerCallback("liberatedOptOut",e),null!==g._liberatedOptOut)return g._callAllCallbacks("liberatedOptOut",[g._liberatedOptOut]),R=!1,g._liberatedOptOut;if(R)return null;R=!0;var r="liberatedGetOptOut";return n.corsUrl=n.corsUrl.replace(/dpm\.demdex\.net\/id\?/,"dpm.demdex.net/optOutStatus?"),n.callback=[r],_[r]=function(e){if(e===Object(e)){var t,n,i=j.parseOptOut(e,t,T);t=i.optOut,n=1e3*i.d_ottl,g._liberatedOptOut=t,setTimeout(function(){g._liberatedOptOut=null;},n);}g._callAllCallbacks("liberatedOptOut",[t]),R=!1;},P.fireCORS(n),null},g.isOptedOut=function(e,t,n){t||(t=S.OptOut.GLOBAL);var i=g.getOptOut(function(n){var i=n===S.OptOut.GLOBAL||n.indexOf(t)>=0;g._callCallback(e,[i]);},n);return i?i===S.OptOut.GLOBAL||i.indexOf(t)>=0:null},g._fields=null,g._fieldsExpired=null,g._hash=function(e){var t,n,i=0;if(e)for(t=0;t0;)g._callCallback(n.shift(),t);}},g._addQuerystringParam=function(e,t,n,i){var r=encodeURIComponent(t)+"="+encodeURIComponent(n),a=w.parseHash(e),o=w.hashlessUrl(e);if(-1===o.indexOf("?"))return o+"?"+r+a;var s=o.split("?"),l=s[0]+"?",c=s[1];return l+w.addQueryParamAtLocation(c,r,i)+a},g._extractParamFromUri=function(e,t){var n=new RegExp("[\\?&#]"+t+"=([^&#]*)"),i=n.exec(e);if(i&&i.length)return decodeURIComponent(i[1])},g._parseAdobeMcFromUrl=r(re.ADOBE_MC),g._parseAdobeMcSdidFromUrl=r(re.ADOBE_MC_SDID),g._attemptToPopulateSdidFromUrl=function(e){var n=g._parseAdobeMcSdidFromUrl(e),i=1e9;n&&n.TS&&(i=w.getTimestampInSeconds()-n.TS),n&&n.SDID&&n.MCORGID===t&&ire.ADOBE_MC_TTL_IN_MIN||e.MCORGID!==t)return;a(e);}},g._mergeServerState=function(e){if(e)try{if(e=function(e){return w.isObject(e)?e:JSON.parse(e)}(e),e[g.marketingCloudOrgID]){var t=e[g.marketingCloudOrgID];!function(e){w.isObject(e)&&g.setCustomerIDs(e);}(t.customerIDs),o(t.sdid);}}catch(e){throw new Error("`serverState` has an invalid format.")}},g._timeout=null,g._loadData=function(e,t,n,i){t=g._addQuerystringParam(t,"d_fieldgroup",e,1),i.url=g._addQuerystringParam(i.url,"d_fieldgroup",e,1),i.corsUrl=g._addQuerystringParam(i.corsUrl,"d_fieldgroup",e,1),N.fieldGroupObj[e]=!0,i===Object(i)&&i.corsUrl&&"XMLHttpRequest"===P.corsMetadata.corsType&&P.fireCORS(i,n,e);},g._clearTimeout=function(e){null!=g._timeout&&g._timeout[e]&&(clearTimeout(g._timeout[e]),g._timeout[e]=0);},g._settingsDigest=0,g._getSettingsDigest=function(){if(!g._settingsDigest){var e=g.version;g.audienceManagerServer&&(e+="|"+g.audienceManagerServer),g.audienceManagerServerSecure&&(e+="|"+g.audienceManagerServerSecure),g._settingsDigest=g._hash(e);}return g._settingsDigest},g._readVisitorDone=!1,g._readVisitor=function(){if(!g._readVisitorDone){g._readVisitorDone=!0;var e,t,n,i,r,a,o=g._getSettingsDigest(),s=!1,l=g.cookieRead(g.cookieName),c=new Date;if(l||I||g.discardTrackingServerECID||(l=g.cookieRead(re.FIRST_PARTY_SERVER_COOKIE)),null==g._fields&&(g._fields={}),l&&"T"!==l)for(l=l.split("|"),l[0].match(/^[\-0-9]+$/)&&(parseInt(l[0],10)!==o&&(s=!0),l.shift()),l.length%2==1&&l.pop(),e=0;e1?(r=parseInt(t[1],10),a=t[1].indexOf("s")>0):(r=0,a=!1),s&&("MCCIDH"===n&&(i=""),r>0&&(r=c.getTime()/1e3-60)),n&&i&&(g._setField(n,i,1),r>0&&(g._fields["expire"+n]=r+(a?"s":""),(c.getTime()>=1e3*r||a&&!g.cookieRead(g.sessionCookieName))&&(g._fieldsExpired||(g._fieldsExpired={}),g._fieldsExpired[n]=!0)));!g._getField(O)&&w.isTrackingServerPopulated()&&(l=g.cookieRead("s_vi"))&&(l=l.split("|"),l.length>1&&l[0].indexOf("v1")>=0&&(i=l[1],e=i.indexOf("["),e>=0&&(i=i.substring(0,e)),i&&i.match(re.VALID_VISITOR_ID_REGEX)&&g._setField(O,i)));}},g._appendVersionTo=function(e){var t="vVersion|"+g.version,n=e?g._getCookieVersion(e):null;return n?Z.areVersionsDifferent(n,g.version)&&(e=e.replace(re.VERSION_REGEX,t)):e+=(e?"|":"")+t,e},g._writeVisitor=function(){var e,t,n=g._getSettingsDigest();for(e in g._fields)L(e)&&g._fields[e]&&"expire"!==e.substring(0,6)&&(t=g._fields[e],n+=(n?"|":"")+e+(g._fields["expire"+e]?"-"+g._fields["expire"+e]:"")+"|"+t);n=g._appendVersionTo(n),g.cookieWrite(g.cookieName,n,1);},g._getField=function(e,t){return null==g._fields||!t&&g._fieldsExpired&&g._fieldsExpired[e]?null:g._fields[e]},g._setField=function(e,t,n){null==g._fields&&(g._fields={}),g._fields[e]=t,n||g._writeVisitor();},g._getFieldList=function(e,t){var n=g._getField(e,t);return n?n.split("*"):null},g._setFieldList=function(e,t,n){g._setField(e,t?t.join("*"):"",n);},g._getFieldMap=function(e,t){var n=g._getFieldList(e,t);if(n){var i,r={};for(i=0;i0?e.substr(t):""},hashlessUrl:function(e){var t=e.indexOf("#");return t>0?e.substr(0,t):e},addQueryParamAtLocation:function(e,t,n){var i=e.split("&");return n=null!=n?n:i.length,i.splice(n,0,t),i.join("&")},isFirstPartyAnalyticsVisitorIDCall:function(e,t,n){if(e!==O)return !1;var i;return t||(t=g.trackingServer),n||(n=g.trackingServerSecure),!("string"!=typeof(i=g.loadSSL?n:t)||!i.length)&&(i.indexOf("2o7.net")<0&&i.indexOf("omtrdc.net")<0)},isObject:function(e){return Boolean(e&&e===Object(e))},removeCookie:function(e){Q.remove(e,{domain:g.cookieDomain});},isTrackingServerPopulated:function(){return !!g.trackingServer||!!g.trackingServerSecure},getTimestampInSeconds:function(){return Math.round((new Date).getTime()/1e3)},parsePipeDelimetedKeyValues:function(e){return e.split("|").reduce(function(e,t){var n=t.split("=");return e[n[0]]=decodeURIComponent(n[1]),e},{})},generateRandomString:function(e){e=e||5;for(var t="",n="abcdefghijklmnopqrstuvwxyz0123456789";e--;)t+=n[Math.floor(Math.random()*n.length)];return t},normalizeBoolean:function(e){return "true"===e||"false"!==e&&e},parseBoolean:function(e){return "true"===e||"false"!==e&&null},replaceMethodsWithFunction:function(e,t){for(var n in e)e.hasOwnProperty(n)&&"function"==typeof e[n]&&(e[n]=t);return e}};g._helpers=w;var F=ae(g,S);g._destinationPublishing=F,g.timeoutMetricsLog=[];var N={isClientSideMarketingCloudVisitorID:null,MCIDCallTimedOut:null,AnalyticsIDCallTimedOut:null,AAMIDCallTimedOut:null,fieldGroupObj:{},setState:function(e,t){switch(e){case"MC":!1===t?!0!==this.MCIDCallTimedOut&&(this.MCIDCallTimedOut=!1):this.MCIDCallTimedOut=t;break;case b:!1===t?!0!==this.AnalyticsIDCallTimedOut&&(this.AnalyticsIDCallTimedOut=!1):this.AnalyticsIDCallTimedOut=t;break;case M:!1===t?!0!==this.AAMIDCallTimedOut&&(this.AAMIDCallTimedOut=!1):this.AAMIDCallTimedOut=t;}}};g.isClientSideMarketingCloudVisitorID=function(){return N.isClientSideMarketingCloudVisitorID},g.MCIDCallTimedOut=function(){return N.MCIDCallTimedOut},g.AnalyticsIDCallTimedOut=function(){return N.AnalyticsIDCallTimedOut},g.AAMIDCallTimedOut=function(){return N.AAMIDCallTimedOut},g.idSyncGetOnPageSyncInfo=function(){return g._readVisitor(),g._getField("MCSYNCSOP")},g.idSyncByURL=function(e){if(!g.isOptedOut()){var t=l(e||{});if(t.error)return t.error;var n,i,r=e.url,a=encodeURIComponent,o=F;return r=r.replace(/^https:/,"").replace(/^http:/,""),n=j.encodeAndBuildRequest(["",e.dpid,e.dpuuid||""],","),i=["ibs",a(e.dpid),"img",a(r),t.ttl,"",n],o.addMessage(i.join("|")),o.requestToProcess(),"Successfully queued"}},g.idSyncByDataSource=function(e){if(!g.isOptedOut())return e===Object(e)&&"string"==typeof e.dpuuid&&e.dpuuid.length?(e.url="//dpm.demdex.net/ibs:dpid="+e.dpid+"&dpuuid="+e.dpuuid,g.idSyncByURL(e)):"Error: config or config.dpuuid is empty"},He(g,F),g._getCookieVersion=function(e){e=e||g.cookieRead(g.cookieName);var t=re.VERSION_REGEX.exec(e);return t&&t.length>1?t[1]:null},g._resetAmcvCookie=function(e){var t=g._getCookieVersion();t&&!Z.isLessThan(t,e)||w.removeCookie(g.cookieName);},g.setAsCoopSafe=function(){D=!0;},g.setAsCoopUnsafe=function(){D=!1;},function(){if(g.configs=Object.create(null),w.isObject(n))for(var e in n)L(e)&&(g[e]=n[e],g.configs[e]=n[e]);}(),function(){[["getMarketingCloudVisitorID"],["setCustomerIDs",void 0],["getAnalyticsVisitorID"],["getAudienceManagerLocationHint"],["getLocationHint"],["getAudienceManagerBlob"]].forEach(function(e){var t=e[0],n=2===e.length?e[1]:"",i=g[t];g[t]=function(e){return u()&&g.isAllowed()?i.apply(g,arguments):("function"==typeof e&&g._callCallback(e,[n]),n)};});}(),g.init=function(){if(c())return m.optIn.fetchPermissions(f,!0);!function(){if(w.isObject(n)){g.idSyncContainerID=g.idSyncContainerID||0,D="boolean"==typeof g.isCoopSafe?g.isCoopSafe:w.parseBoolean(g.isCoopSafe),g.resetBeforeVersion&&g._resetAmcvCookie(g.resetBeforeVersion),g._attemptToPopulateIdsFromUrl(),g._attemptToPopulateSdidFromUrl(),g._readVisitor();var e=g._getField(y),t=Math.ceil((new Date).getTime()/re.MILLIS_PER_DAY);g.idSyncDisableSyncs||g.disableIdSyncs||!F.canMakeSyncIDCall(e,t)||(g._setFieldExpire(k,-1),g._setField(y,t)),g.getMarketingCloudVisitorID(),g.getAudienceManagerLocationHint(),g.getAudienceManagerBlob(),g._mergeServerState(g.serverState);}else g._attemptToPopulateIdsFromUrl(),g._attemptToPopulateSdidFromUrl();}(),function(){if(!g.idSyncDisableSyncs&&!g.disableIdSyncs){F.checkDPIframeSrc();var e=function(){var e=F;e.readyToAttachIframe()&&e.attachIframe();};v.addEventListener("load",function(){S.windowLoaded=!0,e();});try{te.receiveMessage(function(e){F.receiveMessage(e.data);},F.iframeHost);}catch(e){}}}(),function(){g.whitelistIframeDomains&&re.POST_MESSAGE_ENABLED&&(g.whitelistIframeDomains=g.whitelistIframeDomains instanceof Array?g.whitelistIframeDomains:[g.whitelistIframeDomains],g.whitelistIframeDomains.forEach(function(e){var n=new B(t,e),i=K(g,n);te.receiveMessage(i,e);}));}();};};qe.config=se,_.Visitor=qe;var Xe=qe,We=function(e){if(j.isObject(e))return Object.keys(e).filter(function(t){return ""!==e[t]}).reduce(function(t,n){var i="doesOptInApply"!==n?e[n]:se.normalizeConfig(e[n]),r=j.normalizeBoolean(i);return t[n]=r,t},Object.create(null))},Je=Ve.OptIn,Ke=Ve.IabPlugin;return Xe.getInstance=function(e,t){if(!e)throw new Error("Visitor requires Adobe Marketing Cloud Org ID.");e.indexOf("@")<0&&(e+="@AdobeOrg");var n=function(){var t=_.s_c_il;if(t)for(var n=0;na.indexOf(b)?a:a.split(b).join(d)};a.escape=function(c){var b,d;if(!c)return c;c=encodeURIComponent(c);for(b=0;7>b;b++)d="+~!*()'".substring(b,b+1),0<=c.indexOf(d)&&(c=a.replace(c,d,"%"+d.charCodeAt(0).toString(16).toUpperCase()));return c};a.unescape=function(c){if(!c)return c;c=0<=c.indexOf("+")?a.replace(c,"+"," "):c;try{return decodeURIComponent(c)}catch(b){}return unescape(c)};a.Mb=function(){var c=h.location.hostname,b=a.fpCookieDomainPeriods,d;b||(b=a.cookieDomainPeriods); +if(c&&!a.Ja&&!/^[0-9.]+$/.test(c)&&(b=b?parseInt(b):2,b=2d?"":a.unescape(b.substring(d+2+c.length,0>f?b.length:f));return "[[B]]"!=c?c:""};a.c_w=a.cookieWrite=function(c,b,d){var f=a.Mb(),e=a.cookieLifetime,g;b=""+b;e=e?(""+e).toUpperCase():"";d&&"SESSION"!=e&&"NONE"!= +e&&((g=""!=b?parseInt(e?e:0):-60)?(d=new Date,d.setTime(d.getTime()+1E3*g)):1===d&&(d=new Date,g=d.getYear(),d.setYear(g+2+(1900>g?1900:0))));return c&&"NONE"!=e?(a.d.cookie=a.escape(c)+"="+a.escape(""!=b?b:"[[B]]")+"; path=/;"+(d&&"SESSION"!=e?" expires="+d.toUTCString()+";":"")+(f?" domain="+f+";":"")+(a.writeSecureCookies?" secure;":""),a.cookieRead(c)==b):0};a.Jb=function(){var c=a.Util.getIeVersion();"number"===typeof c&&10>c&&(a.unsupportedBrowser=!0,a.wb(a,function(){}));};a.xa=function(){var a= +navigator.userAgent;return "Microsoft Internet Explorer"===navigator.appName||0<=a.indexOf("MSIE ")||0<=a.indexOf("Trident/")&&0<=a.indexOf("Windows NT 6")?!0:!1};a.wb=function(a,b){for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&"function"===typeof a[d]&&(a[d]=b);};a.K=[];a.ea=function(c,b,d){if(a.Ka)return 0;a.maxDelay||(a.maxDelay=250);var f=0,e=(new Date).getTime()+a.maxDelay,g=a.d.visibilityState,k=["webkitvisibilitychange","visibilitychange"];g||(g=a.d.webkitVisibilityState);if(g&&"prerender"== +g){if(!a.fa)for(a.fa=1,d=0;dc){a.K.unshift(d);setTimeout(a.delayReady,parseInt(a.maxDelay/2));break}a.Ka=1;a[d.m].apply(a, +d.a);a.Ka=0;}};a.setAccount=a.sa=function(c){var b,d;if(!a.ea("setAccount",arguments))if(a.account=c,a.allAccounts)for(b=a.allAccounts.concat(c.split(",")),a.allAccounts=[],b.sort(),d=0;de.indexOf(".contextData."))switch(h=k.substring(0,4),n=k.substring(4),k){case "transactionID":k="xact";break;case "channel":k="ch";break;case "campaign":k="v0";break;default:a.Qa(n)&&("prop"==h?k="c"+n:"eVar"==h?k="v"+n:"list"== +h?k="l"+n:"hier"==h&&(k="h"+n,l=l.substring(0,255)));}g+="&"+a.escape(k)+"="+a.escape(l);}}""!=g&&(g+="&."+c);}return g};a.usePostbacks=0;a.Pb=function(){var c="",b,d,f,e,g,k,l,h,n="",m="",p=e="",r=a.T();if(a.lightProfileID)b=a.O,(n=a.lightTrackVars)&&(n=","+n+","+a.ka.join(",")+",");else{b=a.g;if(a.pe||a.linkType)n=a.linkTrackVars,m=a.linkTrackEvents,a.pe&&(e=a.pe.substring(0,1).toUpperCase()+a.pe.substring(1),a[e]&&(n=a[e].cc,m=a[e].bc));n&&(n=","+n+","+a.F.join(",")+",");m&&(m=","+m+",",n&&(n+=",events,")); +a.events2&&(p+=(""!=p?",":"")+a.events2);}if(r&&r.getCustomerIDs){e=q;if(g=r.getCustomerIDs())for(d in g)Object.prototype[d]||(f=g[d],"object"==typeof f&&(e||(e={}),f.id&&(e[d+".id"]=f.id),f.authState&&(e[d+".as"]=f.authState)));e&&(c+=a.o("cid",e));}a.AudienceManagement&&a.AudienceManagement.isReady()&&(c+=a.o("d",a.AudienceManagement.getEventCallConfigParams()));for(d=0;df||0<=e&&f>e||0<=g&&f>g)&&(e=a.protocol&&1f?0:f)+"/":"")+d);return d};a.L=function(c){var b=a.B(c),d,f,e="",g=0;return b&&(d=c.protocol,f=c.onclick,!c.href||"A"!=b&&"AREA"!=b||f&&d&&!(0>d.toLowerCase().indexOf("javascript"))?f?(e=a.replace(a.replace(a.replace(a.replace(""+f,"\r",""),"\n",""),"\t","")," ",""),g=2):"INPUT"==b||"SUBMIT"==b?(c.value?e=c.value:c.innerText?e=c.innerText:c.textContent&&(e=c.textContent),g=3):"IMAGE"==b&&c.src&&(e=c.src):e=a.Ma(c),e)?{id:e.substring(0,100),type:g}:0};a.ic=function(c){for(var b=a.B(c),d=a.L(c);c&& +!d&&"BODY"!=b;)if(c=c.parentElement?c.parentElement:c.parentNode)b=a.B(c),d=a.L(c);d&&"BODY"!=b||(c=0);c&&(b=c.onclick?""+c.onclick:"",0<=b.indexOf(".tl(")||0<=b.indexOf(".trackLink("))&&(c=0);return c};a.Xb=function(){var c,b,d=a.linkObject,f=a.linkType,e=a.linkURL,g,k;a.la=1;d||(a.la=0,d=a.clickObject);if(d){c=a.B(d);for(b=a.L(d);d&&!b&&"BODY"!=c;)if(d=d.parentElement?d.parentElement:d.parentNode)c=a.B(d),b=a.L(d);b&&"BODY"!=c||(d=0);if(d&&!a.linkObject){var l=d.onclick?""+d.onclick:"";if(0<=l.indexOf(".tl(")|| +0<=l.indexOf(".trackLink("))d=0;}}else a.la=1;!e&&d&&(e=a.Ma(d));e&&!a.linkLeaveQueryString&&(g=e.indexOf("?"),0<=g&&(e=e.substring(0,g)));if(!f&&e){var m=0,n=0,p;if(a.trackDownloadLinks&&a.linkDownloadFileTypes)for(l=e.toLowerCase(),g=l.indexOf("?"),k=l.indexOf("#"),0<=g?0<=k&&kb)return 0}return 1};a.S=function(c,b){var d,f,e,g,k,h,m;m={};for(d=0;2>d;d++)for(f=0b;b++)for(d=0c.indexOf("-")){for(c=0;16>c;c++)f= +Math.floor(Math.random()*f),b+="0123456789ABCDEF".substring(f,f+1),f=Math.floor(Math.random()*e),d+="0123456789ABCDEF".substring(f,f+1),f=e=16;c=b+"-"+d;}a.cookieWrite("s_fid",c,1)||(c=0);return c};a.Ea=function(c){var b=new Date,d="s"+Math.floor(b.getTime()/108E5)%10+Math.floor(1E13*Math.random()),f=b.getYear(),f="t="+a.escape(b.getDate()+"/"+b.getMonth()+"/"+(1900>f?f+1900:f)+" "+b.getHours()+":"+b.getMinutes()+":"+b.getSeconds()+" "+b.getDay()+" "+b.getTimezoneOffset()),e=a.T(),g;c&&(g=a.S(c,1)); +a.Ub()&&!a.visitorOptedOut&&(a.wa()||(a.fid=a.Nb()),a.Xb(),a.usePlugins&&a.doPlugins&&a.doPlugins(a),a.account&&(a.abort||(a.trackOffline&&!a.timestamp&&(a.timestamp=Math.floor(b.getTime()/1E3)),c=h.location,a.pageURL||(a.pageURL=c.href?c.href:c),a.referrer||a.Za||(c=a.Util.getQueryParam("adobe_mc_ref",null,null,!0),a.referrer=c||void 0===c?void 0===c?"":c:p.document.referrer),a.Za=1,a.referrer=a.Lb(a.referrer),a.u("_g")),a.Qb()&&!a.abort&&(e&&a.V("TARGET")&&!a.supplementalDataID&&e.getSupplementalDataID&& +(a.supplementalDataID=e.getSupplementalDataID("AppMeasurement:"+a._in,a.expectSupplementalData?!1:!0)),a.V("AAM")||(a.contextData["cm.ssf"]=1),a.Rb(),a.vb(),f+=a.Pb(),a.rb(d,f),a.u("_t"),a.referrer="")));a.Ca();g&&a.S(g,1);};a.t=a.track=function(c,b){b&&a.S(b);a.Y=!0;a.isReadyToTrack()?null!=a.j&&0a.N&&a.Va(a.i),a.qa(500);else{var c=a.Eb();if(0=a.offlineThrottleDelay)return 0;c=a.A()-a.Ta;return a.offlineThrottleDelaya.N&&a.Va(a.i);a.ca();a.qa(500);};b.onreadystatechange=function(){4==b.readyState&&(200== +b.status?b.R():b.ga());};a.Ta=a.A();if(1===d)b.send(c);else if(2===d)f=c.indexOf("?"),d=c.substring(0,f),f=c.substring(f+1),f=f.replace(/&callback=[a-zA-Z0-9_.\[\]]+/,""),b.open("POST",d,!0),b.withCredentials=!0,b.send(f);else if(b.src=c,3===d){if(a.Ra)try{f.removeChild(a.Ra);}catch(e){}f.firstChild?f.insertBefore(b,f.firstChild):f.appendChild(b);a.Ra=a.v;}b.D=setTimeout(function(){b.D&&(b.complete?b.R():(a.trackOffline&&b.abort&&b.abort(),b.ga()));},5E3);a.Hb=c;a.v=h["s_i_"+a.replace(a.account,",","_")]= +b;if(a.useForcedLinkTracking&&a.J||a.bodyClickFunction)a.forcedLinkTrackingTimeout||(a.forcedLinkTrackingTimeout=250),a.da=setTimeout(a.ca,a.forcedLinkTrackingTimeout);};a.mb=function(c){var b=!1;navigator.sendBeacon&&(a.ob(c)?b=!0:a.useBeacon&&(b=!0));a.xb(c)&&(b=!1);return b};a.ob=function(a){return a&&0a.N))try{h.localStorage.removeItem(a.ma()),a.Sa=a.A();}catch(c){}};a.Va=function(c){if(a.oa()){a.Xa();try{h.localStorage.setItem(a.ma(),h.JSON.stringify(c)),a.N=a.A();}catch(b){}}};a.Xa=function(){if(a.trackOffline){if(!a.offlineLimit||0>=a.offlineLimit)a.offlineLimit=10;for(;a.i.length>a.offlineLimit;)a.La();}};a.forceOffline=function(){a.na=!0;};a.forceOnline=function(){a.na=!1;};a.ma=function(){return a.offlineFilename+"-"+a.visitorNamespace+a.account};a.A=function(){return (new Date).getTime()}; +a.Pa=function(a){a=a.toLowerCase();return 0!=a.indexOf("#")&&0!=a.indexOf("about:")&&0!=a.indexOf("opera:")&&0!=a.indexOf("javascript:")?!0:!1};a.setTagContainer=function(c){var b,d,f;a.$b=c;for(b=0;b(""+f[b]).indexOf("s_c_il"))&&(c[b]=f[b]);if(d.mmq)for(b= +0;be)return g;b=d+b.substring(e+1)+d;if(!f||!(0<=b.indexOf(d+c+d)||0<=b.indexOf(d+ +c+"="+d))){e=b.indexOf("#");0<=e&&(b=b.substr(0,e)+d);e=b.indexOf(d+c+"=");if(0>e)return g;b=b.substring(e+d.length+c.length+1);e=b.indexOf(d);0<=e&&(b=b.substring(0,e));0=m;m++)76>m&&(a.g.push("prop"+m),a.O.push("prop"+m)),a.g.push("eVar"+m),a.O.push("eVar"+m),6>m&&a.g.push("hier"+m),4>m&&a.g.push("list"+m);m="pe pev1 pev2 pev3 latitude longitude resolution colorDepth javascriptVersion javaEnabled cookiesEnabled browserWidth browserHeight connectionType homepage pageURLRest marketingCloudOrgID ms_a".split(" ");a.g=a.g.concat(m);a.F=a.F.concat(m);a.ssl=0<=h.location.protocol.toLowerCase().indexOf("https");a.charSet="UTF-8";a.contextData={};a.writeSecureCookies= +!1;a.offlineThrottleDelay=0;a.offlineFilename="AppMeasurement.offline";a.P="s_sq";a.Ta=0;a.ia=0;a.N=0;a.Sa=0;a.linkDownloadFileTypes="exe,zip,wav,mp3,mov,mpg,avi,wmv,pdf,doc,docx,xls,xlsx,ppt,pptx";a.w=h;a.d=h.document;a.ca=function(){a.da&&(h.clearTimeout(a.da),a.da=q);a.bodyClickTarget&&a.J&&a.bodyClickTarget.dispatchEvent(a.J);a.bodyClickFunction&&("function"==typeof a.bodyClickFunction?a.bodyClickFunction():a.bodyClickTarget&&a.bodyClickTarget.href&&(a.d.location=a.bodyClickTarget.href));a.bodyClickTarget= +a.J=a.bodyClickFunction=0;};a.Wa=function(){a.b=a.d.body;a.b?(a.r=function(c){var b,d,f,e,g;if(!(a.d&&a.d.getElementById("cppXYctnr")||c&&c["s_fe_"+a._in])){if(a.Ha)if(a.useForcedLinkTracking)a.b.removeEventListener("click",a.r,!1);else{a.b.removeEventListener("click",a.r,!0);a.Ha=a.useForcedLinkTracking=0;return}else a.useForcedLinkTracking=0;a.clickObject=c.srcElement?c.srcElement:c.target;try{if(!a.clickObject||a.M&&a.M==a.clickObject||!(a.clickObject.tagName||a.clickObject.parentElement||a.clickObject.parentNode))a.clickObject= +0;else{var k=a.M=a.clickObject;a.ha&&(clearTimeout(a.ha),a.ha=0);a.ha=setTimeout(function(){a.M==k&&(a.M=0);},1E4);f=a.Na();a.track();if(f 0) { + setMCIDOnIntegrationAttributes(mcID); + } + + if (forwarderSettings.mediaTrackingServer) { + self.adobeMediaSDK.init(forwarderSettings, service, testMode); + } + isAdobeServerKitInitialized = true; + return 'Adobe Server Side Integration Ready'; + } catch (e) { + return 'Failed to initialize: ' + e; + } + } + + function setMarketingCloudId(mcid) { + setMCIDOnIntegrationAttributes(mcid); + } + + function processEvent(event) { + if (isAdobeServerKitInitialized) { + try { + if (event.EventDataType === MessageType$1.Media) { + self.adobeMediaSDK.process(event); + } + } catch (e) { + return 'Failed to send to: ' + name + ' ' + e; + } + } else { + return "Can't send to forwarder " + name + ', not initialized.'; + } + } + + this.init = initForwarder; + this.process = processEvent; +}; + +function setMCIDOnIntegrationAttributes(mcid) { + var adobeIntegrationAttributes = {}; + adobeIntegrationAttributes[MARKETINGCLOUDIDKEY] = mcid; + mParticle.setIntegrationAttribute( + ADOBEMODULENUMBER, + adobeIntegrationAttributes + ); + mParticle._setIntegrationDelay(ADOBEMODULENUMBER, false); +} + +function getId() { + return moduleId; +} + +if (window && window.mParticle && window.mParticle.addForwarder) { + window.mParticle.addForwarder({ + name: name, + suffix: suffix, + constructor: constructor$1, + getId: getId, + }); +} + +function register(config) { + var forwarderNameWithSuffix = [name, suffix].join('-'); + if (!config) { + window.console.log( + 'You must pass a config object to register the kit ' + + forwarderNameWithSuffix + ); + return; + } + + if (!isObject(config)) { + window.console.log( + "'config' must be an object. You passed in a " + typeof config + ); + return; + } + + if (isObject(config.kits)) { + config.kits[forwarderNameWithSuffix] = { + constructor: constructor$1, + }; + } else { + config.kits = {}; + config.kits[forwarderNameWithSuffix] = { + constructor: constructor$1, + }; + } + window.console.log( + 'Successfully registered ' + + forwarderNameWithSuffix + + ' to your mParticle configuration' + ); +} + +function isObject(val) { + return ( + val != null && typeof val === 'object' && Array.isArray(val) === false + ); +} + +var AdobeServerSideKit_esm = { + register: register, +}; + +module.exports = AdobeServerSideKit_esm; diff --git a/kits/adobe/packages/AdobeServer/dist/AdobeServerSideKit.iife.js b/kits/adobe/packages/AdobeServer/dist/AdobeServerSideKit.iife.js new file mode 100644 index 000000000..5592aeadb --- /dev/null +++ b/kits/adobe/packages/AdobeServer/dist/AdobeServerSideKit.iife.js @@ -0,0 +1,781 @@ +var mParticleAdobeServer = (function () { + function Common() { + this.playheadPosition = 0; + this.startupTime = 0; + this.droppedFrames = 0; + this.bitRate = 0; + this.fps = 0; + } + + var common = Common; + + var MediaEventType = { + Play: 23, + Pause: 24, + ContentEnd: 25, + SessionStart: 30, + SessionEnd: 31, + SeekStart: 32, + SeekEnd: 33, + BufferStart: 34, + BufferEnd: 35, + UpdatePlayheadPosition: 36, + AdClick: 37, + AdBreakStart: 38, + AdBreakEnd: 39, + AdStart: 40, + AdEnd: 41, + AdSkip: 42, + SegmentStart: 43, + SegmentEnd: 44, + SegmentSkip: 45, + UpdateQoS: 46, + }; + + var ContentType = { + Audio: 'Audio', + Video: 'Video', + }; + + var StreamType = { + LiveStream: 'LiveStream', + OnDemand: 'OnDemand', + Linear: 'Linear', + Podcast: 'Podcast', + Audiobook: 'Audiobook', + }; + + function EventHandler(common) { + this.common = common || {}; + } + EventHandler.prototype.logEvent = function(event) { + var customAttributes = {}; + if (event && event.EventAttributes) { + customAttributes = event.EventAttributes; + } + + if (event && event.PlayheadPosition) { + this.common.playheadPosition = event.PlayheadPosition / 1000; + } + + switch (event.EventCategory) { + case MediaEventType.AdBreakStart: + var adBreakObject = this.common.MediaHeartbeat.createAdBreakObject( + event.AdBreak.title, + event.AdBreak.placement || 0, // TODO: Ad Break Object doesn't support placement yet + this.common.playheadPosition + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdBreakStart, + adBreakObject, + customAttributes + ); + break; + case MediaEventType.AdBreakEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdBreakComplete, + {}, + customAttributes + ); + break; + case MediaEventType.AdStart: + var adObject = this.common.MediaHeartbeat.createAdObject( + event.AdContent.title, + event.AdContent.id, + event.AdContent.position, + event.AdContent.duration / 1000 + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdStart, + adObject, + customAttributes + ); + break; + case MediaEventType.AdEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdComplete, + {}, + customAttributes + ); + break; + case MediaEventType.AdSkip: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.AdSkip, + {}, + customAttributes + ); + break; + case MediaEventType.AdClick: + // This is not supported in Adobe Heartbeat + console.warn('Ad Click is not a supported Adobe Heartbeat Event'); + break; + case MediaEventType.BufferStart: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.BufferStart, + {}, + customAttributes + ); + break; + case MediaEventType.BufferEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.BufferComplete, + {}, + customAttributes + ); + break; + case MediaEventType.ContentEnd: + this.common.mediaHeartbeat.trackComplete(); + break; + case MediaEventType.SessionStart: + var streamType = getStreamType( + event.StreamType, + event.ContentType, + this.common.MediaHeartbeat.StreamType + ); + + var adobeMediaObject = this.common.MediaHeartbeat.createMediaObject( + event.ContentTitle, + event.ContentId, + event.Duration / 1000, + streamType, + event.ContentType + ); + + var combinedAttributes = getAdobeMetadataKeys( + customAttributes, + this.common.MediaHeartbeat + ); + + this.common.mediaHeartbeat.trackSessionStart( + adobeMediaObject, + combinedAttributes + ); + break; + + case MediaEventType.SessionEnd: + this.common.mediaHeartbeat.trackSessionEnd(); + break; + case MediaEventType.Play: + this.common.mediaHeartbeat.trackPlay(); + break; + case MediaEventType.Pause: + this.common.mediaHeartbeat.trackPause(); + break; + case MediaEventType.UpdatePlayheadPosition: + // This is commented out because we're updating playhead position + // for all events and Adobe does not have a relevant playhead + // update position function + break; + case MediaEventType.SeekStart: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.SeekStart, + {}, + customAttributes + ); + break; + case MediaEventType.SeekEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.SeekComplete, + {}, + customAttributes + ); + break; + case MediaEventType.SegmentStart: + var chapterObject = this.common.MediaHeartbeat.createChapterObject( + event.Segment.title, + event.Segment.index, + event.Segment.duration / 1000, + this.common.playheadPosition + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.ChapterStart, + chapterObject, + customAttributes + ); + break; + case MediaEventType.SegmentEnd: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.ChapterComplete, + {}, + customAttributes + ); + break; + case MediaEventType.SegmentSkip: + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.ChapterSkip, + {}, + customAttributes + ); + break; + case MediaEventType.UpdateQoS: + this.common.startupTime = event.QoS.startupTime / 1000; + this.common.droppedFrames = event.QoS.droppedFrames; + this.common.bitRate = event.QoS.bitRate; + this.common.fps = event.QoS.fps; + + var qosObject = this.common.MediaHeartbeat.createQoSObject( + this.common.bitRate, + this.common.startupTime, + this.common.fps, + this.common.droppedFrames + ); + + this.common.mediaHeartbeat.trackEvent( + this.common.MediaHeartbeat.Event.BitrateChange, + qosObject, + customAttributes + ); + break; + default: + console.error('Unknown Event Type', event); + return false; + } + }; + + var getAdobeMetadataKeys = function(attributes, Heartbeat) { + var AdobeMetadataLookupTable = { + // Ad Meta Data + ad_content_advertiser: Heartbeat.AdMetadataKeys.ADVERTISER, + ad_content_campaign: Heartbeat.AdMetadataKeys.CAMPAIGN_ID, + ad_content_creative: Heartbeat.AdMetadataKeys.CREATIVE_ID, + ad_content_placement: Heartbeat.AdMetadataKeys.PLACEMENT_ID, + ad_content_site_id: Heartbeat.AdMetadataKeys.SITE_ID, + ad_content_creative_url: Heartbeat.AdMetadataKeys.CREATIVE_URL, + + // Audio Meta + content_artist: Heartbeat.AudioMetadataKeys.ARTIST, + content_album: Heartbeat.AudioMetadataKeys.ALBUM, + content_label: Heartbeat.AudioMetadataKeys.LABEL, + content_author: Heartbeat.AudioMetadataKeys.AUTHOR, + content_station: Heartbeat.AudioMetadataKeys.STATION, + content_publisher: Heartbeat.AudioMetadataKeys.PUBLISHER, + + // Video Meta + content_show: Heartbeat.VideoMetadataKeys.SHOW, + stream_format: Heartbeat.VideoMetadataKeys.STREAM_FORMAT, + content_season: Heartbeat.VideoMetadataKeys.SEASON, + content_episode: Heartbeat.VideoMetadataKeys.EPISODE, + content_asset_id: Heartbeat.VideoMetadataKeys.ASSET_ID, + content_genre: Heartbeat.VideoMetadataKeys.GENRE, + content_first_air_date: Heartbeat.VideoMetadataKeys.FIRST_AIR_DATE, + content_digital_date: Heartbeat.VideoMetadataKeys.FIRST_DIGITAL_DATE, + content_rating: Heartbeat.VideoMetadataKeys.RATING, + content_originator: Heartbeat.VideoMetadataKeys.ORIGINATOR, + content_network: Heartbeat.VideoMetadataKeys.NETWORK, + content_show_type: Heartbeat.VideoMetadataKeys.SHOW_TYPE, + content_ad_load: Heartbeat.VideoMetadataKeys.AD_LOAD, + content_mvpd: Heartbeat.VideoMetadataKeys.MVPD, + content_authorized: Heartbeat.VideoMetadataKeys.AUTHORIZED, + content_daypart: Heartbeat.VideoMetadataKeys.DAY_PART, + content_feed: Heartbeat.VideoMetadataKeys.FEED, + }; + + var adobeMetadataKeys = {}; + for (var attribute in attributes) { + var key = attribute; + if (AdobeMetadataLookupTable[attribute]) { + key = AdobeMetadataLookupTable[attribute]; + } + adobeMetadataKeys[key] = attributes[attribute]; + } + + return adobeMetadataKeys; + }; + + var getStreamType = function(streamType, contentType, types) { + switch (streamType) { + case StreamType.OnDemand: + return contentType === ContentType.Video ? types.VOD : types.AOD; + case StreamType.LiveStream: + return types.LIVE; + case StreamType.Linear: + return types.LINEAR; + case StreamType.Podcast: + return types.PODCAST; + case StreamType.Audiobook: + return types.AUDIOBOOK; + default: + // If it's an unknown type, just pass it through to Adobe + return streamType; + } + }; + + var eventHandler = EventHandler; + + var Initialization = { + name: 'AdobeHeartbeat', + moduleId: 124, + initForwarder: function( + settings, + testMode, + userAttributes, + userIdentities, + processEvent, + eventQueue, + common, + initForwarderCallback + ) { + var self = this; + if (!window.mParticle.isTestEnvironment || !window.ADB) { + /* Load your Web SDK here using a variant of your snippet from your readme that your customers would generally put into their tags + Generally, our integrations create script tags and append them to the . Please follow the following format as a guide: + */ + var adobeHeartbeatSdk = document.createElement('script'); + adobeHeartbeatSdk.type = 'text/javascript'; + adobeHeartbeatSdk.async = true; + adobeHeartbeatSdk.src = + 'https://static.mparticle.com/sdk/web/adobe/MediaSDK.min.js'; + ( + document.getElementsByTagName('head')[0] || + document.getElementsByTagName('body')[0] + ).appendChild(adobeHeartbeatSdk); + adobeHeartbeatSdk.onload = function() { + if (ADB) { + self.initHeartbeat( + settings, + common, + ADB, + testMode, + initForwarderCallback + ); + if (eventQueue.length > 0) { + // Process any events that may have been queued up while forwarder was being initialized. + for (var i = 0; i < eventQueue.length; i++) { + processEvent(eventQueue[i]); + } + // now that each queued event is processed, we empty the eventQueue + eventQueue = []; + } + } + }; + } else { + // For testing, you should fill out this section in order to ensure any required initialization calls are made, + // clientSDKObject.initialize(forwarderSettings.apiKey) + self.initHeartbeat( + settings, + common, + ADB, + testMode, + initForwarderCallback + ); + } + }, + initHeartbeat: function( + settings, + common, + adobeSDK, + testMode, + initHeartbeatCallback + ) { + try { + // Init App Measurement with Visitor + var appMeasurement = new AppMeasurement(settings.reportSuiteIDs); + var visitorOptions = {}; + if (settings.audienceManagerServer) { + visitorOptions.audienceManagerServer = + settings.audienceManagerServer; + } + + appMeasurement.visitor = Visitor.getInstance( + settings.organizationID, + visitorOptions + ); + appMeasurement.trackingServer = settings.trackingServer; + appMeasurement.account = settings.reportSuiteIDs; + appMeasurement.pageName = document.title; + appMeasurement.charSet = 'UTF­8'; + + // Init Media Heartbeat + + var MediaHeartbeat = adobeSDK.va.MediaHeartbeat; + var MediaHeartbeatConfig = adobeSDK.va.MediaHeartbeatConfig; + var MediaHeartbeatDelegate = adobeSDK.va.MediaHeartbeatDelegate; + var mediaConfig = new MediaHeartbeatConfig(); + common.MediaHeartbeat = MediaHeartbeat; + + mediaConfig.trackingServer = settings.mediaTrackingServer; + mediaConfig.ssl = settings.useSSL === 'True'; + mediaConfig.playerName = 'mParticle Media SDK'; + + var mediaDelegate = new MediaHeartbeatDelegate(); + + mediaDelegate.getCurrentPlaybackTime = function() { + return common.playheadPosition; + }; + + mediaDelegate.getQoSObject = function() { + return MediaHeartbeat.createQoSObject( + common.bitRate, + common.startupTime, + common.fps, + common.droppedFrames + ); + }; + + var mediaHeartbeat = new MediaHeartbeat( + mediaDelegate, + mediaConfig, + appMeasurement + ); + common.mediaHeartbeat = mediaHeartbeat; + } catch (e) { + console.error(e); + } + + initHeartbeatCallback(); + }, + }; + + var initialization = Initialization; + + // =============== REACH OUT TO MPARTICLE IF YOU HAVE ANY QUESTIONS =============== + // + // Copyright 2018 mParticle, Inc. + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + + + + + + var MessageType = { + SessionStart: 1, + SessionEnd: 2, + PageView: 3, + PageEvent: 4, + CrashReport: 5, + OptOut: 6, + Commerce: 16, + Media: 20, + }; + + function constructor() { + var self = this, + isAdobeMediaSDKInitialized = false, + reportingService, + eventQueue = [], + name = 'AdobeHeartbeatKit'; + + self.moduleId = initialization.moduleId; + self.common = new common(); + + var initForwarderCallback = function() { + isAdobeMediaSDKInitialized = true; + }; + + function initForwarder( + settings, + service, + testMode, + trackerId, + userAttributes, + userIdentities + ) { + if (window.mParticle.isTestEnvironment) { + reportingService = function() {}; + } else { + reportingService = service; + } + + try { + initialization.initForwarder( + settings, + testMode, + userAttributes, + userIdentities, + processEvent, + eventQueue, + self.common, + initForwarderCallback + ); + self.eventHandler = new eventHandler(self.common); + } catch (e) { + console.error('Failed to initialize ' + name, e); + } + } + + function processEvent(event) { + var reportEvent = false; + if (isAdobeMediaSDKInitialized) { + try { + if (event.EventDataType === MessageType.Media) { + // Kits should just treat Media Events as generic Events + reportEvent = logEvent(event); + } + if (reportEvent === true && reportingService) { + reportingService(self, event); + return 'Successfully sent to ' + name; + } else { + return ( + 'Error logging event or event type not supported on forwarder ' + + name + ); + } + } catch (e) { + return 'Failed to send to ' + name + ' ' + e; + } + } else { + eventQueue.push(event); + return ( + 'Cannot send to forwarder ' + + name + + ', not initialized. Event added to queue.' + ); + } + } + + function logEvent(event) { + try { + self.eventHandler.logEvent(event); + return true; + } catch (e) { + return { + error: 'Error logging event on forwarder ' + name + '; ' + e, + }; + } + } + + this.init = initForwarder; + this.process = processEvent; + } + + if (window.mParticle && window.mParticle.registerHBK) { + window.mParticle.registerHBK({ constructor: constructor }); + } + + var src = { + AdobeHbkConstructor: constructor, + }; + var src_1 = src.AdobeHbkConstructor; + + /** + * @license + * Adobe Visitor API for JavaScript version: 4.4.0 + * Copyright 2019 Adobe, Inc. All Rights Reserved + * More info available at https://marketing.adobe.com/resources/help/en_US/mcvid/ + */ + var e=function(){function e(t){return (e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(){return {callbacks:{},add:function(e,t){this.callbacks[e]=this.callbacks[e]||[];var n=this.callbacks[e].push(t)-1,i=this;return function(){i.callbacks[e].splice(n,1);}},execute:function(e,t){if(this.callbacks[e]){t=void 0===t?[]:t,t=t instanceof Array?t:[t];try{for(;this.callbacks[e].length;){var n=this.callbacks[e].shift();"function"==typeof n?n.apply(null,t):n instanceof Array&&n[1].apply(n[0],t);}delete this.callbacks[e];}catch(e){}}},executeAll:function(e,t){(t||e&&!j.isObjectEmpty(e))&&Object.keys(this.callbacks).forEach(function(t){var n=void 0!==e[t]?e[t]:"";this.execute(t,n);},this);},hasCallbacks:function(){return Boolean(Object.keys(this.callbacks).length)}}}function i(e,t,n){var i=null==e?void 0:e[t];return void 0===i?n:i}function r(e){for(var t=/^\d+$/,n=0,i=e.length;nr)return 1;if(r>i)return -1}return 0}function s(e,t){if(e===t)return 0;var n=e.toString().split("."),i=t.toString().split(".");return r(n.concat(i))?(a(n,i),o(n,i)):NaN}function l(e){return e===Object(e)&&0===Object.keys(e).length}function c(e){return "function"==typeof e||e instanceof Array&&e.length}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){return !0};this.log=_e("log",e,t),this.warn=_e("warn",e,t),this.error=_e("error",e,t);}function d(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.isEnabled,n=e.cookieName,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i.cookies;return t&&n&&r?{remove:function(){r.remove(n);},get:function(){var e=r.get(n),t={};try{t=JSON.parse(e);}catch(e){t={};}return t},set:function(e,t){t=t||{},r.set(n,JSON.stringify(e),{domain:t.optInCookieDomain||"",cookieLifetime:t.optInStorageExpiry||3419e4,expires:!0});}}:{get:Le,set:Le,remove:Le}}function f(e){this.name=this.constructor.name,this.message=e,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error(e).stack;}function p(){function e(e,t){var n=Se(e);return n.length?n.every(function(e){return !!t[e]}):De(t)}function t(){M(b),O(ce.COMPLETE),_(h.status,h.permissions),m.set(h.permissions,{optInCookieDomain:l,optInStorageExpiry:c}),C.execute(xe);}function n(e){return function(n,i){if(!Ae(n))throw new Error("[OptIn] Invalid category(-ies). Please use the `OptIn.Categories` enum.");return O(ce.CHANGED),Object.assign(b,ye(Se(n),e)),i||t(),h}}var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.doesOptInApply,a=i.previousPermissions,o=i.preOptInApprovals,s=i.isOptInStorageEnabled,l=i.optInCookieDomain,c=i.optInStorageExpiry,u=i.isIabContext,f=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},p=f.cookies,g=Pe(a);Re(g,"Invalid `previousPermissions`!"),Re(o,"Invalid `preOptInApprovals`!");var m=d({isEnabled:!!s,cookieName:"adobeujs-optin"},{cookies:p}),h=this,_=le(h),C=ge(),I=Me(g),v=Me(o),S=m.get(),D={},A=function(e,t){return ke(e)||t&&ke(t)?ce.COMPLETE:ce.PENDING}(I,S),y=function(e,t,n){var i=ye(pe,!r);return r?Object.assign({},i,e,t,n):i}(v,I,S),b=be(y),O=function(e){return A=e},M=function(e){return y=e};h.deny=n(!1),h.approve=n(!0),h.denyAll=h.deny.bind(h,pe),h.approveAll=h.approve.bind(h,pe),h.isApproved=function(t){return e(t,h.permissions)},h.isPreApproved=function(t){return e(t,v)},h.fetchPermissions=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=t?h.on(ce.COMPLETE,e):Le;return !r||r&&h.isComplete||!!o?e(h.permissions):t||C.add(xe,function(){return e(h.permissions)}),n},h.complete=function(){h.status===ce.CHANGED&&t();},h.registerPlugin=function(e){if(!e||!e.name||"function"!=typeof e.onRegister)throw new Error(je);D[e.name]||(D[e.name]=e,e.onRegister.call(e,h));},h.execute=Ne(D),Object.defineProperties(h,{permissions:{get:function(){return y}},status:{get:function(){return A}},Categories:{get:function(){return ue}},doesOptInApply:{get:function(){return !!r}},isPending:{get:function(){return h.status===ce.PENDING}},isComplete:{get:function(){return h.status===ce.COMPLETE}},__plugins:{get:function(){return Object.keys(D)}},isIabContext:{get:function(){return u}}});}function g(e,t){function n(){r=null,e.call(e,new f("The call took longer than you wanted!"));}function i(){r&&(clearTimeout(r),e.apply(e,arguments));}if(void 0===t)return e;var r=setTimeout(n,t);return i}function m(){if(window.__cmp)return window.__cmp;var e=window;if(e===window.top)return void Ie.error("__cmp not found");for(var t;!t;){e=e.parent;try{e.frames.__cmpLocator&&(t=e);}catch(e){}if(e===window.top)break}if(!t)return void Ie.error("__cmp not found");var n={};return window.__cmp=function(e,i,r){var a=Math.random()+"",o={__cmpCall:{command:e,parameter:i,callId:a}};n[a]=r,t.postMessage(o,"*");},window.addEventListener("message",function(e){var t=e.data;if("string"==typeof t)try{t=JSON.parse(e.data);}catch(e){}if(t.__cmpReturn){var i=t.__cmpReturn;n[i.callId]&&(n[i.callId](i.returnValue,i.success),delete n[i.callId]);}},!1),window.__cmp}function h(){var e=this;e.name="iabPlugin",e.version="0.0.1";var t=ge(),n={allConsentData:null},i=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return n[e]=t};e.fetchConsentData=function(e){var t=e.callback,n=e.timeout,i=g(t,n);r({callback:i});},e.isApproved=function(e){var t=e.callback,i=e.category,a=e.timeout;if(n.allConsentData)return t(null,s(i,n.allConsentData.vendorConsents,n.allConsentData.purposeConsents));var o=g(function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.vendorConsents,a=n.purposeConsents;t(e,s(i,r,a));},a);r({category:i,callback:o});},e.onRegister=function(t){var n=Object.keys(de),i=function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i.purposeConsents,a=i.gdprApplies,o=i.vendorConsents;!e&&a&&o&&r&&(n.forEach(function(e){var n=s(e,o,r);t[n?"approve":"deny"](e,!0);}),t.complete());};e.fetchConsentData({callback:i});};var r=function(e){var r=e.callback;if(n.allConsentData)return r(null,n.allConsentData);t.add("FETCH_CONSENT_DATA",r);var s={};o(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.purposeConsents,o=e.gdprApplies,l=e.vendorConsents;(arguments.length>1?arguments[1]:void 0)&&(s={purposeConsents:r,gdprApplies:o,vendorConsents:l},i("allConsentData",s)),a(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(arguments.length>1?arguments[1]:void 0)&&(s.consentString=e.consentData,i("allConsentData",s)),t.execute("FETCH_CONSENT_DATA",[null,n.allConsentData]);});});},a=function(e){var t=m();t&&t("getConsentData",null,e);},o=function(e){var t=Fe(de),n=m();n&&n("getVendorConsents",t,e);},s=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=!!t[de[e]];return i&&function(){return fe[e].every(function(e){return n[e]})}()};}var _="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};Object.assign=Object.assign||function(e){for(var t,n,i=1;i4;e--){var t=document.createElement("div");if(t.innerHTML="\x3c!--[if IE "+e+"]>=0;n--)if(t=i.slice(n).join("."),Q.set("test","cookie",{domain:t}))return Q.remove("test",{domain:t}),t;return ""},Z={compare:s,isLessThan:function(e,t){return s(e,t)<0},areVersionsDifferent:function(e,t){return 0!==s(e,t)},isGreaterThan:function(e,t){return s(e,t)>0},isEqual:function(e,t){return 0===s(e,t)}},ee=!!_.postMessage,te={postMessage:function(e,t,n){var i=1;t&&(ee?n.postMessage(e,t.replace(/([^:]+:\/\/[^\/]+).*/,"$1")):t&&(n.location=t.replace(/#.*$/,"")+"#"+ +new Date+i+++"&"+e));},receiveMessage:function(e,t){var n;try{ee&&(e&&(n=function(n){if("string"==typeof t&&n.origin!==t||"[object Function]"===Object.prototype.toString.call(t)&&!1===t(n.origin))return !1;e(n);}),_.addEventListener?_[e?"addEventListener":"removeEventListener"]("message",n):_[e?"attachEvent":"detachEvent"]("onmessage",n));}catch(e){}}},ne=function(e){var t,n,i="0123456789",r="",a="",o=8,s=10,l=10;if(1==e){for(i+="ABCDEF",t=0;16>t;t++)n=Math.floor(Math.random()*o),r+=i.substring(n,n+1),n=Math.floor(Math.random()*o),a+=i.substring(n,n+1),o=16;return r+"-"+a}for(t=0;19>t;t++)n=Math.floor(Math.random()*s),r+=i.substring(n,n+1),0===t&&9==n?s=3:(1==t||2==t)&&10!=s&&2>n?s=10:2n?l=10:20&&(t=!1)),{corsType:e,corsCookiesEnabled:t}}(),getCORSInstance:function(){return "none"===this.corsMetadata.corsType?null:new _[this.corsMetadata.corsType]},fireCORS:function(t,n,i){function r(e){var n;try{if((n=JSON.parse(e))!==Object(n))return void a.handleCORSError(t,null,"Response is not JSON")}catch(e){return void a.handleCORSError(t,e,"Error parsing response as JSON")}try{for(var i=t.callback,r=_,o=0;o=a&&(e.splice(r,1),r--);return {dataPresent:o,dataValid:s}},manageSyncsSize:function(e){if(e.join("*").length>this.MAX_SYNCS_LENGTH)for(e.sort(function(e,t){return parseInt(e.split("-")[1],10)-parseInt(t.split("-")[1],10)});e.join("*").length>this.MAX_SYNCS_LENGTH;)e.shift();},fireSync:function(t,n,i,r,a,o){var s=this;if(t){if("img"===n.tag){var l,c,u,d,f=n.url,p=e.loadSSL?"https:":"http:";for(l=0,c=f.length;lre.DAYS_BETWEEN_SYNC_ID_CALLS},attachIframeASAP:function(){function e(){t.startedAttachingIframe||(n.body?t.attachIframe():setTimeout(e,30));}var t=this;e();}}},oe={audienceManagerServer:{},audienceManagerServerSecure:{},cookieDomain:{},cookieLifetime:{},cookieName:{},doesOptInApply:{},disableThirdPartyCalls:{},discardTrackingServerECID:{},idSyncAfterIDCallResult:{},idSyncAttachIframeOnWindowLoad:{},idSyncContainerID:{},idSyncDisable3rdPartySyncing:{},disableThirdPartyCookies:{},idSyncDisableSyncs:{},disableIdSyncs:{},idSyncIDCallResult:{},idSyncSSLUseAkamai:{},isCoopSafe:{},isIabContext:{},isOptInStorageEnabled:{},loadSSL:{},loadTimeout:{},marketingCloudServer:{},marketingCloudServerSecure:{},optInCookieDomain:{},optInStorageExpiry:{},overwriteCrossDomainMCIDAndAID:{},preOptInApprovals:{},previousPermissions:{},resetBeforeVersion:{},sdidParamExpiry:{},serverState:{},sessionCookieName:{},secureCookie:{},takeTimeoutMetrics:{},trackingServer:{},trackingServerSecure:{},whitelistIframeDomains:{},whitelistParentDomain:{}},se={getConfigNames:function(){return Object.keys(oe)},getConfigs:function(){return oe},normalizeConfig:function(e){return "function"!=typeof e?e:e()}},le=function(e){var t={};return e.on=function(e,n,i){if(!n||"function"!=typeof n)throw new Error("[ON] Callback should be a function.");t.hasOwnProperty(e)||(t[e]=[]);var r=t[e].push({callback:n,context:i})-1;return function(){t[e].splice(r,1),t[e].length||delete t[e];}},e.off=function(e,n){t.hasOwnProperty(e)&&(t[e]=t[e].filter(function(e){if(e.callback!==n)return e}));},e.publish=function(e){if(t.hasOwnProperty(e)){var n=[].slice.call(arguments,1);t[e].slice(0).forEach(function(e){e.callback.apply(e.context,n);});}},e.publish},ce={PENDING:"pending",CHANGED:"changed",COMPLETE:"complete"},ue={AAM:"aam",ADCLOUD:"adcloud",ANALYTICS:"aa",CAMPAIGN:"campaign",ECID:"ecid",LIVEFYRE:"livefyre",TARGET:"target",VIDEO_ANALYTICS:"videoaa"},de=(C={},t(C,ue.AAM,565),t(C,ue.ECID,565),C),fe=(I={},t(I,ue.AAM,[1,2,5]),t(I,ue.ECID,[1,2,5]),I),pe=function(e){return Object.keys(e).map(function(t){return e[t]})}(ue),ge=function(){var e={};return e.callbacks=Object.create(null),e.add=function(t,n){if(!c(n))throw new Error("[callbackRegistryFactory] Make sure callback is a function or an array of functions.");e.callbacks[t]=e.callbacks[t]||[];var i=e.callbacks[t].push(n)-1;return function(){e.callbacks[t].splice(i,1);}},e.execute=function(t,n){if(e.callbacks[t]){n=void 0===n?[]:n,n=n instanceof Array?n:[n];try{for(;e.callbacks[t].length;){var i=e.callbacks[t].shift();"function"==typeof i?i.apply(null,n):i instanceof Array&&i[1].apply(i[0],n);}delete e.callbacks[t];}catch(e){}}},e.executeAll=function(t,n){(n||t&&!l(t))&&Object.keys(e.callbacks).forEach(function(n){var i=void 0!==t[n]?t[n]:"";e.execute(n,i);},e);},e.hasCallbacks=function(){return Boolean(Object.keys(e.callbacks).length)},e},me=function(){},he=function(e){var t=window,n=t.console;return !!n&&"function"==typeof n[e]},_e=function(e,t,n){return n()?function(){if(he(e)){for(var n=arguments.length,i=new Array(n),r=0;r-1})},ye=function(e,t){return e.reduce(function(e,n){return e[n]=t,e},{})},be=function(e){return JSON.parse(JSON.stringify(e))},Oe=function(e){return "[object Array]"===Object.prototype.toString.call(e)&&!e.length},Me=function(e){if(Te(e))return e;try{return JSON.parse(e)}catch(e){return {}}},ke=function(e){return void 0===e||(Te(e)?Ae(Object.keys(e)):Ee(e))},Ee=function(e){try{var t=JSON.parse(e);return !!e&&ve(e,"string")&&Ae(Object.keys(t))}catch(e){return !1}},Te=function(e){return null!==e&&ve(e,"object")&&!1===Array.isArray(e)},Le=function(){},Pe=function(e){return ve(e,"function")?e():e},Re=function(e,t){ke(e)||Ie.error("".concat(t));},we=function(e){return Object.keys(e).map(function(t){return e[t]})},Fe=function(e){return we(e).filter(function(e,t,n){return n.indexOf(e)===t})},Ne=function(e){return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.command,i=t.params,r=void 0===i?{}:i,a=t.callback,o=void 0===a?Le:a;if(!n||-1===n.indexOf("."))throw new Error("[OptIn.execute] Please provide a valid command.");try{var s=n.split("."),l=e[s[0]],c=s[1];if(!l||"function"!=typeof l[c])throw new Error("Make sure the plugin and API name exist.");var u=Object.assign(r,{callback:o});l[c].call(l,u);}catch(e){Ie.error("[execute] Something went wrong: "+e.message);}}};f.prototype=Object.create(Error.prototype),f.prototype.constructor=f;var xe="fetchPermissions",je="[OptIn#registerPlugin] Plugin is invalid.";p.Categories=ue,p.TimeoutError=f;var Ve=Object.freeze({OptIn:p,IabPlugin:h}),He=function(e,t){e.publishDestinations=function(n){var i=arguments[1],r=arguments[2];try{r="function"==typeof r?r:n.callback;}catch(e){r=function(){};}var a=t;if(!a.readyToAttachIframePreliminary())return void r({error:"The destination publishing iframe is disabled in the Visitor library."});if("string"==typeof n){if(!n.length)return void r({error:"subdomain is not a populated string."});if(!(i instanceof Array&&i.length))return void r({error:"messages is not a populated array."});var o=!1;if(i.forEach(function(e){ + "string"==typeof e&&e.length&&(a.addMessage(e),o=!0);}),!o)return void r({error:"None of the messages are populated strings."})}else{if(!j.isObject(n))return void r({error:"Invalid parameters passed."});var s=n;if("string"!=typeof(n=s.subdomain)||!n.length)return void r({error:"config.subdomain is not a populated string."});var l=s.urlDestinations;if(!(l instanceof Array&&l.length))return void r({error:"config.urlDestinations is not a populated array."});var c=[];l.forEach(function(e){j.isObject(e)&&(e.hideReferrer?e.message&&a.addMessage(e.message):c.push(e));});!function e(){c.length&&setTimeout(function(){var t=new Image,n=c.shift();t.src=n.url,a.onPageDestinationsFired.push(n),e();},100);}();}a.iframe?(r({message:"The destination publishing iframe is already attached and loaded."}),a.requestToProcess()):!e.subdomain&&e._getField("MCMID")?(a.subdomain=n,a.doAttachIframe=!0,a.url=a.getUrl(),a.readyToAttachIframe()?(a.iframeLoadedCallbacks.push(function(e){r({message:"Attempted to attach and load the destination publishing iframe through this API call. Result: "+(e.message||"no result")});}),a.attachIframe()):r({error:"Encountered a problem in attempting to attach and load the destination publishing iframe through this API call."})):a.iframeLoadedCallbacks.push(function(e){r({message:"Attempted to attach and load the destination publishing iframe through normal Visitor API processing. Result: "+(e.message||"no result")});});};},Ue=function e(t){function n(e,t){return e>>>t|e<<32-t}for(var i,r,a=Math.pow,o=a(2,32),s="",l=[],c=8*t.length,u=e.h=e.h||[],d=e.k=e.k||[],f=d.length,p={},g=2;f<64;g++)if(!p[g]){for(i=0;i<313;i+=g)p[i]=g;u[f]=a(g,.5)*o|0,d[f++]=a(g,1/3)*o|0;}for(t+="€";t.length%64-56;)t+="\0";for(i=0;i>8)return;l[i>>2]|=r<<(3-i)%4*8;}for(l[l.length]=c/o|0,l[l.length]=c,r=0;r>>3)+m[i-7]+(n(C,17)^n(C,19)^C>>>10)|0);u=[S+((n(I,2)^n(I,13)^n(I,22))+(I&u[1]^I&u[2]^u[1]&u[2]))|0].concat(u),u[4]=u[4]+S|0;}for(i=0;i<8;i++)u[i]=u[i]+h[i]|0;}for(i=0;i<8;i++)for(r=3;r+1;r--){var D=u[i]>>8*r&255;s+=(D<16?0:"")+D.toString(16);}return s},Be=function(e,t){return "SHA-256"!==t&&"SHA256"!==t&&"sha256"!==t&&"sha-256"!==t||(e=Ue(e)),e},Ge=function(e){return String(e).trim().toLowerCase()},Ye=Ve.OptIn;j.defineGlobalNamespace(),window.adobe.OptInCategories=Ye.Categories;var qe=function(t,n,i){function r(e){var t=e;return function(e){var n=e||v.location.href;try{var i=g._extractParamFromUri(n,t);if(i)return w.parsePipeDelimetedKeyValues(i)}catch(e){}}}function a(e){function t(e,t,n){e&&e.match(re.VALID_VISITOR_ID_REGEX)&&(n===A&&(I=!0),t(e));}t(e[A],g.setMarketingCloudVisitorID,A),g._setFieldExpire(k,-1),t(e[O],g.setAnalyticsVisitorID);}function o(e){e=e||{},g._supplementalDataIDCurrent=e.supplementalDataIDCurrent||"",g._supplementalDataIDCurrentConsumed=e.supplementalDataIDCurrentConsumed||{},g._supplementalDataIDLast=e.supplementalDataIDLast||"",g._supplementalDataIDLastConsumed=e.supplementalDataIDLastConsumed||{};}function s(e){function t(e,t,n){return n=n?n+="|":n,n+=e+"="+encodeURIComponent(t)}function n(e,n){var i=n[0],r=n[1];return null!=r&&r!==T&&(e=t(i,r,e)),e}var i=e.reduce(n,"");return function(e){var t=w.getTimestampInSeconds();return e=e?e+="|":e,e+="TS="+t}(i)}function l(e){var t=e.minutesToLive,n="";return (g.idSyncDisableSyncs||g.disableIdSyncs)&&(n=n||"Error: id syncs have been disabled"),"string"==typeof e.dpid&&e.dpid.length||(n=n||"Error: config.dpid is empty"),"string"==typeof e.url&&e.url.length||(n=n||"Error: config.url is empty"),void 0===t?t=20160:(t=parseInt(t,10),(isNaN(t)||t<=0)&&(n=n||"Error: config.minutesToLive needs to be a positive number")),{error:n,ttl:t}}function c(){return !!g.configs.doesOptInApply&&!(m.optIn.isComplete&&u())}function u(){return g.configs.isIabContext?m.optIn.isApproved(m.optIn.Categories.ECID)&&C:m.optIn.isApproved(m.optIn.Categories.ECID)}function d(e,t){if(C=!0,e)throw new Error("[IAB plugin] : "+e);t.gdprApplies&&(h=t.consentString),g.init(),p();}function f(){m.optIn.isApproved(m.optIn.Categories.ECID)&&(g.configs.isIabContext?m.optIn.execute({command:"iabPlugin.fetchConsentData",callback:d}):(g.init(),p()));}function p(){m.optIn.off("complete",f);}if(!i||i.split("").reverse().join("")!==t)throw new Error("Please use `Visitor.getInstance` to instantiate Visitor.");var g=this,m=window.adobe,h="",C=!1,I=!1;g.version="4.4.0";var v=_,S=v.Visitor;S.version=g.version,S.AuthState=E.AUTH_STATE,S.OptOut=E.OPT_OUT,v.s_c_in||(v.s_c_il=[],v.s_c_in=0),g._c="Visitor",g._il=v.s_c_il,g._in=v.s_c_in,g._il[g._in]=g,v.s_c_in++,g._instanceType="regular",g._log={requests:[]},g.marketingCloudOrgID=t,g.cookieName="AMCV_"+t,g.sessionCookieName="AMCVS_"+t,g.cookieDomain=$(),g.loadSSL=v.location.protocol.toLowerCase().indexOf("https")>=0,g.loadTimeout=3e4,g.CORSErrors=[],g.marketingCloudServer=g.audienceManagerServer="dpm.demdex.net",g.sdidParamExpiry=30;var D=null,A="MCMID",y="MCIDTS",b="A",O="MCAID",M="AAM",k="MCAAMB",T="NONE",L=function(e){return !Object.prototype[e]},P=ie(g);g.FIELDS=E.FIELDS,g.cookieRead=function(e){return Q.get(e)},g.cookieWrite=function(e,t,n){var i=g.cookieLifetime?(""+g.cookieLifetime).toUpperCase():"",r=!1;return g.configs&&g.configs.secureCookie&&"https:"===location.protocol&&(r=!0),Q.set(e,""+t,{expires:n,domain:g.cookieDomain,cookieLifetime:i,secure:r})},g.resetState=function(e){e?g._mergeServerState(e):o();},g._isAllowedDone=!1,g._isAllowedFlag=!1,g.isAllowed=function(){return g._isAllowedDone||(g._isAllowedDone=!0,(g.cookieRead(g.cookieName)||g.cookieWrite(g.cookieName,"T",1))&&(g._isAllowedFlag=!0)),"T"===g.cookieRead(g.cookieName)&&g._helpers.removeCookie(g.cookieName),g._isAllowedFlag},g.setMarketingCloudVisitorID=function(e){g._setMarketingCloudFields(e);},g._use1stPartyMarketingCloudServer=!1,g.getMarketingCloudVisitorID=function(e,t){g.marketingCloudServer&&g.marketingCloudServer.indexOf(".demdex.net")<0&&(g._use1stPartyMarketingCloudServer=!0);var n=g._getAudienceManagerURLData("_setMarketingCloudFields"),i=n.url;return g._getRemoteField(A,i,e,t,n)},g.getVisitorValues=function(e,t){var n={MCMID:{fn:g.getMarketingCloudVisitorID,args:[!0],context:g},MCOPTOUT:{fn:g.isOptedOut,args:[void 0,!0],context:g},MCAID:{fn:g.getAnalyticsVisitorID,args:[!0],context:g},MCAAMLH:{fn:g.getAudienceManagerLocationHint,args:[!0],context:g},MCAAMB:{fn:g.getAudienceManagerBlob,args:[!0],context:g}},i=t&&t.length?j.pluck(n,t):n;z(i,e);},g._currentCustomerIDs={},g._customerIDsHashChanged=!1,g._newCustomerIDsHash="",g.setCustomerIDs=function(t,n){function i(){g._customerIDsHashChanged=!1;}if(!g.isOptedOut()&&t){if(!j.isObject(t)||j.isObjectEmpty(t))return !1;g._readVisitor();var r,a,o;for(r in t)if(L(r)&&(a=t[r],n=a.hasOwnProperty("hashType")?a.hashType:n,a))if("object"===e(a)){var s={};if(a.id){if(n){if(!(o=Be(Ge(a.id),n)))return;a.id=o,s.hashType=n;}s.id=a.id;}void 0!=a.authState&&(s.authState=a.authState),g._currentCustomerIDs[r]=s;}else if(n){if(!(o=Be(Ge(a),n)))return;g._currentCustomerIDs[r]={id:o,hashType:n};}else g._currentCustomerIDs[r]={id:a};var l=g.getCustomerIDs(),c=g._getField("MCCIDH"),u="";c||(c=0);for(r in l)L(r)&&(a=l[r],u+=(u?"|":"")+r+"|"+(a.id?a.id:"")+(a.authState?a.authState:""));g._newCustomerIDsHash=String(g._hash(u)),g._newCustomerIDsHash!==c&&(g._customerIDsHashChanged=!0,g._mapCustomerIDs(i));}},g.getCustomerIDs=function(){g._readVisitor();var e,t,n={};for(e in g._currentCustomerIDs)L(e)&&(t=g._currentCustomerIDs[e],n[e]||(n[e]={}),t.id&&(n[e].id=t.id),void 0!=t.authState?n[e].authState=t.authState:n[e].authState=S.AuthState.UNKNOWN,t.hashType&&(n[e].hashType=t.hashType));return n},g.setAnalyticsVisitorID=function(e){g._setAnalyticsFields(e);},g.getAnalyticsVisitorID=function(e,t,n){if(!w.isTrackingServerPopulated()&&!n)return g._callCallback(e,[""]),"";var i="";if(n||(i=g.getMarketingCloudVisitorID(function(t){g.getAnalyticsVisitorID(e,!0);})),i||n){var r=n?g.marketingCloudServer:g.trackingServer,a="";g.loadSSL&&(n?g.marketingCloudServerSecure&&(r=g.marketingCloudServerSecure):g.trackingServerSecure&&(r=g.trackingServerSecure));var o={};if(r){var s="http"+(g.loadSSL?"s":"")+"://"+r+"/id",l="d_visid_ver="+g.version+"&mcorgid="+encodeURIComponent(g.marketingCloudOrgID)+(i?"&mid="+encodeURIComponent(i):"")+(g.idSyncDisable3rdPartySyncing||g.disableThirdPartyCookies?"&d_coppa=true":""),c=["s_c_il",g._in,"_set"+(n?"MarketingCloud":"Analytics")+"Fields"];a=s+"?"+l+"&callback=s_c_il%5B"+g._in+"%5D._set"+(n?"MarketingCloud":"Analytics")+"Fields",o.corsUrl=s+"?"+l,o.callback=c;}return o.url=a,g._getRemoteField(n?A:O,a,e,t,o)}return ""},g.getAudienceManagerLocationHint=function(e,t){if(g.getMarketingCloudVisitorID(function(t){g.getAudienceManagerLocationHint(e,!0);})){var n=g._getField(O);if(!n&&w.isTrackingServerPopulated()&&(n=g.getAnalyticsVisitorID(function(t){g.getAudienceManagerLocationHint(e,!0);})),n||!w.isTrackingServerPopulated()){var i=g._getAudienceManagerURLData(),r=i.url;return g._getRemoteField("MCAAMLH",r,e,t,i)}}return ""},g.getLocationHint=g.getAudienceManagerLocationHint,g.getAudienceManagerBlob=function(e,t){if(g.getMarketingCloudVisitorID(function(t){g.getAudienceManagerBlob(e,!0);})){var n=g._getField(O);if(!n&&w.isTrackingServerPopulated()&&(n=g.getAnalyticsVisitorID(function(t){g.getAudienceManagerBlob(e,!0);})),n||!w.isTrackingServerPopulated()){var i=g._getAudienceManagerURLData(),r=i.url;return g._customerIDsHashChanged&&g._setFieldExpire(k,-1),g._getRemoteField(k,r,e,t,i)}}return ""},g._supplementalDataIDCurrent="",g._supplementalDataIDCurrentConsumed={},g._supplementalDataIDLast="",g._supplementalDataIDLastConsumed={},g.getSupplementalDataID=function(e,t){g._supplementalDataIDCurrent||t||(g._supplementalDataIDCurrent=g._generateID(1));var n=g._supplementalDataIDCurrent;return g._supplementalDataIDLast&&!g._supplementalDataIDLastConsumed[e]?(n=g._supplementalDataIDLast,g._supplementalDataIDLastConsumed[e]=!0):n&&(g._supplementalDataIDCurrentConsumed[e]&&(g._supplementalDataIDLast=g._supplementalDataIDCurrent,g._supplementalDataIDLastConsumed=g._supplementalDataIDCurrentConsumed,g._supplementalDataIDCurrent=n=t?"":g._generateID(1),g._supplementalDataIDCurrentConsumed={}),n&&(g._supplementalDataIDCurrentConsumed[e]=!0)),n};var R=!1;g._liberatedOptOut=null,g.getOptOut=function(e,t){var n=g._getAudienceManagerURLData("_setMarketingCloudFields"),i=n.url;if(u())return g._getRemoteField("MCOPTOUT",i,e,t,n);if(g._registerCallback("liberatedOptOut",e),null!==g._liberatedOptOut)return g._callAllCallbacks("liberatedOptOut",[g._liberatedOptOut]),R=!1,g._liberatedOptOut;if(R)return null;R=!0;var r="liberatedGetOptOut";return n.corsUrl=n.corsUrl.replace(/dpm\.demdex\.net\/id\?/,"dpm.demdex.net/optOutStatus?"),n.callback=[r],_[r]=function(e){if(e===Object(e)){var t,n,i=j.parseOptOut(e,t,T);t=i.optOut,n=1e3*i.d_ottl,g._liberatedOptOut=t,setTimeout(function(){g._liberatedOptOut=null;},n);}g._callAllCallbacks("liberatedOptOut",[t]),R=!1;},P.fireCORS(n),null},g.isOptedOut=function(e,t,n){t||(t=S.OptOut.GLOBAL);var i=g.getOptOut(function(n){var i=n===S.OptOut.GLOBAL||n.indexOf(t)>=0;g._callCallback(e,[i]);},n);return i?i===S.OptOut.GLOBAL||i.indexOf(t)>=0:null},g._fields=null,g._fieldsExpired=null,g._hash=function(e){var t,n,i=0;if(e)for(t=0;t0;)g._callCallback(n.shift(),t);}},g._addQuerystringParam=function(e,t,n,i){var r=encodeURIComponent(t)+"="+encodeURIComponent(n),a=w.parseHash(e),o=w.hashlessUrl(e);if(-1===o.indexOf("?"))return o+"?"+r+a;var s=o.split("?"),l=s[0]+"?",c=s[1];return l+w.addQueryParamAtLocation(c,r,i)+a},g._extractParamFromUri=function(e,t){var n=new RegExp("[\\?&#]"+t+"=([^&#]*)"),i=n.exec(e);if(i&&i.length)return decodeURIComponent(i[1])},g._parseAdobeMcFromUrl=r(re.ADOBE_MC),g._parseAdobeMcSdidFromUrl=r(re.ADOBE_MC_SDID),g._attemptToPopulateSdidFromUrl=function(e){var n=g._parseAdobeMcSdidFromUrl(e),i=1e9;n&&n.TS&&(i=w.getTimestampInSeconds()-n.TS),n&&n.SDID&&n.MCORGID===t&&ire.ADOBE_MC_TTL_IN_MIN||e.MCORGID!==t)return;a(e);}},g._mergeServerState=function(e){if(e)try{if(e=function(e){return w.isObject(e)?e:JSON.parse(e)}(e),e[g.marketingCloudOrgID]){var t=e[g.marketingCloudOrgID];!function(e){w.isObject(e)&&g.setCustomerIDs(e);}(t.customerIDs),o(t.sdid);}}catch(e){throw new Error("`serverState` has an invalid format.")}},g._timeout=null,g._loadData=function(e,t,n,i){t=g._addQuerystringParam(t,"d_fieldgroup",e,1),i.url=g._addQuerystringParam(i.url,"d_fieldgroup",e,1),i.corsUrl=g._addQuerystringParam(i.corsUrl,"d_fieldgroup",e,1),N.fieldGroupObj[e]=!0,i===Object(i)&&i.corsUrl&&"XMLHttpRequest"===P.corsMetadata.corsType&&P.fireCORS(i,n,e);},g._clearTimeout=function(e){null!=g._timeout&&g._timeout[e]&&(clearTimeout(g._timeout[e]),g._timeout[e]=0);},g._settingsDigest=0,g._getSettingsDigest=function(){if(!g._settingsDigest){var e=g.version;g.audienceManagerServer&&(e+="|"+g.audienceManagerServer),g.audienceManagerServerSecure&&(e+="|"+g.audienceManagerServerSecure),g._settingsDigest=g._hash(e);}return g._settingsDigest},g._readVisitorDone=!1,g._readVisitor=function(){if(!g._readVisitorDone){g._readVisitorDone=!0;var e,t,n,i,r,a,o=g._getSettingsDigest(),s=!1,l=g.cookieRead(g.cookieName),c=new Date;if(l||I||g.discardTrackingServerECID||(l=g.cookieRead(re.FIRST_PARTY_SERVER_COOKIE)),null==g._fields&&(g._fields={}),l&&"T"!==l)for(l=l.split("|"),l[0].match(/^[\-0-9]+$/)&&(parseInt(l[0],10)!==o&&(s=!0),l.shift()),l.length%2==1&&l.pop(),e=0;e1?(r=parseInt(t[1],10),a=t[1].indexOf("s")>0):(r=0,a=!1),s&&("MCCIDH"===n&&(i=""),r>0&&(r=c.getTime()/1e3-60)),n&&i&&(g._setField(n,i,1),r>0&&(g._fields["expire"+n]=r+(a?"s":""),(c.getTime()>=1e3*r||a&&!g.cookieRead(g.sessionCookieName))&&(g._fieldsExpired||(g._fieldsExpired={}),g._fieldsExpired[n]=!0)));!g._getField(O)&&w.isTrackingServerPopulated()&&(l=g.cookieRead("s_vi"))&&(l=l.split("|"),l.length>1&&l[0].indexOf("v1")>=0&&(i=l[1],e=i.indexOf("["),e>=0&&(i=i.substring(0,e)),i&&i.match(re.VALID_VISITOR_ID_REGEX)&&g._setField(O,i)));}},g._appendVersionTo=function(e){var t="vVersion|"+g.version,n=e?g._getCookieVersion(e):null;return n?Z.areVersionsDifferent(n,g.version)&&(e=e.replace(re.VERSION_REGEX,t)):e+=(e?"|":"")+t,e},g._writeVisitor=function(){var e,t,n=g._getSettingsDigest();for(e in g._fields)L(e)&&g._fields[e]&&"expire"!==e.substring(0,6)&&(t=g._fields[e],n+=(n?"|":"")+e+(g._fields["expire"+e]?"-"+g._fields["expire"+e]:"")+"|"+t);n=g._appendVersionTo(n),g.cookieWrite(g.cookieName,n,1);},g._getField=function(e,t){return null==g._fields||!t&&g._fieldsExpired&&g._fieldsExpired[e]?null:g._fields[e]},g._setField=function(e,t,n){null==g._fields&&(g._fields={}),g._fields[e]=t,n||g._writeVisitor();},g._getFieldList=function(e,t){var n=g._getField(e,t);return n?n.split("*"):null},g._setFieldList=function(e,t,n){g._setField(e,t?t.join("*"):"",n);},g._getFieldMap=function(e,t){var n=g._getFieldList(e,t);if(n){var i,r={};for(i=0;i0?e.substr(t):""},hashlessUrl:function(e){var t=e.indexOf("#");return t>0?e.substr(0,t):e},addQueryParamAtLocation:function(e,t,n){var i=e.split("&");return n=null!=n?n:i.length,i.splice(n,0,t),i.join("&")},isFirstPartyAnalyticsVisitorIDCall:function(e,t,n){if(e!==O)return !1;var i;return t||(t=g.trackingServer),n||(n=g.trackingServerSecure),!("string"!=typeof(i=g.loadSSL?n:t)||!i.length)&&(i.indexOf("2o7.net")<0&&i.indexOf("omtrdc.net")<0)},isObject:function(e){return Boolean(e&&e===Object(e))},removeCookie:function(e){Q.remove(e,{domain:g.cookieDomain});},isTrackingServerPopulated:function(){return !!g.trackingServer||!!g.trackingServerSecure},getTimestampInSeconds:function(){return Math.round((new Date).getTime()/1e3)},parsePipeDelimetedKeyValues:function(e){return e.split("|").reduce(function(e,t){var n=t.split("=");return e[n[0]]=decodeURIComponent(n[1]),e},{})},generateRandomString:function(e){e=e||5;for(var t="",n="abcdefghijklmnopqrstuvwxyz0123456789";e--;)t+=n[Math.floor(Math.random()*n.length)];return t},normalizeBoolean:function(e){return "true"===e||"false"!==e&&e},parseBoolean:function(e){return "true"===e||"false"!==e&&null},replaceMethodsWithFunction:function(e,t){for(var n in e)e.hasOwnProperty(n)&&"function"==typeof e[n]&&(e[n]=t);return e}};g._helpers=w;var F=ae(g,S);g._destinationPublishing=F,g.timeoutMetricsLog=[];var N={isClientSideMarketingCloudVisitorID:null,MCIDCallTimedOut:null,AnalyticsIDCallTimedOut:null,AAMIDCallTimedOut:null,fieldGroupObj:{},setState:function(e,t){switch(e){case"MC":!1===t?!0!==this.MCIDCallTimedOut&&(this.MCIDCallTimedOut=!1):this.MCIDCallTimedOut=t;break;case b:!1===t?!0!==this.AnalyticsIDCallTimedOut&&(this.AnalyticsIDCallTimedOut=!1):this.AnalyticsIDCallTimedOut=t;break;case M:!1===t?!0!==this.AAMIDCallTimedOut&&(this.AAMIDCallTimedOut=!1):this.AAMIDCallTimedOut=t;}}};g.isClientSideMarketingCloudVisitorID=function(){return N.isClientSideMarketingCloudVisitorID},g.MCIDCallTimedOut=function(){return N.MCIDCallTimedOut},g.AnalyticsIDCallTimedOut=function(){return N.AnalyticsIDCallTimedOut},g.AAMIDCallTimedOut=function(){return N.AAMIDCallTimedOut},g.idSyncGetOnPageSyncInfo=function(){return g._readVisitor(),g._getField("MCSYNCSOP")},g.idSyncByURL=function(e){if(!g.isOptedOut()){var t=l(e||{});if(t.error)return t.error;var n,i,r=e.url,a=encodeURIComponent,o=F;return r=r.replace(/^https:/,"").replace(/^http:/,""),n=j.encodeAndBuildRequest(["",e.dpid,e.dpuuid||""],","),i=["ibs",a(e.dpid),"img",a(r),t.ttl,"",n],o.addMessage(i.join("|")),o.requestToProcess(),"Successfully queued"}},g.idSyncByDataSource=function(e){if(!g.isOptedOut())return e===Object(e)&&"string"==typeof e.dpuuid&&e.dpuuid.length?(e.url="//dpm.demdex.net/ibs:dpid="+e.dpid+"&dpuuid="+e.dpuuid,g.idSyncByURL(e)):"Error: config or config.dpuuid is empty"},He(g,F),g._getCookieVersion=function(e){e=e||g.cookieRead(g.cookieName);var t=re.VERSION_REGEX.exec(e);return t&&t.length>1?t[1]:null},g._resetAmcvCookie=function(e){var t=g._getCookieVersion();t&&!Z.isLessThan(t,e)||w.removeCookie(g.cookieName);},g.setAsCoopSafe=function(){D=!0;},g.setAsCoopUnsafe=function(){D=!1;},function(){if(g.configs=Object.create(null),w.isObject(n))for(var e in n)L(e)&&(g[e]=n[e],g.configs[e]=n[e]);}(),function(){[["getMarketingCloudVisitorID"],["setCustomerIDs",void 0],["getAnalyticsVisitorID"],["getAudienceManagerLocationHint"],["getLocationHint"],["getAudienceManagerBlob"]].forEach(function(e){var t=e[0],n=2===e.length?e[1]:"",i=g[t];g[t]=function(e){return u()&&g.isAllowed()?i.apply(g,arguments):("function"==typeof e&&g._callCallback(e,[n]),n)};});}(),g.init=function(){if(c())return m.optIn.fetchPermissions(f,!0);!function(){if(w.isObject(n)){g.idSyncContainerID=g.idSyncContainerID||0,D="boolean"==typeof g.isCoopSafe?g.isCoopSafe:w.parseBoolean(g.isCoopSafe),g.resetBeforeVersion&&g._resetAmcvCookie(g.resetBeforeVersion),g._attemptToPopulateIdsFromUrl(),g._attemptToPopulateSdidFromUrl(),g._readVisitor();var e=g._getField(y),t=Math.ceil((new Date).getTime()/re.MILLIS_PER_DAY);g.idSyncDisableSyncs||g.disableIdSyncs||!F.canMakeSyncIDCall(e,t)||(g._setFieldExpire(k,-1),g._setField(y,t)),g.getMarketingCloudVisitorID(),g.getAudienceManagerLocationHint(),g.getAudienceManagerBlob(),g._mergeServerState(g.serverState);}else g._attemptToPopulateIdsFromUrl(),g._attemptToPopulateSdidFromUrl();}(),function(){if(!g.idSyncDisableSyncs&&!g.disableIdSyncs){F.checkDPIframeSrc();var e=function(){var e=F;e.readyToAttachIframe()&&e.attachIframe();};v.addEventListener("load",function(){S.windowLoaded=!0,e();});try{te.receiveMessage(function(e){F.receiveMessage(e.data);},F.iframeHost);}catch(e){}}}(),function(){g.whitelistIframeDomains&&re.POST_MESSAGE_ENABLED&&(g.whitelistIframeDomains=g.whitelistIframeDomains instanceof Array?g.whitelistIframeDomains:[g.whitelistIframeDomains],g.whitelistIframeDomains.forEach(function(e){var n=new B(t,e),i=K(g,n);te.receiveMessage(i,e);}));}();};};qe.config=se,_.Visitor=qe;var Xe=qe,We=function(e){if(j.isObject(e))return Object.keys(e).filter(function(t){return ""!==e[t]}).reduce(function(t,n){var i="doesOptInApply"!==n?e[n]:se.normalizeConfig(e[n]),r=j.normalizeBoolean(i);return t[n]=r,t},Object.create(null))},Je=Ve.OptIn,Ke=Ve.IabPlugin;return Xe.getInstance=function(e,t){if(!e)throw new Error("Visitor requires Adobe Marketing Cloud Org ID.");e.indexOf("@")<0&&(e+="@AdobeOrg");var n=function(){var t=_.s_c_il;if(t)for(var n=0;na.indexOf(b)?a:a.split(b).join(d)};a.escape=function(c){var b,d;if(!c)return c;c=encodeURIComponent(c);for(b=0;7>b;b++)d="+~!*()'".substring(b,b+1),0<=c.indexOf(d)&&(c=a.replace(c,d,"%"+d.charCodeAt(0).toString(16).toUpperCase()));return c};a.unescape=function(c){if(!c)return c;c=0<=c.indexOf("+")?a.replace(c,"+"," "):c;try{return decodeURIComponent(c)}catch(b){}return unescape(c)};a.Mb=function(){var c=h.location.hostname,b=a.fpCookieDomainPeriods,d;b||(b=a.cookieDomainPeriods); + if(c&&!a.Ja&&!/^[0-9.]+$/.test(c)&&(b=b?parseInt(b):2,b=2d?"":a.unescape(b.substring(d+2+c.length,0>f?b.length:f));return "[[B]]"!=c?c:""};a.c_w=a.cookieWrite=function(c,b,d){var f=a.Mb(),e=a.cookieLifetime,g;b=""+b;e=e?(""+e).toUpperCase():"";d&&"SESSION"!=e&&"NONE"!= + e&&((g=""!=b?parseInt(e?e:0):-60)?(d=new Date,d.setTime(d.getTime()+1E3*g)):1===d&&(d=new Date,g=d.getYear(),d.setYear(g+2+(1900>g?1900:0))));return c&&"NONE"!=e?(a.d.cookie=a.escape(c)+"="+a.escape(""!=b?b:"[[B]]")+"; path=/;"+(d&&"SESSION"!=e?" expires="+d.toUTCString()+";":"")+(f?" domain="+f+";":"")+(a.writeSecureCookies?" secure;":""),a.cookieRead(c)==b):0};a.Jb=function(){var c=a.Util.getIeVersion();"number"===typeof c&&10>c&&(a.unsupportedBrowser=!0,a.wb(a,function(){}));};a.xa=function(){var a= + navigator.userAgent;return "Microsoft Internet Explorer"===navigator.appName||0<=a.indexOf("MSIE ")||0<=a.indexOf("Trident/")&&0<=a.indexOf("Windows NT 6")?!0:!1};a.wb=function(a,b){for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&"function"===typeof a[d]&&(a[d]=b);};a.K=[];a.ea=function(c,b,d){if(a.Ka)return 0;a.maxDelay||(a.maxDelay=250);var f=0,e=(new Date).getTime()+a.maxDelay,g=a.d.visibilityState,k=["webkitvisibilitychange","visibilitychange"];g||(g=a.d.webkitVisibilityState);if(g&&"prerender"== + g){if(!a.fa)for(a.fa=1,d=0;dc){a.K.unshift(d);setTimeout(a.delayReady,parseInt(a.maxDelay/2));break}a.Ka=1;a[d.m].apply(a, + d.a);a.Ka=0;}};a.setAccount=a.sa=function(c){var b,d;if(!a.ea("setAccount",arguments))if(a.account=c,a.allAccounts)for(b=a.allAccounts.concat(c.split(",")),a.allAccounts=[],b.sort(),d=0;de.indexOf(".contextData."))switch(h=k.substring(0,4),n=k.substring(4),k){case "transactionID":k="xact";break;case "channel":k="ch";break;case "campaign":k="v0";break;default:a.Qa(n)&&("prop"==h?k="c"+n:"eVar"==h?k="v"+n:"list"== + h?k="l"+n:"hier"==h&&(k="h"+n,l=l.substring(0,255)));}g+="&"+a.escape(k)+"="+a.escape(l);}}""!=g&&(g+="&."+c);}return g};a.usePostbacks=0;a.Pb=function(){var c="",b,d,f,e,g,k,l,h,n="",m="",p=e="",r=a.T();if(a.lightProfileID)b=a.O,(n=a.lightTrackVars)&&(n=","+n+","+a.ka.join(",")+",");else{b=a.g;if(a.pe||a.linkType)n=a.linkTrackVars,m=a.linkTrackEvents,a.pe&&(e=a.pe.substring(0,1).toUpperCase()+a.pe.substring(1),a[e]&&(n=a[e].cc,m=a[e].bc));n&&(n=","+n+","+a.F.join(",")+",");m&&(m=","+m+",",n&&(n+=",events,")); + a.events2&&(p+=(""!=p?",":"")+a.events2);}if(r&&r.getCustomerIDs){e=q;if(g=r.getCustomerIDs())for(d in g)Object.prototype[d]||(f=g[d],"object"==typeof f&&(e||(e={}),f.id&&(e[d+".id"]=f.id),f.authState&&(e[d+".as"]=f.authState)));e&&(c+=a.o("cid",e));}a.AudienceManagement&&a.AudienceManagement.isReady()&&(c+=a.o("d",a.AudienceManagement.getEventCallConfigParams()));for(d=0;df||0<=e&&f>e||0<=g&&f>g)&&(e=a.protocol&&1f?0:f)+"/":"")+d);return d};a.L=function(c){var b=a.B(c),d,f,e="",g=0;return b&&(d=c.protocol,f=c.onclick,!c.href||"A"!=b&&"AREA"!=b||f&&d&&!(0>d.toLowerCase().indexOf("javascript"))?f?(e=a.replace(a.replace(a.replace(a.replace(""+f,"\r",""),"\n",""),"\t","")," ",""),g=2):"INPUT"==b||"SUBMIT"==b?(c.value?e=c.value:c.innerText?e=c.innerText:c.textContent&&(e=c.textContent),g=3):"IMAGE"==b&&c.src&&(e=c.src):e=a.Ma(c),e)?{id:e.substring(0,100),type:g}:0};a.ic=function(c){for(var b=a.B(c),d=a.L(c);c&& + !d&&"BODY"!=b;)if(c=c.parentElement?c.parentElement:c.parentNode)b=a.B(c),d=a.L(c);d&&"BODY"!=b||(c=0);c&&(b=c.onclick?""+c.onclick:"",0<=b.indexOf(".tl(")||0<=b.indexOf(".trackLink("))&&(c=0);return c};a.Xb=function(){var c,b,d=a.linkObject,f=a.linkType,e=a.linkURL,g,k;a.la=1;d||(a.la=0,d=a.clickObject);if(d){c=a.B(d);for(b=a.L(d);d&&!b&&"BODY"!=c;)if(d=d.parentElement?d.parentElement:d.parentNode)c=a.B(d),b=a.L(d);b&&"BODY"!=c||(d=0);if(d&&!a.linkObject){var l=d.onclick?""+d.onclick:"";if(0<=l.indexOf(".tl(")|| + 0<=l.indexOf(".trackLink("))d=0;}}else a.la=1;!e&&d&&(e=a.Ma(d));e&&!a.linkLeaveQueryString&&(g=e.indexOf("?"),0<=g&&(e=e.substring(0,g)));if(!f&&e){var m=0,n=0,p;if(a.trackDownloadLinks&&a.linkDownloadFileTypes)for(l=e.toLowerCase(),g=l.indexOf("?"),k=l.indexOf("#"),0<=g?0<=k&&kb)return 0}return 1};a.S=function(c,b){var d,f,e,g,k,h,m;m={};for(d=0;2>d;d++)for(f=0b;b++)for(d=0c.indexOf("-")){for(c=0;16>c;c++)f= + Math.floor(Math.random()*f),b+="0123456789ABCDEF".substring(f,f+1),f=Math.floor(Math.random()*e),d+="0123456789ABCDEF".substring(f,f+1),f=e=16;c=b+"-"+d;}a.cookieWrite("s_fid",c,1)||(c=0);return c};a.Ea=function(c){var b=new Date,d="s"+Math.floor(b.getTime()/108E5)%10+Math.floor(1E13*Math.random()),f=b.getYear(),f="t="+a.escape(b.getDate()+"/"+b.getMonth()+"/"+(1900>f?f+1900:f)+" "+b.getHours()+":"+b.getMinutes()+":"+b.getSeconds()+" "+b.getDay()+" "+b.getTimezoneOffset()),e=a.T(),g;c&&(g=a.S(c,1)); + a.Ub()&&!a.visitorOptedOut&&(a.wa()||(a.fid=a.Nb()),a.Xb(),a.usePlugins&&a.doPlugins&&a.doPlugins(a),a.account&&(a.abort||(a.trackOffline&&!a.timestamp&&(a.timestamp=Math.floor(b.getTime()/1E3)),c=h.location,a.pageURL||(a.pageURL=c.href?c.href:c),a.referrer||a.Za||(c=a.Util.getQueryParam("adobe_mc_ref",null,null,!0),a.referrer=c||void 0===c?void 0===c?"":c:p.document.referrer),a.Za=1,a.referrer=a.Lb(a.referrer),a.u("_g")),a.Qb()&&!a.abort&&(e&&a.V("TARGET")&&!a.supplementalDataID&&e.getSupplementalDataID&& + (a.supplementalDataID=e.getSupplementalDataID("AppMeasurement:"+a._in,a.expectSupplementalData?!1:!0)),a.V("AAM")||(a.contextData["cm.ssf"]=1),a.Rb(),a.vb(),f+=a.Pb(),a.rb(d,f),a.u("_t"),a.referrer="")));a.Ca();g&&a.S(g,1);};a.t=a.track=function(c,b){b&&a.S(b);a.Y=!0;a.isReadyToTrack()?null!=a.j&&0a.N&&a.Va(a.i),a.qa(500);else{var c=a.Eb();if(0=a.offlineThrottleDelay)return 0;c=a.A()-a.Ta;return a.offlineThrottleDelaya.N&&a.Va(a.i);a.ca();a.qa(500);};b.onreadystatechange=function(){4==b.readyState&&(200== + b.status?b.R():b.ga());};a.Ta=a.A();if(1===d)b.send(c);else if(2===d)f=c.indexOf("?"),d=c.substring(0,f),f=c.substring(f+1),f=f.replace(/&callback=[a-zA-Z0-9_.\[\]]+/,""),b.open("POST",d,!0),b.withCredentials=!0,b.send(f);else if(b.src=c,3===d){if(a.Ra)try{f.removeChild(a.Ra);}catch(e){}f.firstChild?f.insertBefore(b,f.firstChild):f.appendChild(b);a.Ra=a.v;}b.D=setTimeout(function(){b.D&&(b.complete?b.R():(a.trackOffline&&b.abort&&b.abort(),b.ga()));},5E3);a.Hb=c;a.v=h["s_i_"+a.replace(a.account,",","_")]= + b;if(a.useForcedLinkTracking&&a.J||a.bodyClickFunction)a.forcedLinkTrackingTimeout||(a.forcedLinkTrackingTimeout=250),a.da=setTimeout(a.ca,a.forcedLinkTrackingTimeout);};a.mb=function(c){var b=!1;navigator.sendBeacon&&(a.ob(c)?b=!0:a.useBeacon&&(b=!0));a.xb(c)&&(b=!1);return b};a.ob=function(a){return a&&0a.N))try{h.localStorage.removeItem(a.ma()),a.Sa=a.A();}catch(c){}};a.Va=function(c){if(a.oa()){a.Xa();try{h.localStorage.setItem(a.ma(),h.JSON.stringify(c)),a.N=a.A();}catch(b){}}};a.Xa=function(){if(a.trackOffline){if(!a.offlineLimit||0>=a.offlineLimit)a.offlineLimit=10;for(;a.i.length>a.offlineLimit;)a.La();}};a.forceOffline=function(){a.na=!0;};a.forceOnline=function(){a.na=!1;};a.ma=function(){return a.offlineFilename+"-"+a.visitorNamespace+a.account};a.A=function(){return (new Date).getTime()}; + a.Pa=function(a){a=a.toLowerCase();return 0!=a.indexOf("#")&&0!=a.indexOf("about:")&&0!=a.indexOf("opera:")&&0!=a.indexOf("javascript:")?!0:!1};a.setTagContainer=function(c){var b,d,f;a.$b=c;for(b=0;b(""+f[b]).indexOf("s_c_il"))&&(c[b]=f[b]);if(d.mmq)for(b= + 0;be)return g;b=d+b.substring(e+1)+d;if(!f||!(0<=b.indexOf(d+c+d)||0<=b.indexOf(d+ + c+"="+d))){e=b.indexOf("#");0<=e&&(b=b.substr(0,e)+d);e=b.indexOf(d+c+"=");if(0>e)return g;b=b.substring(e+d.length+c.length+1);e=b.indexOf(d);0<=e&&(b=b.substring(0,e));0=m;m++)76>m&&(a.g.push("prop"+m),a.O.push("prop"+m)),a.g.push("eVar"+m),a.O.push("eVar"+m),6>m&&a.g.push("hier"+m),4>m&&a.g.push("list"+m);m="pe pev1 pev2 pev3 latitude longitude resolution colorDepth javascriptVersion javaEnabled cookiesEnabled browserWidth browserHeight connectionType homepage pageURLRest marketingCloudOrgID ms_a".split(" ");a.g=a.g.concat(m);a.F=a.F.concat(m);a.ssl=0<=h.location.protocol.toLowerCase().indexOf("https");a.charSet="UTF-8";a.contextData={};a.writeSecureCookies= + !1;a.offlineThrottleDelay=0;a.offlineFilename="AppMeasurement.offline";a.P="s_sq";a.Ta=0;a.ia=0;a.N=0;a.Sa=0;a.linkDownloadFileTypes="exe,zip,wav,mp3,mov,mpg,avi,wmv,pdf,doc,docx,xls,xlsx,ppt,pptx";a.w=h;a.d=h.document;a.ca=function(){a.da&&(h.clearTimeout(a.da),a.da=q);a.bodyClickTarget&&a.J&&a.bodyClickTarget.dispatchEvent(a.J);a.bodyClickFunction&&("function"==typeof a.bodyClickFunction?a.bodyClickFunction():a.bodyClickTarget&&a.bodyClickTarget.href&&(a.d.location=a.bodyClickTarget.href));a.bodyClickTarget= + a.J=a.bodyClickFunction=0;};a.Wa=function(){a.b=a.d.body;a.b?(a.r=function(c){var b,d,f,e,g;if(!(a.d&&a.d.getElementById("cppXYctnr")||c&&c["s_fe_"+a._in])){if(a.Ha)if(a.useForcedLinkTracking)a.b.removeEventListener("click",a.r,!1);else{a.b.removeEventListener("click",a.r,!0);a.Ha=a.useForcedLinkTracking=0;return}else a.useForcedLinkTracking=0;a.clickObject=c.srcElement?c.srcElement:c.target;try{if(!a.clickObject||a.M&&a.M==a.clickObject||!(a.clickObject.tagName||a.clickObject.parentElement||a.clickObject.parentNode))a.clickObject= + 0;else{var k=a.M=a.clickObject;a.ha&&(clearTimeout(a.ha),a.ha=0);a.ha=setTimeout(function(){a.M==k&&(a.M=0);},1E4);f=a.Na();a.track();if(f 0) { + setMCIDOnIntegrationAttributes(mcID); + } + + if (forwarderSettings.mediaTrackingServer) { + self.adobeMediaSDK.init(forwarderSettings, service, testMode); + } + isAdobeServerKitInitialized = true; + return 'Adobe Server Side Integration Ready'; + } catch (e) { + return 'Failed to initialize: ' + e; + } + } + + function setMarketingCloudId(mcid) { + setMCIDOnIntegrationAttributes(mcid); + } + + function processEvent(event) { + if (isAdobeServerKitInitialized) { + try { + if (event.EventDataType === MessageType$1.Media) { + self.adobeMediaSDK.process(event); + } + } catch (e) { + return 'Failed to send to: ' + name + ' ' + e; + } + } else { + return "Can't send to forwarder " + name + ', not initialized.'; + } + } + + this.init = initForwarder; + this.process = processEvent; + }; + + function setMCIDOnIntegrationAttributes(mcid) { + var adobeIntegrationAttributes = {}; + adobeIntegrationAttributes[MARKETINGCLOUDIDKEY] = mcid; + mParticle.setIntegrationAttribute( + ADOBEMODULENUMBER, + adobeIntegrationAttributes + ); + mParticle._setIntegrationDelay(ADOBEMODULENUMBER, false); + } + + function getId() { + return moduleId; + } + + if (window && window.mParticle && window.mParticle.addForwarder) { + window.mParticle.addForwarder({ + name: name, + suffix: suffix, + constructor: constructor$1, + getId: getId, + }); + } + + function register(config) { + var forwarderNameWithSuffix = [name, suffix].join('-'); + if (!config) { + window.console.log( + 'You must pass a config object to register the kit ' + + forwarderNameWithSuffix + ); + return; + } + + if (!isObject(config)) { + window.console.log( + "'config' must be an object. You passed in a " + typeof config + ); + return; + } + + if (isObject(config.kits)) { + config.kits[forwarderNameWithSuffix] = { + constructor: constructor$1, + }; + } else { + config.kits = {}; + config.kits[forwarderNameWithSuffix] = { + constructor: constructor$1, + }; + } + window.console.log( + 'Successfully registered ' + + forwarderNameWithSuffix + + ' to your mParticle configuration' + ); + } + + function isObject(val) { + return ( + val != null && typeof val === 'object' && Array.isArray(val) === false + ); + } + + var AdobeServerSideKit_esm = { + register: register, + }; + + return AdobeServerSideKit_esm; + +}()); diff --git a/kits/adwords/dist/GoogleAdWordsEventForwarder.common.js b/kits/adwords/dist/GoogleAdWordsEventForwarder.common.js new file mode 100644 index 000000000..0497e854d --- /dev/null +++ b/kits/adwords/dist/GoogleAdWordsEventForwarder.common.js @@ -0,0 +1,839 @@ +Object.defineProperty(exports, '__esModule', { value: true }); + +/* eslint-disable no-undef*/ + +// +// Copyright 2017 mParticle, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +var name = 'GoogleAdWords', + moduleId = 82, + MessageType = { + SessionStart: 1, + SessionEnd: 2, + PageView: 3, + PageEvent: 4, + CrashReport: 5, + OptOut: 6, + Commerce: 16, + }, + ENHANCED_CONVERSION_DATA = 'GoogleAds.ECData'; + +// Declares valid Google consent values +var googleConsentValues = { + // Server Integration uses 'Unspecified' as a value when the setting is 'not set'. + // However, this is not used by Google's Web SDK. We are referencing it here as a comment + // as a record of this distinction and for posterity. + // If Google ever adds this for web, the line can just be uncommented to support this. + // + // Docs: + // Web: https://developers.google.com/tag-platform/gtagjs/reference#consent + // S2S: https://developers.google.com/google-ads/api/reference/rpc/v15/ConsentStatusEnum.ConsentStatus + // + // Unspecified: 'unspecified', + Denied: 'denied', + Granted: 'granted', +}; + +// Declares list of valid Google Consent Properties +var googleConsentProperties = [ + 'ad_storage', + 'ad_user_data', + 'ad_personalization', + 'analytics_storage', +]; + +var constructor = function() { + var self = this, + isInitialized = false, + forwarderSettings, + labels, + customAttributeMappings, + consentMappings = [], + consentPayloadDefaults = {}, + consentPayloadAsString = '', + reportingService, + eventQueue = [], + gtagSiteId; + + self.name = name; + + function processEvent(event) { + var reportEvent = false; + var sendEventFunction = function() {}; + var generateEventFunction = function() {}; + var conversionLabel; + var eventPayload; + + if (isInitialized) { + // First, process anything in the queue + processQueue(eventQueue); + + try { + if (window.gtag && forwarderSettings.enableGtag == 'True') { + // If consent payload is empty, + // we never sent an initial default consent state + // so we shouldn't send an update. + var eventConsentState = getEventConsentState( + event.ConsentState + ); + maybeSendConsentUpdateToGoogle(eventConsentState); + + if ( + forwarderSettings.enableEnhancedConversions === + 'True' && + hasEnhancedConversionData(event.CustomFlags) + ) { + window.enhanced_conversion_data = parseEnhancedConversionData( + event.CustomFlags[ENHANCED_CONVERSION_DATA] + ); + } + + sendEventFunction = sendGtagEvent; + generateEventFunction = generateGtagEvent; + generateCommerceEvent = generateGtagCommerceEvent; + } else if (window.google_trackConversion) { + // window.google_trackConversion is a legacy API and will be deprecated + sendEventFunction = sendAdwordsEvent; + generateEventFunction = generateAdwordsEvent; + generateCommerceEvent = generateAdwordsCommerceEvent; + } else { + eventQueue.push({ + action: processEvent, + data: event, + }); + + return ( + "Can't send to forwarder " + + name + + ', not initialized. Event added to queue.' + ); + } + + // Get conversionLabel to be used for event generation + var conversionLabel = getConversionLabel(event); + var customProps = getCustomProps(event); + + if (conversionLabel) { + // Determines the proper event to fire + if ( + event.EventDataType == MessageType.PageView || + event.EventDataType == MessageType.PageEvent + ) { + eventPayload = generateEventFunction( + event, + conversionLabel, + customProps + ); + } else if ( + event.EventDataType == MessageType.Commerce && + event.ProductAction + ) { + eventPayload = generateCommerceEvent( + event, + conversionLabel, + customProps + ); + } + + if (eventPayload) { + reportEvent = sendEventFunction(eventPayload); + } + + if (reportEvent && reportingService) { + reportingService(self, event); + + return 'Successfully sent to ' + name; + } + } + + return ( + "Can't send to forwarder: " + name + '. Event not mapped' + ); + } catch (e) { + console.error('Can\t send to forwarder', e); + return "Can't send to forwarder: " + name + ' ' + e; + } + } else { + eventQueue.push({ + action: processEvent, + data: event, + }); + } + + return ( + "Can't send to forwarder " + + name + + ', not initialized. Event added to queue.' + ); + } + + function hasEnhancedConversionData(customFlags) { + return ( + customFlags && + Object.keys(customFlags).length && + customFlags[ENHANCED_CONVERSION_DATA] + ); + } + + function parseEnhancedConversionData(conversionData) { + // Checks if conversion data in custom flags is a stringified object + // Conversion data should only be a stringified object or a JS object + if (typeof conversionData === 'string') { + try { + return JSON.parse(conversionData); + } catch (error) { + console.warn( + 'Unrecognized Enhanced Conversion Data Format', + conversionData, + error + ); + return {}; + } + } else if (typeof conversionData === 'object') { + // Not a stringified object so it can be used as-is. However, + // we want to avoid mutating the original state, so we make a copy. + return cloneObject(conversionData); + } else { + console.warn( + 'Unrecognized Enhanced Conversion Data Format', + conversionData + ); + return {}; + } + } + + // Converts an mParticle Commerce Event into either Legacy or gtag Event + function generateCommerceEvent(mPEvent, conversionLabel, isPageEvent) { + if ( + mPEvent.ProductAction && + mPEvent.ProductAction.ProductList && + mPEvent.ProductAction.ProductActionType + ) { + if (window.gtag && forwarderSettings.enableGtag == 'True') { + return generateGtagCommerceEvent( + mPEvent, + conversionLabel, + isPageEvent + ); + } else if (window.google_trackConversion) { + return generateAdwordsCommerceEvent( + mPEvent, + conversionLabel, + isPageEvent + ); + } else { + console.error('Unrecognized Commerce Event', mPEvent); + return false; + } + } else { + return false; + } + } + + function getUserConsentState() { + var userConsentState = {}; + + if ( + window.mParticle && + window.mParticle.Identity && + window.mParticle.Identity.getCurrentUser + ) { + var currentUser = window.mParticle.Identity.getCurrentUser(); + + if (!currentUser) { + return {}; + } + + var consentState = window.mParticle.Identity.getCurrentUser().getConsentState(); + + if (consentState && consentState.getGDPRConsentState) { + userConsentState = consentState.getGDPRConsentState(); + } + } + + return userConsentState; + } + + function getEventConsentState(eventConsentState) { + return eventConsentState && eventConsentState.getGDPRConsentState + ? eventConsentState.getGDPRConsentState() + : {}; + } + + // ** Adwords Events + function getBaseAdWordEvent() { + var adWordEvent = {}; + adWordEvent.google_conversion_value = 0; + adWordEvent.google_conversion_language = 'en'; + adWordEvent.google_conversion_format = '3'; + adWordEvent.google_conversion_color = 'ffffff'; + adWordEvent.google_remarketing_only = + forwarderSettings.remarketingOnly == 'True'; + adWordEvent.google_conversion_id = forwarderSettings.conversionId; + return adWordEvent; + } + + function generateAdwordsEvent(mPEvent, conversionLabel, customProps) { + var adWordEvent = getBaseAdWordEvent(); + adWordEvent.google_conversion_label = conversionLabel; + adWordEvent.google_custom_params = customProps; + + return adWordEvent; + } + + function generateAdwordsCommerceEvent( + mPEvent, + conversionLabel, + customProps + ) { + var adWordEvent = getBaseAdWordEvent(); + adWordEvent.google_conversion_label = conversionLabel; + + if ( + mPEvent.ProductAction.ProductActionType === + mParticle.ProductActionType.Purchase && + mPEvent.ProductAction.TransactionId + ) { + adWordEvent.google_conversion_order_id = + mPEvent.ProductAction.TransactionId; + } + + if (mPEvent.CurrencyCode) { + adWordEvent.google_conversion_currency = mPEvent.CurrencyCode; + } + + if (mPEvent.ProductAction.TotalAmount) { + adWordEvent.google_conversion_value = + mPEvent.ProductAction.TotalAmount; + } + + adWordEvent.google_custom_params = customProps; + return adWordEvent; + } + + function getConsentSettings() { + var consentSettings = {}; + + var googleToMpConsentSettingsMapping = { + // Inherited from S2S Integration Settings + ad_user_data: 'defaultAdUserDataConsent', + ad_personalization: 'defaultAdPersonalizationConsent', + + // Unique to Web Kits + ad_storage: 'defaultAdStorageConsentWeb', + analytics_storage: 'defaultAnalyticsStorageConsentWeb', + }; + + Object.keys(googleToMpConsentSettingsMapping).forEach(function( + googleConsentKey + ) { + var mpConsentSettingKey = + googleToMpConsentSettingsMapping[googleConsentKey]; + var googleConsentValuesKey = forwarderSettings[mpConsentSettingKey]; + + if (googleConsentValuesKey && mpConsentSettingKey) { + consentSettings[googleConsentKey] = + googleConsentValues[googleConsentValuesKey]; + } + }); + + return consentSettings; + } + + // gtag Events + function getBaseGtagEvent(conversionLabel) { + return { + send_to: gtagSiteId + '/' + conversionLabel, + value: 0, + language: 'en', + remarketing_only: forwarderSettings.remarketingOnly == 'True', + }; + } + + function generateGtagEvent(mPEvent, conversionLabel, customProps) { + if (!conversionLabel) { + return null; + } + + var conversionPayload = getBaseGtagEvent(conversionLabel); + conversionPayload.transaction_id = mPEvent.SourceMessageId; + return mergeObjects(conversionPayload, customProps); + } + + function generateGtagCommerceEvent(mPEvent, conversionLabel, customProps) { + if (!conversionLabel) { + return null; + } + + var conversionPayload = getBaseGtagEvent(conversionLabel); + + if ( + mPEvent.ProductAction.ProductActionType === + mParticle.ProductActionType.Purchase && + mPEvent.ProductAction.TransactionId + ) { + conversionPayload.transaction_id = + mPEvent.ProductAction.TransactionId; + } else { + conversionPayload.transaction_id = mPEvent.SourceMessageId; + } + + if (mPEvent.CurrencyCode) { + conversionPayload.currency = mPEvent.CurrencyCode; + } + + if (mPEvent.ProductAction.TotalAmount) { + conversionPayload.value = mPEvent.ProductAction.TotalAmount; + } + + return mergeObjects(conversionPayload, customProps); + } + + function sendGtagEvent(payload) { + // https://go.mparticle.com/work/SQDSDKS-6165 + try { + gtag('event', 'conversion', payload); + } catch (e) { + console.error( + 'gtag is not available to send payload: ', + payload, + e + ); + return false; + } + return true; + } + + function maybeSendConsentUpdateToGoogle(consentState) { + if ( + consentPayloadAsString && + forwarderSettings.consentMappingWeb && + !isEmpty(consentState) + ) { + var updatedConsentPayload = generateConsentStatePayloadFromMappings( + consentState, + consentMappings + ); + + var eventConsentAsString = JSON.stringify(updatedConsentPayload); + + if (eventConsentAsString !== consentPayloadAsString) { + sendGtagConsentUpdate(updatedConsentPayload); + consentPayloadAsString = eventConsentAsString; + } + } + } + + function sendGtagConsentDefaults(payload) { + // https://go.mparticle.com/work/SQDSDKS-6165 + consentPayloadAsString = JSON.stringify(payload); + + try { + gtag('consent', 'default', payload); + } catch (e) { + console.error( + 'gtag is not available to send consent defaults: ', + payload, + e + ); + return false; + } + return true; + } + + function sendGtagConsentUpdate(payload) { + // https://go.mparticle.com/work/SQDSDKS-6165 + try { + gtag('consent', 'update', payload); + } catch (e) { + console.error( + 'gtag is not available to send consent update: ', + payload, + e + ); + return false; + } + return true; + } + + function sendAdwordsEvent(payload) { + try { + window.google_trackConversion(payload); + } catch (e) { + console.error( + 'google_trackConversion is not available to send payload: ', + payload, + e + ); + return false; + } + return true; + } + + // Creates a new Consent State Payload based on Consent State and Mapping + function generateConsentStatePayloadFromMappings(consentState, mappings) { + if (!mappings) return {}; + var payload = cloneObject(consentPayloadDefaults); + + for (var i = 0; i <= mappings.length - 1; i++) { + var mappingEntry = mappings[i]; + // Although consent purposes can be inputted into the UI in any casing + // the SDK will automatically lowercase them to prevent pseudo-duplicate + // consent purposes, so we call `toLowerCase` on the consentMapping purposes here + var mpMappedConsentName = mappingEntry.map.toLowerCase(); + // var mpMappedConsentName = mappingEntry.map; + var googleMappedConsentName = mappingEntry.value; + + if ( + consentState[mpMappedConsentName] && + googleConsentProperties.indexOf(googleMappedConsentName) !== -1 + ) { + payload[googleMappedConsentName] = consentState[ + mpMappedConsentName + ].Consented + ? googleConsentValues.Granted + : googleConsentValues.Denied; + } + } + + return payload; + } + + // Looks up an Event's conversionLabel from customAttributeMappings based on computed jsHash value + function getConversionLabel(event) { + var jsHash = calculateJSHash( + event.EventDataType, + event.EventCategory, + event.EventName + ); + var type = + event.EventDataType === MessageType.PageEvent + ? 'EventClass.Id' + : 'EventClassDetails.Id'; + var conversionLabel = null; + var mappingEntry = findValueInMapping(jsHash, type, labels); + + if (mappingEntry) { + conversionLabel = mappingEntry.value; + } + + return conversionLabel; + } + + // Filters Event.EventAttributes for attributes that are in customAttributeMappings + function getCustomProps(event) { + var customProps = {}; + var attributes = event.EventAttributes; + var type = + event.EventDataType === MessageType.PageEvent + ? 'EventAttributeClass.Id' + : 'EventAttributeClassDetails.Id'; + + if (attributes) { + for (var attributeKey in attributes) { + if (attributes.hasOwnProperty(attributeKey)) { + var jsHash = calculateJSHash( + event.EventDataType, + event.EventCategory, + attributeKey + ); + var mappingEntry = findValueInMapping( + jsHash, + type, + customAttributeMappings + ); + if (mappingEntry) { + customProps[mappingEntry.value] = + attributes[attributeKey]; + } + } + } + } + + return customProps; + } + + function findValueInMapping(jsHash, type, mapping) { + if (mapping) { + var filteredArray = mapping.filter(function(mappingEntry) { + if ( + mappingEntry.jsmap && + mappingEntry.maptype && + mappingEntry.value + ) { + return ( + mappingEntry.jsmap == jsHash && + mappingEntry.maptype == type + ); + } + + return false; + }); + + if (filteredArray && filteredArray.length > 0) { + return filteredArray[0]; + } + } + return null; + } + + function calculateJSHash(eventDataType, eventCategory, name) { + var preHash = [eventDataType, eventCategory, name].join(''); + + return mParticle.generateHash(preHash); + } + + function loadGtagSnippet() { + (function() { + window.dataLayer = window.dataLayer || []; + window.gtag = function() { + dataLayer.push(arguments); + }; + + var gTagScript = document.createElement('script'); + gTagScript.async = true; + gTagScript.onload = function() { + gtag('js', new Date()); + if (forwarderSettings.enableEnhancedConversions === 'True') { + gtag('config', gtagSiteId, { + allow_enhanced_conversions: true, + }); + } else { + gtag('config', gtagSiteId); + } + isInitialized = true; + processQueue(eventQueue); + }; + gTagScript.src = + 'https://www.googletagmanager.com/gtag/js?id=' + gtagSiteId; + document.getElementsByTagName('head')[0].appendChild(gTagScript); + })(); + } + + function loadLegacySnippet() { + (function() { + var googleAdwords = document.createElement('script'); + googleAdwords.type = 'text/javascript'; + googleAdwords.async = true; + googleAdwords.onload = function() { + isInitialized = true; + processQueue(eventQueue); + }; + googleAdwords.src = + ('https:' == document.location.protocol ? 'https' : 'http') + + '://www.googleadservices.com/pagead/conversion_async.js'; + document.getElementsByTagName('head')[0].appendChild(googleAdwords); + })(); + } + + // https://go.mparticle.com/work/SQDSDKS-6166 + function initForwarder(settings, service, testMode) { + window.enhanced_conversion_data = {}; + forwarderSettings = settings; + reportingService = service; + + try { + if (!forwarderSettings.conversionId) { + return ( + "Can't initialize forwarder: " + + name + + ', conversionId is not defined' + ); + } + + gtagSiteId = 'AW-' + forwarderSettings.conversionId; + + if (testMode !== true) { + if (forwarderSettings.enableGtag == 'True') { + loadGtagSnippet(); + } else { + loadLegacySnippet(); + } + } else { + isInitialized = true; + processQueue(eventQueue); + } + + if (!forwarderSettings.conversionId) { + return ( + "Can't initialize forwarder: " + + name + + ', conversionId is not defined' + ); + } + + // https://go.mparticle.com/work/SQDSDKS-6165 + if (window.gtag && forwarderSettings.enableGtag === 'True') { + if (forwarderSettings.consentMappingWeb) { + consentMappings = parseSettingsString( + forwarderSettings.consentMappingWeb + ); + } else { + // Ensures consent mappings is an empty array + // for future use + consentMappings = []; + } + + consentPayloadDefaults = getConsentSettings(); + var defaultConsentPayload = cloneObject(consentPayloadDefaults); + var updatedConsentState = getUserConsentState(); + var updatedDefaultConsentPayload = generateConsentStatePayloadFromMappings( + updatedConsentState, + consentMappings + ); + + if (!isEmpty(defaultConsentPayload)) { + sendGtagConsentDefaults(defaultConsentPayload); + } else if (!isEmpty(updatedDefaultConsentPayload)) { + sendGtagConsentDefaults(updatedDefaultConsentPayload); + } + + maybeSendConsentUpdateToGoogle(updatedConsentState); + } + + forwarderSettings.remarketingOnly = + forwarderSettings.remarketingOnly == 'True'; + + try { + if (forwarderSettings.labels) { + labels = JSON.parse( + forwarderSettings.labels.replace(/"/g, '"') + ); + } + + if (forwarderSettings.customParameters) { + customAttributeMappings = JSON.parse( + forwarderSettings.customParameters.replace( + /"/g, + '"' + ) + ); + } + } catch (e) { + return ( + "Can't initialize forwarder: " + + name + + ', Could not process event to label mapping' + ); + } + + return 'Successfully initialized: ' + name; + } catch (e) { + return 'Failed to initialize: ' + name; + } + } + + function processQueue(queue) { + var item; + + if ( + (window.gtag || window.google_trackConversion) && + queue.length > 0 + ) { + try { + while (queue.length > 0) { + item = queue.shift(); + item.action(item.data); + } + } catch (e) { + console.error('Error on mParticle Adwords Kit', e); + } + } + } + + this.init = initForwarder; + this.process = processEvent; + this.processQueue = processQueue; +}; + +function getId() { + return moduleId; +} + +function register(config) { + if (!config) { + console.log( + 'You must pass a config object to register the kit ' + name + ); + return; + } + + if (!isObject(config)) { + console.log( + "'config' must be an object. You passed in a " + typeof config + ); + return; + } + + if (isObject(config.kits)) { + config.kits[name] = { + constructor: constructor, + }; + } else { + config.kits = {}; + config.kits[name] = { + constructor: constructor, + }; + } + console.log( + 'Successfully registered ' + name + ' to your mParticle configuration' + ); +} + +function parseSettingsString(settingsString) { + return JSON.parse(settingsString.replace(/"/g, '"')); +} + +function isObject(val) { + return ( + val != null && typeof val === 'object' && Array.isArray(val) === false + ); +} + +function isEmpty(value) { + return value == null || !(Object.keys(value) || value).length; +} + +function mergeObjects() { + var resObj = {}; + for (var i = 0; i < arguments.length; i += 1) { + var obj = arguments[i], + keys = Object.keys(obj); + for (var j = 0; j < keys.length; j += 1) { + resObj[keys[j]] = obj[keys[j]]; + } + } + return resObj; +} + +function cloneObject(obj) { + return JSON.parse(JSON.stringify(obj)); +} + +if (typeof window !== 'undefined') { + if (window && window.mParticle && window.mParticle.addForwarder) { + window.mParticle.addForwarder({ + name: name, + constructor: constructor, + getId: getId, + }); + } +} + +var GoogleAdWordsEventForwarder = { + register: register, +}; + +exports.default = GoogleAdWordsEventForwarder; diff --git a/kits/adwords/dist/GoogleAdWordsEventForwarder.iife.js b/kits/adwords/dist/GoogleAdWordsEventForwarder.iife.js new file mode 100644 index 000000000..ff4265579 --- /dev/null +++ b/kits/adwords/dist/GoogleAdWordsEventForwarder.iife.js @@ -0,0 +1,842 @@ +var mpAdWordsKit = (function (exports) { + /* eslint-disable no-undef*/ + + // + // Copyright 2017 mParticle, Inc. + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + + var name = 'GoogleAdWords', + moduleId = 82, + MessageType = { + SessionStart: 1, + SessionEnd: 2, + PageView: 3, + PageEvent: 4, + CrashReport: 5, + OptOut: 6, + Commerce: 16, + }, + ENHANCED_CONVERSION_DATA = 'GoogleAds.ECData'; + + // Declares valid Google consent values + var googleConsentValues = { + // Server Integration uses 'Unspecified' as a value when the setting is 'not set'. + // However, this is not used by Google's Web SDK. We are referencing it here as a comment + // as a record of this distinction and for posterity. + // If Google ever adds this for web, the line can just be uncommented to support this. + // + // Docs: + // Web: https://developers.google.com/tag-platform/gtagjs/reference#consent + // S2S: https://developers.google.com/google-ads/api/reference/rpc/v15/ConsentStatusEnum.ConsentStatus + // + // Unspecified: 'unspecified', + Denied: 'denied', + Granted: 'granted', + }; + + // Declares list of valid Google Consent Properties + var googleConsentProperties = [ + 'ad_storage', + 'ad_user_data', + 'ad_personalization', + 'analytics_storage', + ]; + + var constructor = function() { + var self = this, + isInitialized = false, + forwarderSettings, + labels, + customAttributeMappings, + consentMappings = [], + consentPayloadDefaults = {}, + consentPayloadAsString = '', + reportingService, + eventQueue = [], + gtagSiteId; + + self.name = name; + + function processEvent(event) { + var reportEvent = false; + var sendEventFunction = function() {}; + var generateEventFunction = function() {}; + var conversionLabel; + var eventPayload; + + if (isInitialized) { + // First, process anything in the queue + processQueue(eventQueue); + + try { + if (window.gtag && forwarderSettings.enableGtag == 'True') { + // If consent payload is empty, + // we never sent an initial default consent state + // so we shouldn't send an update. + var eventConsentState = getEventConsentState( + event.ConsentState + ); + maybeSendConsentUpdateToGoogle(eventConsentState); + + if ( + forwarderSettings.enableEnhancedConversions === + 'True' && + hasEnhancedConversionData(event.CustomFlags) + ) { + window.enhanced_conversion_data = parseEnhancedConversionData( + event.CustomFlags[ENHANCED_CONVERSION_DATA] + ); + } + + sendEventFunction = sendGtagEvent; + generateEventFunction = generateGtagEvent; + generateCommerceEvent = generateGtagCommerceEvent; + } else if (window.google_trackConversion) { + // window.google_trackConversion is a legacy API and will be deprecated + sendEventFunction = sendAdwordsEvent; + generateEventFunction = generateAdwordsEvent; + generateCommerceEvent = generateAdwordsCommerceEvent; + } else { + eventQueue.push({ + action: processEvent, + data: event, + }); + + return ( + "Can't send to forwarder " + + name + + ', not initialized. Event added to queue.' + ); + } + + // Get conversionLabel to be used for event generation + var conversionLabel = getConversionLabel(event); + var customProps = getCustomProps(event); + + if (conversionLabel) { + // Determines the proper event to fire + if ( + event.EventDataType == MessageType.PageView || + event.EventDataType == MessageType.PageEvent + ) { + eventPayload = generateEventFunction( + event, + conversionLabel, + customProps + ); + } else if ( + event.EventDataType == MessageType.Commerce && + event.ProductAction + ) { + eventPayload = generateCommerceEvent( + event, + conversionLabel, + customProps + ); + } + + if (eventPayload) { + reportEvent = sendEventFunction(eventPayload); + } + + if (reportEvent && reportingService) { + reportingService(self, event); + + return 'Successfully sent to ' + name; + } + } + + return ( + "Can't send to forwarder: " + name + '. Event not mapped' + ); + } catch (e) { + console.error('Can\t send to forwarder', e); + return "Can't send to forwarder: " + name + ' ' + e; + } + } else { + eventQueue.push({ + action: processEvent, + data: event, + }); + } + + return ( + "Can't send to forwarder " + + name + + ', not initialized. Event added to queue.' + ); + } + + function hasEnhancedConversionData(customFlags) { + return ( + customFlags && + Object.keys(customFlags).length && + customFlags[ENHANCED_CONVERSION_DATA] + ); + } + + function parseEnhancedConversionData(conversionData) { + // Checks if conversion data in custom flags is a stringified object + // Conversion data should only be a stringified object or a JS object + if (typeof conversionData === 'string') { + try { + return JSON.parse(conversionData); + } catch (error) { + console.warn( + 'Unrecognized Enhanced Conversion Data Format', + conversionData, + error + ); + return {}; + } + } else if (typeof conversionData === 'object') { + // Not a stringified object so it can be used as-is. However, + // we want to avoid mutating the original state, so we make a copy. + return cloneObject(conversionData); + } else { + console.warn( + 'Unrecognized Enhanced Conversion Data Format', + conversionData + ); + return {}; + } + } + + // Converts an mParticle Commerce Event into either Legacy or gtag Event + function generateCommerceEvent(mPEvent, conversionLabel, isPageEvent) { + if ( + mPEvent.ProductAction && + mPEvent.ProductAction.ProductList && + mPEvent.ProductAction.ProductActionType + ) { + if (window.gtag && forwarderSettings.enableGtag == 'True') { + return generateGtagCommerceEvent( + mPEvent, + conversionLabel, + isPageEvent + ); + } else if (window.google_trackConversion) { + return generateAdwordsCommerceEvent( + mPEvent, + conversionLabel, + isPageEvent + ); + } else { + console.error('Unrecognized Commerce Event', mPEvent); + return false; + } + } else { + return false; + } + } + + function getUserConsentState() { + var userConsentState = {}; + + if ( + window.mParticle && + window.mParticle.Identity && + window.mParticle.Identity.getCurrentUser + ) { + var currentUser = window.mParticle.Identity.getCurrentUser(); + + if (!currentUser) { + return {}; + } + + var consentState = window.mParticle.Identity.getCurrentUser().getConsentState(); + + if (consentState && consentState.getGDPRConsentState) { + userConsentState = consentState.getGDPRConsentState(); + } + } + + return userConsentState; + } + + function getEventConsentState(eventConsentState) { + return eventConsentState && eventConsentState.getGDPRConsentState + ? eventConsentState.getGDPRConsentState() + : {}; + } + + // ** Adwords Events + function getBaseAdWordEvent() { + var adWordEvent = {}; + adWordEvent.google_conversion_value = 0; + adWordEvent.google_conversion_language = 'en'; + adWordEvent.google_conversion_format = '3'; + adWordEvent.google_conversion_color = 'ffffff'; + adWordEvent.google_remarketing_only = + forwarderSettings.remarketingOnly == 'True'; + adWordEvent.google_conversion_id = forwarderSettings.conversionId; + return adWordEvent; + } + + function generateAdwordsEvent(mPEvent, conversionLabel, customProps) { + var adWordEvent = getBaseAdWordEvent(); + adWordEvent.google_conversion_label = conversionLabel; + adWordEvent.google_custom_params = customProps; + + return adWordEvent; + } + + function generateAdwordsCommerceEvent( + mPEvent, + conversionLabel, + customProps + ) { + var adWordEvent = getBaseAdWordEvent(); + adWordEvent.google_conversion_label = conversionLabel; + + if ( + mPEvent.ProductAction.ProductActionType === + mParticle.ProductActionType.Purchase && + mPEvent.ProductAction.TransactionId + ) { + adWordEvent.google_conversion_order_id = + mPEvent.ProductAction.TransactionId; + } + + if (mPEvent.CurrencyCode) { + adWordEvent.google_conversion_currency = mPEvent.CurrencyCode; + } + + if (mPEvent.ProductAction.TotalAmount) { + adWordEvent.google_conversion_value = + mPEvent.ProductAction.TotalAmount; + } + + adWordEvent.google_custom_params = customProps; + return adWordEvent; + } + + function getConsentSettings() { + var consentSettings = {}; + + var googleToMpConsentSettingsMapping = { + // Inherited from S2S Integration Settings + ad_user_data: 'defaultAdUserDataConsent', + ad_personalization: 'defaultAdPersonalizationConsent', + + // Unique to Web Kits + ad_storage: 'defaultAdStorageConsentWeb', + analytics_storage: 'defaultAnalyticsStorageConsentWeb', + }; + + Object.keys(googleToMpConsentSettingsMapping).forEach(function( + googleConsentKey + ) { + var mpConsentSettingKey = + googleToMpConsentSettingsMapping[googleConsentKey]; + var googleConsentValuesKey = forwarderSettings[mpConsentSettingKey]; + + if (googleConsentValuesKey && mpConsentSettingKey) { + consentSettings[googleConsentKey] = + googleConsentValues[googleConsentValuesKey]; + } + }); + + return consentSettings; + } + + // gtag Events + function getBaseGtagEvent(conversionLabel) { + return { + send_to: gtagSiteId + '/' + conversionLabel, + value: 0, + language: 'en', + remarketing_only: forwarderSettings.remarketingOnly == 'True', + }; + } + + function generateGtagEvent(mPEvent, conversionLabel, customProps) { + if (!conversionLabel) { + return null; + } + + var conversionPayload = getBaseGtagEvent(conversionLabel); + conversionPayload.transaction_id = mPEvent.SourceMessageId; + return mergeObjects(conversionPayload, customProps); + } + + function generateGtagCommerceEvent(mPEvent, conversionLabel, customProps) { + if (!conversionLabel) { + return null; + } + + var conversionPayload = getBaseGtagEvent(conversionLabel); + + if ( + mPEvent.ProductAction.ProductActionType === + mParticle.ProductActionType.Purchase && + mPEvent.ProductAction.TransactionId + ) { + conversionPayload.transaction_id = + mPEvent.ProductAction.TransactionId; + } else { + conversionPayload.transaction_id = mPEvent.SourceMessageId; + } + + if (mPEvent.CurrencyCode) { + conversionPayload.currency = mPEvent.CurrencyCode; + } + + if (mPEvent.ProductAction.TotalAmount) { + conversionPayload.value = mPEvent.ProductAction.TotalAmount; + } + + return mergeObjects(conversionPayload, customProps); + } + + function sendGtagEvent(payload) { + // https://go.mparticle.com/work/SQDSDKS-6165 + try { + gtag('event', 'conversion', payload); + } catch (e) { + console.error( + 'gtag is not available to send payload: ', + payload, + e + ); + return false; + } + return true; + } + + function maybeSendConsentUpdateToGoogle(consentState) { + if ( + consentPayloadAsString && + forwarderSettings.consentMappingWeb && + !isEmpty(consentState) + ) { + var updatedConsentPayload = generateConsentStatePayloadFromMappings( + consentState, + consentMappings + ); + + var eventConsentAsString = JSON.stringify(updatedConsentPayload); + + if (eventConsentAsString !== consentPayloadAsString) { + sendGtagConsentUpdate(updatedConsentPayload); + consentPayloadAsString = eventConsentAsString; + } + } + } + + function sendGtagConsentDefaults(payload) { + // https://go.mparticle.com/work/SQDSDKS-6165 + consentPayloadAsString = JSON.stringify(payload); + + try { + gtag('consent', 'default', payload); + } catch (e) { + console.error( + 'gtag is not available to send consent defaults: ', + payload, + e + ); + return false; + } + return true; + } + + function sendGtagConsentUpdate(payload) { + // https://go.mparticle.com/work/SQDSDKS-6165 + try { + gtag('consent', 'update', payload); + } catch (e) { + console.error( + 'gtag is not available to send consent update: ', + payload, + e + ); + return false; + } + return true; + } + + function sendAdwordsEvent(payload) { + try { + window.google_trackConversion(payload); + } catch (e) { + console.error( + 'google_trackConversion is not available to send payload: ', + payload, + e + ); + return false; + } + return true; + } + + // Creates a new Consent State Payload based on Consent State and Mapping + function generateConsentStatePayloadFromMappings(consentState, mappings) { + if (!mappings) return {}; + var payload = cloneObject(consentPayloadDefaults); + + for (var i = 0; i <= mappings.length - 1; i++) { + var mappingEntry = mappings[i]; + // Although consent purposes can be inputted into the UI in any casing + // the SDK will automatically lowercase them to prevent pseudo-duplicate + // consent purposes, so we call `toLowerCase` on the consentMapping purposes here + var mpMappedConsentName = mappingEntry.map.toLowerCase(); + // var mpMappedConsentName = mappingEntry.map; + var googleMappedConsentName = mappingEntry.value; + + if ( + consentState[mpMappedConsentName] && + googleConsentProperties.indexOf(googleMappedConsentName) !== -1 + ) { + payload[googleMappedConsentName] = consentState[ + mpMappedConsentName + ].Consented + ? googleConsentValues.Granted + : googleConsentValues.Denied; + } + } + + return payload; + } + + // Looks up an Event's conversionLabel from customAttributeMappings based on computed jsHash value + function getConversionLabel(event) { + var jsHash = calculateJSHash( + event.EventDataType, + event.EventCategory, + event.EventName + ); + var type = + event.EventDataType === MessageType.PageEvent + ? 'EventClass.Id' + : 'EventClassDetails.Id'; + var conversionLabel = null; + var mappingEntry = findValueInMapping(jsHash, type, labels); + + if (mappingEntry) { + conversionLabel = mappingEntry.value; + } + + return conversionLabel; + } + + // Filters Event.EventAttributes for attributes that are in customAttributeMappings + function getCustomProps(event) { + var customProps = {}; + var attributes = event.EventAttributes; + var type = + event.EventDataType === MessageType.PageEvent + ? 'EventAttributeClass.Id' + : 'EventAttributeClassDetails.Id'; + + if (attributes) { + for (var attributeKey in attributes) { + if (attributes.hasOwnProperty(attributeKey)) { + var jsHash = calculateJSHash( + event.EventDataType, + event.EventCategory, + attributeKey + ); + var mappingEntry = findValueInMapping( + jsHash, + type, + customAttributeMappings + ); + if (mappingEntry) { + customProps[mappingEntry.value] = + attributes[attributeKey]; + } + } + } + } + + return customProps; + } + + function findValueInMapping(jsHash, type, mapping) { + if (mapping) { + var filteredArray = mapping.filter(function(mappingEntry) { + if ( + mappingEntry.jsmap && + mappingEntry.maptype && + mappingEntry.value + ) { + return ( + mappingEntry.jsmap == jsHash && + mappingEntry.maptype == type + ); + } + + return false; + }); + + if (filteredArray && filteredArray.length > 0) { + return filteredArray[0]; + } + } + return null; + } + + function calculateJSHash(eventDataType, eventCategory, name) { + var preHash = [eventDataType, eventCategory, name].join(''); + + return mParticle.generateHash(preHash); + } + + function loadGtagSnippet() { + (function() { + window.dataLayer = window.dataLayer || []; + window.gtag = function() { + dataLayer.push(arguments); + }; + + var gTagScript = document.createElement('script'); + gTagScript.async = true; + gTagScript.onload = function() { + gtag('js', new Date()); + if (forwarderSettings.enableEnhancedConversions === 'True') { + gtag('config', gtagSiteId, { + allow_enhanced_conversions: true, + }); + } else { + gtag('config', gtagSiteId); + } + isInitialized = true; + processQueue(eventQueue); + }; + gTagScript.src = + 'https://www.googletagmanager.com/gtag/js?id=' + gtagSiteId; + document.getElementsByTagName('head')[0].appendChild(gTagScript); + })(); + } + + function loadLegacySnippet() { + (function() { + var googleAdwords = document.createElement('script'); + googleAdwords.type = 'text/javascript'; + googleAdwords.async = true; + googleAdwords.onload = function() { + isInitialized = true; + processQueue(eventQueue); + }; + googleAdwords.src = + ('https:' == document.location.protocol ? 'https' : 'http') + + '://www.googleadservices.com/pagead/conversion_async.js'; + document.getElementsByTagName('head')[0].appendChild(googleAdwords); + })(); + } + + // https://go.mparticle.com/work/SQDSDKS-6166 + function initForwarder(settings, service, testMode) { + window.enhanced_conversion_data = {}; + forwarderSettings = settings; + reportingService = service; + + try { + if (!forwarderSettings.conversionId) { + return ( + "Can't initialize forwarder: " + + name + + ', conversionId is not defined' + ); + } + + gtagSiteId = 'AW-' + forwarderSettings.conversionId; + + if (testMode !== true) { + if (forwarderSettings.enableGtag == 'True') { + loadGtagSnippet(); + } else { + loadLegacySnippet(); + } + } else { + isInitialized = true; + processQueue(eventQueue); + } + + if (!forwarderSettings.conversionId) { + return ( + "Can't initialize forwarder: " + + name + + ', conversionId is not defined' + ); + } + + // https://go.mparticle.com/work/SQDSDKS-6165 + if (window.gtag && forwarderSettings.enableGtag === 'True') { + if (forwarderSettings.consentMappingWeb) { + consentMappings = parseSettingsString( + forwarderSettings.consentMappingWeb + ); + } else { + // Ensures consent mappings is an empty array + // for future use + consentMappings = []; + } + + consentPayloadDefaults = getConsentSettings(); + var defaultConsentPayload = cloneObject(consentPayloadDefaults); + var updatedConsentState = getUserConsentState(); + var updatedDefaultConsentPayload = generateConsentStatePayloadFromMappings( + updatedConsentState, + consentMappings + ); + + if (!isEmpty(defaultConsentPayload)) { + sendGtagConsentDefaults(defaultConsentPayload); + } else if (!isEmpty(updatedDefaultConsentPayload)) { + sendGtagConsentDefaults(updatedDefaultConsentPayload); + } + + maybeSendConsentUpdateToGoogle(updatedConsentState); + } + + forwarderSettings.remarketingOnly = + forwarderSettings.remarketingOnly == 'True'; + + try { + if (forwarderSettings.labels) { + labels = JSON.parse( + forwarderSettings.labels.replace(/"/g, '"') + ); + } + + if (forwarderSettings.customParameters) { + customAttributeMappings = JSON.parse( + forwarderSettings.customParameters.replace( + /"/g, + '"' + ) + ); + } + } catch (e) { + return ( + "Can't initialize forwarder: " + + name + + ', Could not process event to label mapping' + ); + } + + return 'Successfully initialized: ' + name; + } catch (e) { + return 'Failed to initialize: ' + name; + } + } + + function processQueue(queue) { + var item; + + if ( + (window.gtag || window.google_trackConversion) && + queue.length > 0 + ) { + try { + while (queue.length > 0) { + item = queue.shift(); + item.action(item.data); + } + } catch (e) { + console.error('Error on mParticle Adwords Kit', e); + } + } + } + + this.init = initForwarder; + this.process = processEvent; + this.processQueue = processQueue; + }; + + function getId() { + return moduleId; + } + + function register(config) { + if (!config) { + console.log( + 'You must pass a config object to register the kit ' + name + ); + return; + } + + if (!isObject(config)) { + console.log( + "'config' must be an object. You passed in a " + typeof config + ); + return; + } + + if (isObject(config.kits)) { + config.kits[name] = { + constructor: constructor, + }; + } else { + config.kits = {}; + config.kits[name] = { + constructor: constructor, + }; + } + console.log( + 'Successfully registered ' + name + ' to your mParticle configuration' + ); + } + + function parseSettingsString(settingsString) { + return JSON.parse(settingsString.replace(/"/g, '"')); + } + + function isObject(val) { + return ( + val != null && typeof val === 'object' && Array.isArray(val) === false + ); + } + + function isEmpty(value) { + return value == null || !(Object.keys(value) || value).length; + } + + function mergeObjects() { + var resObj = {}; + for (var i = 0; i < arguments.length; i += 1) { + var obj = arguments[i], + keys = Object.keys(obj); + for (var j = 0; j < keys.length; j += 1) { + resObj[keys[j]] = obj[keys[j]]; + } + } + return resObj; + } + + function cloneObject(obj) { + return JSON.parse(JSON.stringify(obj)); + } + + if (typeof window !== 'undefined') { + if (window && window.mParticle && window.mParticle.addForwarder) { + window.mParticle.addForwarder({ + name: name, + constructor: constructor, + getId: getId, + }); + } + } + + var GoogleAdWordsEventForwarder = { + register: register, + }; + + exports.default = GoogleAdWordsEventForwarder; + + return exports; + +}({})); diff --git a/kits/amplitude/amplitude-8/dist/Amplitude.common.js b/kits/amplitude/amplitude-8/dist/Amplitude.common.js new file mode 100644 index 000000000..12704582d --- /dev/null +++ b/kits/amplitude/amplitude-8/dist/Amplitude.common.js @@ -0,0 +1,793 @@ +Object.defineProperty(exports, '__esModule', { value: true }); + +/* eslint-disable no-undef*/ +// +// Copyright 2015 mParticle, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +var name = 'Amplitude', + moduleId = 53, + MessageType = { + SessionStart: 1, + SessionEnd: 2, + PageView: 3, + PageEvent: 4, + CrashReport: 5, + OptOut: 6, + Commerce: 16, + }; + +var constants = { + MPID: 'mpId', + customerId: 'customerId', + email: 'email', + other: 'other', + other2: 'other2', + other3: 'other3', + other4: 'other4', + other5: 'other5', + other6: 'other6', + other7: 'other7', + other8: 'other8', + other9: 'other9', + other10: 'other10', +}; + +var MP_AMP_SPLIT = 'mparticle_amplitude_should_split', + TOTAL_AMOUNT = 'Total Amount', + TOTAL = 'Total', + PRODUCTS = 'products', + REFUND = 'Refund', + PURCHASE = 'Purchase', + TOTAL_PRODUCT_AMOUNT = 'Total Product Amount'; + +var includeIndividualProductEvents, + shouldSendSeparateAmplitudeRevenueEvent, + enableTempAmplitudeEcommerce; + +/* eslint-disable */ +// prettier-ignore +var renderSnippet = function() { + (function(e,t){var n=e.amplitude||{_q:[],_iq:{}};var r=t.createElement("script"); + r.type="text/javascript"; + r.integrity="sha384-QahB0HKETlcqjneomU3Ohs+UgJTinhUNFIKJitEl2Vo7DjvphO2jei64ZP5J2GA5"; + r.crossOrigin="anonymous";r.async=true; + r.src="https://cdn.amplitude.com/libs/amplitude-8.21.8-min.gz.js"; + r.onload=function(){if(!e.amplitude.runQueuedFunctions){console.log( + "[Amplitude] Error: could not load SDK");}};var s=t.getElementsByTagName("script" + )[0];s.parentNode.insertBefore(r,s);function i(e,t){e.prototype[t]=function(){ + this._q.push([t].concat(Array.prototype.slice.call(arguments,0)));return this};} + var o=function(){this._q=[];return this};var a=["add","append","clearAll", + "prepend","set","setOnce","unset","preInsert","postInsert","remove"];for( + var c=0;c -1 + ) { + var revenueAmount = + (expandedEvt.EventAttributes['Total Amount'] || 0) * + (isRefund ? -1 : 1); + var revenue = new window.amplitude.Revenue() + .setPrice(revenueAmount) + .setEventProperties(updatedAttributes); + getInstance().logRevenueV2(revenue); + } else { + getInstance().logEvent( + expandedEvt.EventName, + updatedAttributes + ); + } + }); + + return true; + } + } + + // if it is not a product action, it is an impression or promotion commerce event + if (isNotProductAction(event)) { + expandedEvents.forEach(function(expandedEvt) { + // Exclude Totals from the attributes as we log it in the revenue call + var updatedAttributes = createEcommerceAttributes( + expandedEvt.EventAttributes + ); + + getInstance().logEvent( + expandedEvt.EventName, + updatedAttributes + ); + }); + + return true; + } + + console.warn( + 'Commerce event does not conform to our expectations and was not forwarded to Amplitude. Please double-check your code.' + ); + + return false; + } + + /* + When we process a product action event, Amplitude has a very specific way of + sending events to them: + + 1. Send a summary event with event attributes from the MP event. + a. Add a key of `products` with a value of JSON.stringify(productArray). + b. Add a key of mparticle_amplitude_should_split with a value of `false`. + + 2. Determine if we send product level events or not. + a. If includeIndividualProductEvents === true, send product level events + b. If includeIndividualProductEvents === false, do not send product level events + + 3. Determine if we send an Amplitude revenue event or not. + a. If shouldSendSeparateAmplitudeRevenueEvent === true, send an Amplitude revenue event. + b. If shouldSendSeparateAmplitudeRevenueEvent === true, the summary event attribute should be `revenue`. + c. If shouldSendSeparateAmplitudeRevenueEvent === false, the summary event attribute should be `$revenue` + + See test/AmplitudeCommerceEvent.MD for examples of what the expectations of the payload are. + + */ + function processTemporaryProductAction( + unexpandedCommerceEvent, + expandedEvents + ) { + var summaryEvent, isRefund, isPurchase, isMPRevenueEvent; + + isRefund = + unexpandedCommerceEvent.ProductAction.ProductActionType === + mParticle.ProductActionType.Refund; + isPurchase = + unexpandedCommerceEvent.ProductAction.ProductActionType === + mParticle.ProductActionType.Purchase; + isMPRevenueEvent = isRefund || isPurchase; + + // if the event is a revenue event, then we set it to the expanded `Total` event for backwards compatibility + if ( + isMPRevenueEvent && + expandedEvents[0].EventName.indexOf(TOTAL) > -1 + ) { + summaryEvent = expandedEvents[0]; + sendMPRevenueSummaryEvent( + summaryEvent, + unexpandedCommerceEvent.ProductAction.ProductList, + isRefund, + shouldSendSeparateAmplitudeRevenueEvent + ); + } + + if (!isMPRevenueEvent) { + sendSummaryEvent(unexpandedCommerceEvent); + } + + if (includeIndividualProductEvents) { + sendIndividualProductEvents( + expandedEvents, + isMPRevenueEvent, + shouldSendSeparateAmplitudeRevenueEvent, + isRefund + ); + } + + return true; + } + + // If event.ProductAction does not exist, the commerce event is a promotion or impression event + function isNotProductAction(event) { + return ( + event.EventCategory === + mParticle.CommerceEventType.ProductImpression || + event.EventCategory === mParticle.CommerceEventType.PromotionView || + event.EventCategory === mParticle.CommerceEventType.PromotionClick + ); + } + + // this function does not use Amplitude's logRevenueV2, but rather sends custom event names + function sendMPRevenueSummaryEvent( + summaryEvent, + products, + isRefund, + shouldSendSeparateAmplitudeRevenueEvent + ) { + // send the ecommerce - purchase event + var updatedAttributes = createMPRevenueEcommerceAttributes( + summaryEvent.EventAttributes, + shouldSendSeparateAmplitudeRevenueEvent, + isRefund + ); + updatedAttributes[MP_AMP_SPLIT] = false; + + updatedAttributes[PRODUCTS] = products; + var revenueEventLabel = isRefund ? REFUND : PURCHASE; + getInstance().logEvent( + 'eCommerce - ' + revenueEventLabel, + updatedAttributes + ); + } + + // revenue summary event will either have $price/price or $revenue/revenue depending on if + function createMPRevenueEcommerceAttributes( + attributes, + shouldSendSeparateAmplitudeRevenueEvent, + isRefund + ) { + var updatedAttributes = {}; + for (var key in attributes) { + if (key === TOTAL_AMOUNT) { + // A purchase is a positive amount and a refund is negative + var revenueAmount = attributes[key] * (isRefund ? -1 : 1); + // If we send a separate Amplitude Revenue Event, Amplitude's + // SDK prefixes price/revenue with a $ for calculating things + // like LTV, so we do not want to prepend it as part of the + // summary event to avoid double counting + var revenueKey = shouldSendSeparateAmplitudeRevenueEvent + ? 'revenue' + : '$revenue'; + + updatedAttributes[revenueKey] = revenueAmount; + } else if (key !== TOTAL_AMOUNT) { + updatedAttributes[key] = attributes[key]; + } + } + + return convertJsonAttrs(updatedAttributes); + } + + function createAttrsForAmplitudeRevenueEvent(attributes) { + var updatedAttributes = {}; + for (var key in attributes) { + if (key !== TOTAL_AMOUNT) { + updatedAttributes[key] = attributes[key]; + } + } + + return convertJsonAttrs(updatedAttributes); + } + + function sendSummaryEvent(summaryEvent) { + var updatedAttributes = createEcommerceAttributes( + summaryEvent.EventAttributes + ); + updatedAttributes[MP_AMP_SPLIT] = false; + try { + updatedAttributes[PRODUCTS] = + summaryEvent.ProductAction.ProductList; + } catch (e) { + console.error('error adding Product List to summary event'); + } + + getInstance().logEvent(summaryEvent.EventName, updatedAttributes); + } + + function sendIndividualProductEvents( + expandedEvents, + isMPRevenueEvent, + shouldSendSeparateAmplitudeRevenueEvent, + isRefund + ) { + expandedEvents.forEach(function(expandedEvt) { + var updatedAttributes; + // `Total` exists on an expanded event if it is part of a revenue/purchase event + // but not on other commerce events. This only needs to be fired if shouldSendSeparateAmplitudeRevenueEvent === True + if ( + isMPRevenueEvent && + // A purchase is a positive amount and a refund is negative + (expandedEvt.EventName.indexOf(TOTAL) > -1) & + shouldSendSeparateAmplitudeRevenueEvent + ) { + var revenueAmount = + // A purchase is a positive amount and a refund is negative + (expandedEvt.EventAttributes[TOTAL_AMOUNT] || 0) * + (isRefund ? -1 : 1); + updatedAttributes = createAttrsForAmplitudeRevenueEvent( + expandedEvt.EventAttributes + ); + + var revenue = new window.amplitude.Revenue() + .setPrice(revenueAmount) + .setEventProperties(updatedAttributes); + getInstance().logRevenueV2(revenue); + } else if (expandedEvt.EventName.indexOf(TOTAL) === -1) { + updatedAttributes = createEcommerceAttributes( + expandedEvt.EventAttributes + ); + getInstance().logEvent( + expandedEvt.EventName, + updatedAttributes + ); + } + }); + } + + function convertJsonAttrs(customAttributes) { + if (forwarderSettings.sendEventAttributesAsObjects === 'True') { + for (var key in customAttributes) { + if (typeof customAttributes[key] === 'string') { + try { + var parsed = JSON.parse(customAttributes[key]); + if (typeof parsed === 'object') { + customAttributes[key] = parsed; + } + } catch (e) { + // if parsing fails, don't update the customAttribute object + } + } + } + } + + return customAttributes; + } + + function initForwarder(settings, service, testMode) { + var ampSettings; + + forwarderSettings = settings; + reportingService = service; + + // Changing this setting from a negative action to a positive action for readability + includeIndividualProductEvents = + forwarderSettings.excludeIndividualProductEvents === 'False'; + // Only send separate amplitude revenue events when we includeIndividualProductEvents, + // so create this variable for clarity + shouldSendSeparateAmplitudeRevenueEvent = includeIndividualProductEvents; + + enableTempAmplitudeEcommerce = + forwarderSettings.enableTempAmplitudeEcommerce === 'True'; + try { + if (!window.amplitude) { + if (testMode !== true) { + renderSnippet(); + } + } + + ampSettings = {}; + + // allow the client to set custom amplitude init properties + if ( + typeof window.AmplitudeInitSettings === 'object' && + window.AmplitudeInitSettings !== null + ) { + ampSettings = window.AmplitudeInitSettings; + } + + if (forwarderSettings.saveEvents) { + ampSettings.saveEvents = + forwarderSettings.saveEvents === 'True'; + } + + if (forwarderSettings.savedMaxCount) { + ampSettings.savedMaxCount = parseInt( + forwarderSettings.savedMaxCount, + 10 + ); + } + + if (forwarderSettings.uploadBatchSize) { + ampSettings.uploadBatchSize = parseInt( + forwarderSettings.uploadBatchSize, + 10 + ); + } + + if (forwarderSettings.includeUtm) { + ampSettings.includeUtm = + forwarderSettings.includeUtm === 'True'; + } + + if (forwarderSettings.includeReferrer) { + ampSettings.includeReferrer = + forwarderSettings.includeReferrer === 'True'; + } + + if (forwarderSettings.forceHttps) { + ampSettings.forceHttps = + forwarderSettings.forceHttps === 'True'; + } + + if (forwarderSettings.baseUrl) { + ampSettings.apiEndpoint = forwarderSettings.baseUrl; + } + + isDefaultInstance = + !forwarderSettings.instanceName || + forwarderSettings.instanceName === 'default'; + + getInstance().init(forwarderSettings.apiKey, null, ampSettings); + isInitialized = true; + + if (forwarderSettings.userIdentification === constants.MPID) { + if (window.mParticle && window.mParticle.Identity) { + var user = window.mParticle.Identity.getCurrentUser(); + if (user) { + var userId = user.getMPID(); + getInstance().setUserId(userId); + } + } + } + + return 'Successfully initialized: ' + name; + } catch (e) { + return 'Failed to initialize: ' + name; + } + } + + this.init = initForwarder; + this.process = processEvent; + this.setUserIdentity = setUserIdentity; + this.onUserIdentified = onUserIdentified; + this.setUserAttribute = setUserAttribute; + this.setOptOut = setOptOut; + this.removeUserAttribute = removeUserAttribute; +}; + +function getId() { + return moduleId; +} + +function isObject(val) { + return ( + val != null && typeof val === 'object' && Array.isArray(val) === false + ); +} + +function register(config) { + if (!config) { + console.log( + 'You must pass a config object to register the kit ' + name + ); + return; + } + + if (!isObject(config)) { + console.log( + 'The "config" must be an object. You passed in a ' + typeof config + ); + return; + } + + if (isObject(config.kits)) { + config.kits[name] = { + constructor: constructor, + }; + } else { + config.kits = {}; + config.kits[name] = { + constructor: constructor, + }; + } + console.log( + 'Successfully registered ' + name + ' to your mParticle configuration' + ); +} + +if (typeof window !== 'undefined') { + if (window && window.mParticle && window.mParticle.addForwarder) { + window.mParticle.addForwarder({ + name: name, + constructor: constructor, + getId: getId, + }); + } +} + +var Amplitude = { + register: register, +}; +var Amplitude_1 = Amplitude.register; + +exports["default"] = Amplitude; +exports.register = Amplitude_1; diff --git a/kits/amplitude/amplitude-8/dist/Amplitude.esm.js b/kits/amplitude/amplitude-8/dist/Amplitude.esm.js new file mode 100644 index 000000000..ae6cb0496 --- /dev/null +++ b/kits/amplitude/amplitude-8/dist/Amplitude.esm.js @@ -0,0 +1,790 @@ +/* eslint-disable no-undef*/ +// +// Copyright 2015 mParticle, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +var name = 'Amplitude', + moduleId = 53, + MessageType = { + SessionStart: 1, + SessionEnd: 2, + PageView: 3, + PageEvent: 4, + CrashReport: 5, + OptOut: 6, + Commerce: 16, + }; + +var constants = { + MPID: 'mpId', + customerId: 'customerId', + email: 'email', + other: 'other', + other2: 'other2', + other3: 'other3', + other4: 'other4', + other5: 'other5', + other6: 'other6', + other7: 'other7', + other8: 'other8', + other9: 'other9', + other10: 'other10', +}; + +var MP_AMP_SPLIT = 'mparticle_amplitude_should_split', + TOTAL_AMOUNT = 'Total Amount', + TOTAL = 'Total', + PRODUCTS = 'products', + REFUND = 'Refund', + PURCHASE = 'Purchase', + TOTAL_PRODUCT_AMOUNT = 'Total Product Amount'; + +var includeIndividualProductEvents, + shouldSendSeparateAmplitudeRevenueEvent, + enableTempAmplitudeEcommerce; + +/* eslint-disable */ +// prettier-ignore +var renderSnippet = function() { + (function(e,t){var n=e.amplitude||{_q:[],_iq:{}};var r=t.createElement("script"); + r.type="text/javascript"; + r.integrity="sha384-QahB0HKETlcqjneomU3Ohs+UgJTinhUNFIKJitEl2Vo7DjvphO2jei64ZP5J2GA5"; + r.crossOrigin="anonymous";r.async=true; + r.src="https://cdn.amplitude.com/libs/amplitude-8.21.8-min.gz.js"; + r.onload=function(){if(!e.amplitude.runQueuedFunctions){console.log( + "[Amplitude] Error: could not load SDK");}};var s=t.getElementsByTagName("script" + )[0];s.parentNode.insertBefore(r,s);function i(e,t){e.prototype[t]=function(){ + this._q.push([t].concat(Array.prototype.slice.call(arguments,0)));return this};} + var o=function(){this._q=[];return this};var a=["add","append","clearAll", + "prepend","set","setOnce","unset","preInsert","postInsert","remove"];for( + var c=0;c -1 + ) { + var revenueAmount = + (expandedEvt.EventAttributes['Total Amount'] || 0) * + (isRefund ? -1 : 1); + var revenue = new window.amplitude.Revenue() + .setPrice(revenueAmount) + .setEventProperties(updatedAttributes); + getInstance().logRevenueV2(revenue); + } else { + getInstance().logEvent( + expandedEvt.EventName, + updatedAttributes + ); + } + }); + + return true; + } + } + + // if it is not a product action, it is an impression or promotion commerce event + if (isNotProductAction(event)) { + expandedEvents.forEach(function(expandedEvt) { + // Exclude Totals from the attributes as we log it in the revenue call + var updatedAttributes = createEcommerceAttributes( + expandedEvt.EventAttributes + ); + + getInstance().logEvent( + expandedEvt.EventName, + updatedAttributes + ); + }); + + return true; + } + + console.warn( + 'Commerce event does not conform to our expectations and was not forwarded to Amplitude. Please double-check your code.' + ); + + return false; + } + + /* + When we process a product action event, Amplitude has a very specific way of + sending events to them: + + 1. Send a summary event with event attributes from the MP event. + a. Add a key of `products` with a value of JSON.stringify(productArray). + b. Add a key of mparticle_amplitude_should_split with a value of `false`. + + 2. Determine if we send product level events or not. + a. If includeIndividualProductEvents === true, send product level events + b. If includeIndividualProductEvents === false, do not send product level events + + 3. Determine if we send an Amplitude revenue event or not. + a. If shouldSendSeparateAmplitudeRevenueEvent === true, send an Amplitude revenue event. + b. If shouldSendSeparateAmplitudeRevenueEvent === true, the summary event attribute should be `revenue`. + c. If shouldSendSeparateAmplitudeRevenueEvent === false, the summary event attribute should be `$revenue` + + See test/AmplitudeCommerceEvent.MD for examples of what the expectations of the payload are. + + */ + function processTemporaryProductAction( + unexpandedCommerceEvent, + expandedEvents + ) { + var summaryEvent, isRefund, isPurchase, isMPRevenueEvent; + + isRefund = + unexpandedCommerceEvent.ProductAction.ProductActionType === + mParticle.ProductActionType.Refund; + isPurchase = + unexpandedCommerceEvent.ProductAction.ProductActionType === + mParticle.ProductActionType.Purchase; + isMPRevenueEvent = isRefund || isPurchase; + + // if the event is a revenue event, then we set it to the expanded `Total` event for backwards compatibility + if ( + isMPRevenueEvent && + expandedEvents[0].EventName.indexOf(TOTAL) > -1 + ) { + summaryEvent = expandedEvents[0]; + sendMPRevenueSummaryEvent( + summaryEvent, + unexpandedCommerceEvent.ProductAction.ProductList, + isRefund, + shouldSendSeparateAmplitudeRevenueEvent + ); + } + + if (!isMPRevenueEvent) { + sendSummaryEvent(unexpandedCommerceEvent); + } + + if (includeIndividualProductEvents) { + sendIndividualProductEvents( + expandedEvents, + isMPRevenueEvent, + shouldSendSeparateAmplitudeRevenueEvent, + isRefund + ); + } + + return true; + } + + // If event.ProductAction does not exist, the commerce event is a promotion or impression event + function isNotProductAction(event) { + return ( + event.EventCategory === + mParticle.CommerceEventType.ProductImpression || + event.EventCategory === mParticle.CommerceEventType.PromotionView || + event.EventCategory === mParticle.CommerceEventType.PromotionClick + ); + } + + // this function does not use Amplitude's logRevenueV2, but rather sends custom event names + function sendMPRevenueSummaryEvent( + summaryEvent, + products, + isRefund, + shouldSendSeparateAmplitudeRevenueEvent + ) { + // send the ecommerce - purchase event + var updatedAttributes = createMPRevenueEcommerceAttributes( + summaryEvent.EventAttributes, + shouldSendSeparateAmplitudeRevenueEvent, + isRefund + ); + updatedAttributes[MP_AMP_SPLIT] = false; + + updatedAttributes[PRODUCTS] = products; + var revenueEventLabel = isRefund ? REFUND : PURCHASE; + getInstance().logEvent( + 'eCommerce - ' + revenueEventLabel, + updatedAttributes + ); + } + + // revenue summary event will either have $price/price or $revenue/revenue depending on if + function createMPRevenueEcommerceAttributes( + attributes, + shouldSendSeparateAmplitudeRevenueEvent, + isRefund + ) { + var updatedAttributes = {}; + for (var key in attributes) { + if (key === TOTAL_AMOUNT) { + // A purchase is a positive amount and a refund is negative + var revenueAmount = attributes[key] * (isRefund ? -1 : 1); + // If we send a separate Amplitude Revenue Event, Amplitude's + // SDK prefixes price/revenue with a $ for calculating things + // like LTV, so we do not want to prepend it as part of the + // summary event to avoid double counting + var revenueKey = shouldSendSeparateAmplitudeRevenueEvent + ? 'revenue' + : '$revenue'; + + updatedAttributes[revenueKey] = revenueAmount; + } else if (key !== TOTAL_AMOUNT) { + updatedAttributes[key] = attributes[key]; + } + } + + return convertJsonAttrs(updatedAttributes); + } + + function createAttrsForAmplitudeRevenueEvent(attributes) { + var updatedAttributes = {}; + for (var key in attributes) { + if (key !== TOTAL_AMOUNT) { + updatedAttributes[key] = attributes[key]; + } + } + + return convertJsonAttrs(updatedAttributes); + } + + function sendSummaryEvent(summaryEvent) { + var updatedAttributes = createEcommerceAttributes( + summaryEvent.EventAttributes + ); + updatedAttributes[MP_AMP_SPLIT] = false; + try { + updatedAttributes[PRODUCTS] = + summaryEvent.ProductAction.ProductList; + } catch (e) { + console.error('error adding Product List to summary event'); + } + + getInstance().logEvent(summaryEvent.EventName, updatedAttributes); + } + + function sendIndividualProductEvents( + expandedEvents, + isMPRevenueEvent, + shouldSendSeparateAmplitudeRevenueEvent, + isRefund + ) { + expandedEvents.forEach(function(expandedEvt) { + var updatedAttributes; + // `Total` exists on an expanded event if it is part of a revenue/purchase event + // but not on other commerce events. This only needs to be fired if shouldSendSeparateAmplitudeRevenueEvent === True + if ( + isMPRevenueEvent && + // A purchase is a positive amount and a refund is negative + (expandedEvt.EventName.indexOf(TOTAL) > -1) & + shouldSendSeparateAmplitudeRevenueEvent + ) { + var revenueAmount = + // A purchase is a positive amount and a refund is negative + (expandedEvt.EventAttributes[TOTAL_AMOUNT] || 0) * + (isRefund ? -1 : 1); + updatedAttributes = createAttrsForAmplitudeRevenueEvent( + expandedEvt.EventAttributes + ); + + var revenue = new window.amplitude.Revenue() + .setPrice(revenueAmount) + .setEventProperties(updatedAttributes); + getInstance().logRevenueV2(revenue); + } else if (expandedEvt.EventName.indexOf(TOTAL) === -1) { + updatedAttributes = createEcommerceAttributes( + expandedEvt.EventAttributes + ); + getInstance().logEvent( + expandedEvt.EventName, + updatedAttributes + ); + } + }); + } + + function convertJsonAttrs(customAttributes) { + if (forwarderSettings.sendEventAttributesAsObjects === 'True') { + for (var key in customAttributes) { + if (typeof customAttributes[key] === 'string') { + try { + var parsed = JSON.parse(customAttributes[key]); + if (typeof parsed === 'object') { + customAttributes[key] = parsed; + } + } catch (e) { + // if parsing fails, don't update the customAttribute object + } + } + } + } + + return customAttributes; + } + + function initForwarder(settings, service, testMode) { + var ampSettings; + + forwarderSettings = settings; + reportingService = service; + + // Changing this setting from a negative action to a positive action for readability + includeIndividualProductEvents = + forwarderSettings.excludeIndividualProductEvents === 'False'; + // Only send separate amplitude revenue events when we includeIndividualProductEvents, + // so create this variable for clarity + shouldSendSeparateAmplitudeRevenueEvent = includeIndividualProductEvents; + + enableTempAmplitudeEcommerce = + forwarderSettings.enableTempAmplitudeEcommerce === 'True'; + try { + if (!window.amplitude) { + if (testMode !== true) { + renderSnippet(); + } + } + + ampSettings = {}; + + // allow the client to set custom amplitude init properties + if ( + typeof window.AmplitudeInitSettings === 'object' && + window.AmplitudeInitSettings !== null + ) { + ampSettings = window.AmplitudeInitSettings; + } + + if (forwarderSettings.saveEvents) { + ampSettings.saveEvents = + forwarderSettings.saveEvents === 'True'; + } + + if (forwarderSettings.savedMaxCount) { + ampSettings.savedMaxCount = parseInt( + forwarderSettings.savedMaxCount, + 10 + ); + } + + if (forwarderSettings.uploadBatchSize) { + ampSettings.uploadBatchSize = parseInt( + forwarderSettings.uploadBatchSize, + 10 + ); + } + + if (forwarderSettings.includeUtm) { + ampSettings.includeUtm = + forwarderSettings.includeUtm === 'True'; + } + + if (forwarderSettings.includeReferrer) { + ampSettings.includeReferrer = + forwarderSettings.includeReferrer === 'True'; + } + + if (forwarderSettings.forceHttps) { + ampSettings.forceHttps = + forwarderSettings.forceHttps === 'True'; + } + + if (forwarderSettings.baseUrl) { + ampSettings.apiEndpoint = forwarderSettings.baseUrl; + } + + isDefaultInstance = + !forwarderSettings.instanceName || + forwarderSettings.instanceName === 'default'; + + getInstance().init(forwarderSettings.apiKey, null, ampSettings); + isInitialized = true; + + if (forwarderSettings.userIdentification === constants.MPID) { + if (window.mParticle && window.mParticle.Identity) { + var user = window.mParticle.Identity.getCurrentUser(); + if (user) { + var userId = user.getMPID(); + getInstance().setUserId(userId); + } + } + } + + return 'Successfully initialized: ' + name; + } catch (e) { + return 'Failed to initialize: ' + name; + } + } + + this.init = initForwarder; + this.process = processEvent; + this.setUserIdentity = setUserIdentity; + this.onUserIdentified = onUserIdentified; + this.setUserAttribute = setUserAttribute; + this.setOptOut = setOptOut; + this.removeUserAttribute = removeUserAttribute; +}; + +function getId() { + return moduleId; +} + +function isObject(val) { + return ( + val != null && typeof val === 'object' && Array.isArray(val) === false + ); +} + +function register(config) { + if (!config) { + console.log( + 'You must pass a config object to register the kit ' + name + ); + return; + } + + if (!isObject(config)) { + console.log( + 'The "config" must be an object. You passed in a ' + typeof config + ); + return; + } + + if (isObject(config.kits)) { + config.kits[name] = { + constructor: constructor, + }; + } else { + config.kits = {}; + config.kits[name] = { + constructor: constructor, + }; + } + console.log( + 'Successfully registered ' + name + ' to your mParticle configuration' + ); +} + +if (typeof window !== 'undefined') { + if (window && window.mParticle && window.mParticle.addForwarder) { + window.mParticle.addForwarder({ + name: name, + constructor: constructor, + getId: getId, + }); + } +} + +var Amplitude = { + register: register, +}; +var Amplitude_1 = Amplitude.register; + +export { Amplitude as default, Amplitude_1 as register }; diff --git a/kits/amplitude/amplitude-8/dist/Amplitude.iife.js b/kits/amplitude/amplitude-8/dist/Amplitude.iife.js new file mode 100644 index 000000000..9713de92b --- /dev/null +++ b/kits/amplitude/amplitude-8/dist/Amplitude.iife.js @@ -0,0 +1,799 @@ +var mpAmplitudeKit = (function (exports) { + + /* eslint-disable no-undef*/ + // + // Copyright 2015 mParticle, Inc. + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + + var name = 'Amplitude', + moduleId = 53, + MessageType = { + SessionStart: 1, + SessionEnd: 2, + PageView: 3, + PageEvent: 4, + CrashReport: 5, + OptOut: 6, + Commerce: 16, + }; + + var constants = { + MPID: 'mpId', + customerId: 'customerId', + email: 'email', + other: 'other', + other2: 'other2', + other3: 'other3', + other4: 'other4', + other5: 'other5', + other6: 'other6', + other7: 'other7', + other8: 'other8', + other9: 'other9', + other10: 'other10', + }; + + var MP_AMP_SPLIT = 'mparticle_amplitude_should_split', + TOTAL_AMOUNT = 'Total Amount', + TOTAL = 'Total', + PRODUCTS = 'products', + REFUND = 'Refund', + PURCHASE = 'Purchase', + TOTAL_PRODUCT_AMOUNT = 'Total Product Amount'; + + var includeIndividualProductEvents, + shouldSendSeparateAmplitudeRevenueEvent, + enableTempAmplitudeEcommerce; + + /* eslint-disable */ + // prettier-ignore + var renderSnippet = function() { + (function(e,t){var n=e.amplitude||{_q:[],_iq:{}};var r=t.createElement("script"); + r.type="text/javascript"; + r.integrity="sha384-QahB0HKETlcqjneomU3Ohs+UgJTinhUNFIKJitEl2Vo7DjvphO2jei64ZP5J2GA5"; + r.crossOrigin="anonymous";r.async=true; + r.src="https://cdn.amplitude.com/libs/amplitude-8.21.8-min.gz.js"; + r.onload=function(){if(!e.amplitude.runQueuedFunctions){console.log( + "[Amplitude] Error: could not load SDK");}};var s=t.getElementsByTagName("script" + )[0];s.parentNode.insertBefore(r,s);function i(e,t){e.prototype[t]=function(){ + this._q.push([t].concat(Array.prototype.slice.call(arguments,0)));return this};} + var o=function(){this._q=[];return this};var a=["add","append","clearAll", + "prepend","set","setOnce","unset","preInsert","postInsert","remove"];for( + var c=0;c -1 + ) { + var revenueAmount = + (expandedEvt.EventAttributes['Total Amount'] || 0) * + (isRefund ? -1 : 1); + var revenue = new window.amplitude.Revenue() + .setPrice(revenueAmount) + .setEventProperties(updatedAttributes); + getInstance().logRevenueV2(revenue); + } else { + getInstance().logEvent( + expandedEvt.EventName, + updatedAttributes + ); + } + }); + + return true; + } + } + + // if it is not a product action, it is an impression or promotion commerce event + if (isNotProductAction(event)) { + expandedEvents.forEach(function(expandedEvt) { + // Exclude Totals from the attributes as we log it in the revenue call + var updatedAttributes = createEcommerceAttributes( + expandedEvt.EventAttributes + ); + + getInstance().logEvent( + expandedEvt.EventName, + updatedAttributes + ); + }); + + return true; + } + + console.warn( + 'Commerce event does not conform to our expectations and was not forwarded to Amplitude. Please double-check your code.' + ); + + return false; + } + + /* + When we process a product action event, Amplitude has a very specific way of + sending events to them: + + 1. Send a summary event with event attributes from the MP event. + a. Add a key of `products` with a value of JSON.stringify(productArray). + b. Add a key of mparticle_amplitude_should_split with a value of `false`. + + 2. Determine if we send product level events or not. + a. If includeIndividualProductEvents === true, send product level events + b. If includeIndividualProductEvents === false, do not send product level events + + 3. Determine if we send an Amplitude revenue event or not. + a. If shouldSendSeparateAmplitudeRevenueEvent === true, send an Amplitude revenue event. + b. If shouldSendSeparateAmplitudeRevenueEvent === true, the summary event attribute should be `revenue`. + c. If shouldSendSeparateAmplitudeRevenueEvent === false, the summary event attribute should be `$revenue` + + See test/AmplitudeCommerceEvent.MD for examples of what the expectations of the payload are. + + */ + function processTemporaryProductAction( + unexpandedCommerceEvent, + expandedEvents + ) { + var summaryEvent, isRefund, isPurchase, isMPRevenueEvent; + + isRefund = + unexpandedCommerceEvent.ProductAction.ProductActionType === + mParticle.ProductActionType.Refund; + isPurchase = + unexpandedCommerceEvent.ProductAction.ProductActionType === + mParticle.ProductActionType.Purchase; + isMPRevenueEvent = isRefund || isPurchase; + + // if the event is a revenue event, then we set it to the expanded `Total` event for backwards compatibility + if ( + isMPRevenueEvent && + expandedEvents[0].EventName.indexOf(TOTAL) > -1 + ) { + summaryEvent = expandedEvents[0]; + sendMPRevenueSummaryEvent( + summaryEvent, + unexpandedCommerceEvent.ProductAction.ProductList, + isRefund, + shouldSendSeparateAmplitudeRevenueEvent + ); + } + + if (!isMPRevenueEvent) { + sendSummaryEvent(unexpandedCommerceEvent); + } + + if (includeIndividualProductEvents) { + sendIndividualProductEvents( + expandedEvents, + isMPRevenueEvent, + shouldSendSeparateAmplitudeRevenueEvent, + isRefund + ); + } + + return true; + } + + // If event.ProductAction does not exist, the commerce event is a promotion or impression event + function isNotProductAction(event) { + return ( + event.EventCategory === + mParticle.CommerceEventType.ProductImpression || + event.EventCategory === mParticle.CommerceEventType.PromotionView || + event.EventCategory === mParticle.CommerceEventType.PromotionClick + ); + } + + // this function does not use Amplitude's logRevenueV2, but rather sends custom event names + function sendMPRevenueSummaryEvent( + summaryEvent, + products, + isRefund, + shouldSendSeparateAmplitudeRevenueEvent + ) { + // send the ecommerce - purchase event + var updatedAttributes = createMPRevenueEcommerceAttributes( + summaryEvent.EventAttributes, + shouldSendSeparateAmplitudeRevenueEvent, + isRefund + ); + updatedAttributes[MP_AMP_SPLIT] = false; + + updatedAttributes[PRODUCTS] = products; + var revenueEventLabel = isRefund ? REFUND : PURCHASE; + getInstance().logEvent( + 'eCommerce - ' + revenueEventLabel, + updatedAttributes + ); + } + + // revenue summary event will either have $price/price or $revenue/revenue depending on if + function createMPRevenueEcommerceAttributes( + attributes, + shouldSendSeparateAmplitudeRevenueEvent, + isRefund + ) { + var updatedAttributes = {}; + for (var key in attributes) { + if (key === TOTAL_AMOUNT) { + // A purchase is a positive amount and a refund is negative + var revenueAmount = attributes[key] * (isRefund ? -1 : 1); + // If we send a separate Amplitude Revenue Event, Amplitude's + // SDK prefixes price/revenue with a $ for calculating things + // like LTV, so we do not want to prepend it as part of the + // summary event to avoid double counting + var revenueKey = shouldSendSeparateAmplitudeRevenueEvent + ? 'revenue' + : '$revenue'; + + updatedAttributes[revenueKey] = revenueAmount; + } else if (key !== TOTAL_AMOUNT) { + updatedAttributes[key] = attributes[key]; + } + } + + return convertJsonAttrs(updatedAttributes); + } + + function createAttrsForAmplitudeRevenueEvent(attributes) { + var updatedAttributes = {}; + for (var key in attributes) { + if (key !== TOTAL_AMOUNT) { + updatedAttributes[key] = attributes[key]; + } + } + + return convertJsonAttrs(updatedAttributes); + } + + function sendSummaryEvent(summaryEvent) { + var updatedAttributes = createEcommerceAttributes( + summaryEvent.EventAttributes + ); + updatedAttributes[MP_AMP_SPLIT] = false; + try { + updatedAttributes[PRODUCTS] = + summaryEvent.ProductAction.ProductList; + } catch (e) { + console.error('error adding Product List to summary event'); + } + + getInstance().logEvent(summaryEvent.EventName, updatedAttributes); + } + + function sendIndividualProductEvents( + expandedEvents, + isMPRevenueEvent, + shouldSendSeparateAmplitudeRevenueEvent, + isRefund + ) { + expandedEvents.forEach(function(expandedEvt) { + var updatedAttributes; + // `Total` exists on an expanded event if it is part of a revenue/purchase event + // but not on other commerce events. This only needs to be fired if shouldSendSeparateAmplitudeRevenueEvent === True + if ( + isMPRevenueEvent && + // A purchase is a positive amount and a refund is negative + (expandedEvt.EventName.indexOf(TOTAL) > -1) & + shouldSendSeparateAmplitudeRevenueEvent + ) { + var revenueAmount = + // A purchase is a positive amount and a refund is negative + (expandedEvt.EventAttributes[TOTAL_AMOUNT] || 0) * + (isRefund ? -1 : 1); + updatedAttributes = createAttrsForAmplitudeRevenueEvent( + expandedEvt.EventAttributes + ); + + var revenue = new window.amplitude.Revenue() + .setPrice(revenueAmount) + .setEventProperties(updatedAttributes); + getInstance().logRevenueV2(revenue); + } else if (expandedEvt.EventName.indexOf(TOTAL) === -1) { + updatedAttributes = createEcommerceAttributes( + expandedEvt.EventAttributes + ); + getInstance().logEvent( + expandedEvt.EventName, + updatedAttributes + ); + } + }); + } + + function convertJsonAttrs(customAttributes) { + if (forwarderSettings.sendEventAttributesAsObjects === 'True') { + for (var key in customAttributes) { + if (typeof customAttributes[key] === 'string') { + try { + var parsed = JSON.parse(customAttributes[key]); + if (typeof parsed === 'object') { + customAttributes[key] = parsed; + } + } catch (e) { + // if parsing fails, don't update the customAttribute object + } + } + } + } + + return customAttributes; + } + + function initForwarder(settings, service, testMode) { + var ampSettings; + + forwarderSettings = settings; + reportingService = service; + + // Changing this setting from a negative action to a positive action for readability + includeIndividualProductEvents = + forwarderSettings.excludeIndividualProductEvents === 'False'; + // Only send separate amplitude revenue events when we includeIndividualProductEvents, + // so create this variable for clarity + shouldSendSeparateAmplitudeRevenueEvent = includeIndividualProductEvents; + + enableTempAmplitudeEcommerce = + forwarderSettings.enableTempAmplitudeEcommerce === 'True'; + try { + if (!window.amplitude) { + if (testMode !== true) { + renderSnippet(); + } + } + + ampSettings = {}; + + // allow the client to set custom amplitude init properties + if ( + typeof window.AmplitudeInitSettings === 'object' && + window.AmplitudeInitSettings !== null + ) { + ampSettings = window.AmplitudeInitSettings; + } + + if (forwarderSettings.saveEvents) { + ampSettings.saveEvents = + forwarderSettings.saveEvents === 'True'; + } + + if (forwarderSettings.savedMaxCount) { + ampSettings.savedMaxCount = parseInt( + forwarderSettings.savedMaxCount, + 10 + ); + } + + if (forwarderSettings.uploadBatchSize) { + ampSettings.uploadBatchSize = parseInt( + forwarderSettings.uploadBatchSize, + 10 + ); + } + + if (forwarderSettings.includeUtm) { + ampSettings.includeUtm = + forwarderSettings.includeUtm === 'True'; + } + + if (forwarderSettings.includeReferrer) { + ampSettings.includeReferrer = + forwarderSettings.includeReferrer === 'True'; + } + + if (forwarderSettings.forceHttps) { + ampSettings.forceHttps = + forwarderSettings.forceHttps === 'True'; + } + + if (forwarderSettings.baseUrl) { + ampSettings.apiEndpoint = forwarderSettings.baseUrl; + } + + isDefaultInstance = + !forwarderSettings.instanceName || + forwarderSettings.instanceName === 'default'; + + getInstance().init(forwarderSettings.apiKey, null, ampSettings); + isInitialized = true; + + if (forwarderSettings.userIdentification === constants.MPID) { + if (window.mParticle && window.mParticle.Identity) { + var user = window.mParticle.Identity.getCurrentUser(); + if (user) { + var userId = user.getMPID(); + getInstance().setUserId(userId); + } + } + } + + return 'Successfully initialized: ' + name; + } catch (e) { + return 'Failed to initialize: ' + name; + } + } + + this.init = initForwarder; + this.process = processEvent; + this.setUserIdentity = setUserIdentity; + this.onUserIdentified = onUserIdentified; + this.setUserAttribute = setUserAttribute; + this.setOptOut = setOptOut; + this.removeUserAttribute = removeUserAttribute; + }; + + function getId() { + return moduleId; + } + + function isObject(val) { + return ( + val != null && typeof val === 'object' && Array.isArray(val) === false + ); + } + + function register(config) { + if (!config) { + console.log( + 'You must pass a config object to register the kit ' + name + ); + return; + } + + if (!isObject(config)) { + console.log( + 'The "config" must be an object. You passed in a ' + typeof config + ); + return; + } + + if (isObject(config.kits)) { + config.kits[name] = { + constructor: constructor, + }; + } else { + config.kits = {}; + config.kits[name] = { + constructor: constructor, + }; + } + console.log( + 'Successfully registered ' + name + ' to your mParticle configuration' + ); + } + + if (typeof window !== 'undefined') { + if (window && window.mParticle && window.mParticle.addForwarder) { + window.mParticle.addForwarder({ + name: name, + constructor: constructor, + getId: getId, + }); + } + } + + var Amplitude = { + register: register, + }; + var Amplitude_1 = Amplitude.register; + + exports["default"] = Amplitude; + exports.register = Amplitude_1; + + Object.defineProperty(exports, '__esModule', { value: true }); + + return exports; + +})({}); diff --git a/kits/bingads/dist/BingAdsEventForwarder.common.js b/kits/bingads/dist/BingAdsEventForwarder.common.js new file mode 100644 index 000000000..6d63733d7 --- /dev/null +++ b/kits/bingads/dist/BingAdsEventForwarder.common.js @@ -0,0 +1,413 @@ +Object.defineProperty(exports, '__esModule', { value: true }); + +/*! + * isobject + * + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. + */ + +function isObject(val) { + return val != null && typeof val === 'object' && Array.isArray(val) === false; +} + +var isobject = /*#__PURE__*/Object.freeze({ + 'default': isObject +}); + +function getCjsExportFromNamespace (n) { + return n && n['default'] || n; +} + +var isobject$1 = getCjsExportFromNamespace(isobject); + +// Copyright 2016 mParticle, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + + +var name = 'Bing'; +var moduleId = 107; +var MessageType = { + SessionStart: 1, + SessionEnd: 2, + PageView: 3, + PageEvent: 4, + CrashReport: 5, + OptOut: 6, + Profile: 14, + Commerce: 16, +}; + +var bingConsentValues = { Denied: 'denied', Granted: 'granted' }; +var bingConsentProperties = ['ad_storage']; +var bingToMpConsentSettingsMapping = { + ad_storage: 'defaultAdStorageConsentWeb', +}; + +var constructor = function() { + var self = this; + var isInitialized = false; + var forwarderSettings = null; + var reportingService = null; + + self.consentMappings = []; + self.consentPayloadAsString = ''; + self.consentPayloadDefaults = {}; + + self.name = name; + + function initForwarder(settings, service, testMode) { + forwarderSettings = settings; + reportingService = service; + + if (forwarderSettings.consentMappingWeb) { + self.consentMappings = parseSettingsString( + forwarderSettings.consentMappingWeb + ); + } + self.consentPayloadDefaults = getConsentSettings(forwarderSettings); + + var initialConsentPayload = cloneObject(self.consentPayloadDefaults); + var userConsentState = getUserConsentState(); + + var updatedConsentPayload = generateConsentPayload( + userConsentState, + self.consentMappings + ); + + try { + if (!testMode) { + (function(window, document, tag, url, queue) { + var f; + var n; + var i; + (window[queue] = window[queue] || []), + (window.uetq = window.uetq || []), + sendConsentDefaultToBing(initialConsentPayload), + (f = function() { + var obj = { + ti: forwarderSettings.tagId, + q: window.uetq, + }; + (obj.q = window[queue]), + (window[queue] = new UET(obj)), + maybeSendConsentUpdateToBing( + updatedConsentPayload + ); + window[queue].push('pageLoad'); + }), + (n = document.createElement(tag)), + (n.src = url), + (n.async = 1), + (n.onload = n.onreadystatechange = function() { + var state = this.readyState; + (state && + state !== 'loaded' && + state !== 'complete') || + (f(), (n.onload = n.onreadystatechange = null)); + }), + (i = document.getElementsByTagName(tag)[0]), + i.parentNode.insertBefore(n, i); + })(window, document, 'script', '//bat.bing.com/bat.js', 'uetq'); + + if (window.uetq && window.queue && window.queue.length > 0) { + for ( + var i = 0, length = window.queue.length; + i < length; + i++ + ) { + processEvent(window.queue[i]); + } + + window.queue.length = 0; + } + } + + isInitialized = true; + return 'Successfully initialized: ' + name; + } catch (e) { + return "Can't initialize forwarder: " + name + ': ' + e; + } + } + + function processEvent(event) { + if (!isInitialized) { + return "Can't send to forwarder: " + name + ', not initialized'; + } + + var reportEvent = false; + try { + if ( + event.EventDataType == MessageType.PageEvent || + event.EventDataType == MessageType.PageView + ) { + reportEvent = true; + logEvent(event); + } else if ( + event.EventDataType == MessageType.Commerce && + event.ProductAction && + event.ProductAction.ProductActionType == + mParticle.ProductActionType.Purchase + ) { + reportEvent = true; + logPurchaseEvent(event); + } + + if (reportEvent && reportingService) { + reportingService(self, event); + return 'Successfully sent to forwarder: ' + name; + } + } catch (e) { + return "Can't send to forwarder: " + name + ' ' + e; + } + } + + function logEvent(event) { + if (!isInitialized) { + return ( + "Can't log event on forwarder: " + name + ', not initialized' + ); + } + try { + var obj = createUetObject(event, 'pageLoad'); + + var eventConsentState = getEventConsentState(event.ConsentState); + + maybeSendConsentUpdateToBing(eventConsentState); + + window.uetq.push(obj); + } catch (e) { + return "Can't log event on forwarder: " + name + ': ' + e; + } + + return 'Successfully logged event from forwarder: ' + name; + } + + function logPurchaseEvent(event) { + if (!isInitialized) { + return ( + "Can't log purchase event on forwarder: " + + name + + ', not initialized' + ); + } + + if ( + event.ProductAction.TotalAmount === undefined || + event.ProductAction.TotalAmount === null + ) { + return "Can't log purchase event without a total amount on product action"; + } + + try { + var obj = createUetObject(event, 'eCommerce'); + obj.gv = event.ProductAction.TotalAmount; + + window.uetq.push(obj); + } catch (e) { + return "Can't log commerce event on forwarder: " + name + ': ' + e; + } + } + + function createUetObject(event, action) { + var obj = { + ea: action, + ec: window.mParticle.EventType.getName(event.EventCategory), + el: event.EventName, + }; + + if (event.CustomFlags && event.CustomFlags['Bing.EventValue']) { + obj.ev = event.CustomFlags['Bing.EventValue']; + } + + return obj; + } + + function getEventConsentState(eventConsentState) { + return eventConsentState && eventConsentState.getGDPRConsentState + ? eventConsentState.getGDPRConsentState() + : {}; + } + + function generateConsentPayload(consentState, mappings) { + if (!mappings) { + return {}; + } + + var payload = cloneObject(self.consentPayloadDefaults); + if (mappings && mappings.length > 0) { + for (var i = 0; i < mappings.length; i++) { + var mappingEntry = mappings[i]; + var mpMappedConsentName = mappingEntry.map.toLowerCase(); + var bingMappedConsentName = mappingEntry.value; + + if ( + consentState[mpMappedConsentName] && + bingConsentProperties.indexOf(bingMappedConsentName) !== -1 + ) { + payload[bingMappedConsentName] = consentState[ + mpMappedConsentName + ].Consented + ? bingConsentValues.Granted + : bingConsentValues.Denied; + } + } + } + + return payload; + } + + function maybeSendConsentUpdateToBing(consentState) { + if ( + self.consentPayloadAsString && + self.consentMappings && + !isEmpty(consentState) + ) { + var updatedConsentPayload = generateConsentPayload( + consentState, + self.consentMappings + ); + + var eventConsentAsString = JSON.stringify(updatedConsentPayload); + + if (eventConsentAsString !== self.consentPayloadAsString) { + window.uetq.push('consent', 'update', updatedConsentPayload); + self.consentPayloadAsString = JSON.stringify( + updatedConsentPayload + ); + } + } + } + + function sendConsentDefaultToBing(consentPayload) { + self.consentPayloadAsString = JSON.stringify(consentPayload); + + window.uetq.push('consent', 'default', consentPayload); + } + + this.init = initForwarder; + this.process = processEvent; +}; + +function getUserConsentState() { + var userConsentState = {}; + + if (mParticle.Identity && mParticle.Identity.getCurrentUser) { + var currentUser = mParticle.Identity.getCurrentUser(); + + if (!currentUser) { + return {}; + } + + var consentState = mParticle.Identity.getCurrentUser().getConsentState(); + + if (consentState && consentState.getGDPRConsentState) { + userConsentState = consentState.getGDPRConsentState(); + } + } + + return userConsentState; +} + +function getConsentSettings(settings) { + var consentSettings = {}; + + Object.keys(bingToMpConsentSettingsMapping).forEach(function( + bingConsentKey + ) { + var mpConsentSettingKey = + bingToMpConsentSettingsMapping[bingConsentKey]; + var bingConsentValuesKey = settings[mpConsentSettingKey]; + + // Microsoft recommends that for most countries, we should default to 'Granted' + // if a default value is not provided + // https://help.ads.microsoft.com/apex/index/3/en/60119 + if (bingConsentValuesKey && mpConsentSettingKey) { + consentSettings[bingConsentKey] = bingConsentValues[ + bingConsentValuesKey + ] + ? bingConsentValues[bingConsentValuesKey] + : bingConsentValues.Granted; + } else { + consentSettings[bingConsentKey] = bingConsentValues.Granted; + } + }); + + return consentSettings; +} + +function parseSettingsString(settingsString) { + return JSON.parse(settingsString.replace(/"/g, '"')); +} + +function getId() { + return moduleId; +} + +function register(config) { + if (!config) { + console.log( + 'You must pass a config object to register the kit ' + name + ); + return; + } + + if (!isobject$1(config)) { + console.log( + "'config' must be an object. You passed in a " + typeof config + ); + return; + } + + if (isobject$1(config.kits)) { + config.kits[name] = { + constructor: constructor, + }; + } else { + config.kits = {}; + config.kits[name] = { + constructor: constructor, + }; + } + console.log( + 'Successfully registered ' + name + ' to your mParticle configuration' + ); +} + +if (typeof window !== 'undefined') { + if (window && window.mParticle && window.mParticle.addForwarder) { + window.mParticle.addForwarder({ + name: name, + constructor: constructor, + getId: getId, + }); + } +} + +function isEmpty(value) { + return value == null || !(Object.keys(value) || value).length; +} + +function cloneObject(obj) { + return JSON.parse(JSON.stringify(obj)); +} + +var BingAdsEventForwarder = { + register: register, +}; +var BingAdsEventForwarder_1 = BingAdsEventForwarder.register; + +exports.default = BingAdsEventForwarder; +exports.register = BingAdsEventForwarder_1; diff --git a/kits/bingads/dist/BingAdsEventForwarder.iife.js b/kits/bingads/dist/BingAdsEventForwarder.iife.js new file mode 100644 index 000000000..1c821d88b --- /dev/null +++ b/kits/bingads/dist/BingAdsEventForwarder.iife.js @@ -0,0 +1,406 @@ +var mpBingAdsKit = (function (exports) { + /*! + * isobject + * + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. + */ + + function isObject(val) { + return val != null && typeof val === 'object' && Array.isArray(val) === false; + } + + // Copyright 2016 mParticle, Inc. + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + + + + var name = 'Bing'; + var moduleId = 107; + var MessageType = { + SessionStart: 1, + SessionEnd: 2, + PageView: 3, + PageEvent: 4, + CrashReport: 5, + OptOut: 6, + Profile: 14, + Commerce: 16, + }; + + var bingConsentValues = { Denied: 'denied', Granted: 'granted' }; + var bingConsentProperties = ['ad_storage']; + var bingToMpConsentSettingsMapping = { + ad_storage: 'defaultAdStorageConsentWeb', + }; + + var constructor = function() { + var self = this; + var isInitialized = false; + var forwarderSettings = null; + var reportingService = null; + + self.consentMappings = []; + self.consentPayloadAsString = ''; + self.consentPayloadDefaults = {}; + + self.name = name; + + function initForwarder(settings, service, testMode) { + forwarderSettings = settings; + reportingService = service; + + if (forwarderSettings.consentMappingWeb) { + self.consentMappings = parseSettingsString( + forwarderSettings.consentMappingWeb + ); + } + self.consentPayloadDefaults = getConsentSettings(forwarderSettings); + + var initialConsentPayload = cloneObject(self.consentPayloadDefaults); + var userConsentState = getUserConsentState(); + + var updatedConsentPayload = generateConsentPayload( + userConsentState, + self.consentMappings + ); + + try { + if (!testMode) { + (function(window, document, tag, url, queue) { + var f; + var n; + var i; + (window[queue] = window[queue] || []), + (window.uetq = window.uetq || []), + sendConsentDefaultToBing(initialConsentPayload), + (f = function() { + var obj = { + ti: forwarderSettings.tagId, + q: window.uetq, + }; + (obj.q = window[queue]), + (window[queue] = new UET(obj)), + maybeSendConsentUpdateToBing( + updatedConsentPayload + ); + window[queue].push('pageLoad'); + }), + (n = document.createElement(tag)), + (n.src = url), + (n.async = 1), + (n.onload = n.onreadystatechange = function() { + var state = this.readyState; + (state && + state !== 'loaded' && + state !== 'complete') || + (f(), (n.onload = n.onreadystatechange = null)); + }), + (i = document.getElementsByTagName(tag)[0]), + i.parentNode.insertBefore(n, i); + })(window, document, 'script', '//bat.bing.com/bat.js', 'uetq'); + + if (window.uetq && window.queue && window.queue.length > 0) { + for ( + var i = 0, length = window.queue.length; + i < length; + i++ + ) { + processEvent(window.queue[i]); + } + + window.queue.length = 0; + } + } + + isInitialized = true; + return 'Successfully initialized: ' + name; + } catch (e) { + return "Can't initialize forwarder: " + name + ': ' + e; + } + } + + function processEvent(event) { + if (!isInitialized) { + return "Can't send to forwarder: " + name + ', not initialized'; + } + + var reportEvent = false; + try { + if ( + event.EventDataType == MessageType.PageEvent || + event.EventDataType == MessageType.PageView + ) { + reportEvent = true; + logEvent(event); + } else if ( + event.EventDataType == MessageType.Commerce && + event.ProductAction && + event.ProductAction.ProductActionType == + mParticle.ProductActionType.Purchase + ) { + reportEvent = true; + logPurchaseEvent(event); + } + + if (reportEvent && reportingService) { + reportingService(self, event); + return 'Successfully sent to forwarder: ' + name; + } + } catch (e) { + return "Can't send to forwarder: " + name + ' ' + e; + } + } + + function logEvent(event) { + if (!isInitialized) { + return ( + "Can't log event on forwarder: " + name + ', not initialized' + ); + } + try { + var obj = createUetObject(event, 'pageLoad'); + + var eventConsentState = getEventConsentState(event.ConsentState); + + maybeSendConsentUpdateToBing(eventConsentState); + + window.uetq.push(obj); + } catch (e) { + return "Can't log event on forwarder: " + name + ': ' + e; + } + + return 'Successfully logged event from forwarder: ' + name; + } + + function logPurchaseEvent(event) { + if (!isInitialized) { + return ( + "Can't log purchase event on forwarder: " + + name + + ', not initialized' + ); + } + + if ( + event.ProductAction.TotalAmount === undefined || + event.ProductAction.TotalAmount === null + ) { + return "Can't log purchase event without a total amount on product action"; + } + + try { + var obj = createUetObject(event, 'eCommerce'); + obj.gv = event.ProductAction.TotalAmount; + + window.uetq.push(obj); + } catch (e) { + return "Can't log commerce event on forwarder: " + name + ': ' + e; + } + } + + function createUetObject(event, action) { + var obj = { + ea: action, + ec: window.mParticle.EventType.getName(event.EventCategory), + el: event.EventName, + }; + + if (event.CustomFlags && event.CustomFlags['Bing.EventValue']) { + obj.ev = event.CustomFlags['Bing.EventValue']; + } + + return obj; + } + + function getEventConsentState(eventConsentState) { + return eventConsentState && eventConsentState.getGDPRConsentState + ? eventConsentState.getGDPRConsentState() + : {}; + } + + function generateConsentPayload(consentState, mappings) { + if (!mappings) { + return {}; + } + + var payload = cloneObject(self.consentPayloadDefaults); + if (mappings && mappings.length > 0) { + for (var i = 0; i < mappings.length; i++) { + var mappingEntry = mappings[i]; + var mpMappedConsentName = mappingEntry.map.toLowerCase(); + var bingMappedConsentName = mappingEntry.value; + + if ( + consentState[mpMappedConsentName] && + bingConsentProperties.indexOf(bingMappedConsentName) !== -1 + ) { + payload[bingMappedConsentName] = consentState[ + mpMappedConsentName + ].Consented + ? bingConsentValues.Granted + : bingConsentValues.Denied; + } + } + } + + return payload; + } + + function maybeSendConsentUpdateToBing(consentState) { + if ( + self.consentPayloadAsString && + self.consentMappings && + !isEmpty(consentState) + ) { + var updatedConsentPayload = generateConsentPayload( + consentState, + self.consentMappings + ); + + var eventConsentAsString = JSON.stringify(updatedConsentPayload); + + if (eventConsentAsString !== self.consentPayloadAsString) { + window.uetq.push('consent', 'update', updatedConsentPayload); + self.consentPayloadAsString = JSON.stringify( + updatedConsentPayload + ); + } + } + } + + function sendConsentDefaultToBing(consentPayload) { + self.consentPayloadAsString = JSON.stringify(consentPayload); + + window.uetq.push('consent', 'default', consentPayload); + } + + this.init = initForwarder; + this.process = processEvent; + }; + + function getUserConsentState() { + var userConsentState = {}; + + if (mParticle.Identity && mParticle.Identity.getCurrentUser) { + var currentUser = mParticle.Identity.getCurrentUser(); + + if (!currentUser) { + return {}; + } + + var consentState = mParticle.Identity.getCurrentUser().getConsentState(); + + if (consentState && consentState.getGDPRConsentState) { + userConsentState = consentState.getGDPRConsentState(); + } + } + + return userConsentState; + } + + function getConsentSettings(settings) { + var consentSettings = {}; + + Object.keys(bingToMpConsentSettingsMapping).forEach(function( + bingConsentKey + ) { + var mpConsentSettingKey = + bingToMpConsentSettingsMapping[bingConsentKey]; + var bingConsentValuesKey = settings[mpConsentSettingKey]; + + // Microsoft recommends that for most countries, we should default to 'Granted' + // if a default value is not provided + // https://help.ads.microsoft.com/apex/index/3/en/60119 + if (bingConsentValuesKey && mpConsentSettingKey) { + consentSettings[bingConsentKey] = bingConsentValues[ + bingConsentValuesKey + ] + ? bingConsentValues[bingConsentValuesKey] + : bingConsentValues.Granted; + } else { + consentSettings[bingConsentKey] = bingConsentValues.Granted; + } + }); + + return consentSettings; + } + + function parseSettingsString(settingsString) { + return JSON.parse(settingsString.replace(/"/g, '"')); + } + + function getId() { + return moduleId; + } + + function register(config) { + if (!config) { + console.log( + 'You must pass a config object to register the kit ' + name + ); + return; + } + + if (!isObject(config)) { + console.log( + "'config' must be an object. You passed in a " + typeof config + ); + return; + } + + if (isObject(config.kits)) { + config.kits[name] = { + constructor: constructor, + }; + } else { + config.kits = {}; + config.kits[name] = { + constructor: constructor, + }; + } + console.log( + 'Successfully registered ' + name + ' to your mParticle configuration' + ); + } + + if (typeof window !== 'undefined') { + if (window && window.mParticle && window.mParticle.addForwarder) { + window.mParticle.addForwarder({ + name: name, + constructor: constructor, + getId: getId, + }); + } + } + + function isEmpty(value) { + return value == null || !(Object.keys(value) || value).length; + } + + function cloneObject(obj) { + return JSON.parse(JSON.stringify(obj)); + } + + var BingAdsEventForwarder = { + register: register, + }; + var BingAdsEventForwarder_1 = BingAdsEventForwarder.register; + + exports.default = BingAdsEventForwarder; + exports.register = BingAdsEventForwarder_1; + + return exports; + +}({})); diff --git a/kits/braze/braze-3/dist/BrazeKit.common.js b/kits/braze/braze-3/dist/BrazeKit.common.js new file mode 100644 index 000000000..451974183 --- /dev/null +++ b/kits/braze/braze-3/dist/BrazeKit.common.js @@ -0,0 +1,1248 @@ +Object.defineProperty(exports, '__esModule', { value: true }); + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; +} + +var appboy_min = createCommonjsModule(function (module) { +/* +* Braze Web SDK v3.5.0 +* (c) Braze, Inc. 2022 - http://braze.com +* License available at https://github.com/Appboy/appboy-web-sdk/blob/master/LICENSE +* Compiled on 2022-02-02 +*/ +(function(){(function(b,a){if(module.exports){var e = a();module.exports=e;module.exports.default=e;}else if(b.appboy){var d=a(),c;for(c in d)b.appboy[c]=d[c];}else b.appboy=a();})("undefined"!==typeof self?self:this,function(){var appboyInterface={};var p;function aa(a){var b=0;return function(){return bb||1342177279>>=1)c+=c;return d}}); +ha("Promise",function(a){function b(g){this.Ub=0;this.Rd=void 0;this.sb=[];var h=this.Ad();try{g(h.resolve,h.reject);}catch(l){h.reject(l);}}function c(){this.Ha=null;}function d(g){return g instanceof b?g:new b(function(h){h(g);})}if(a)return a;c.prototype.Te=function(g){if(null==this.Ha){this.Ha=[];var h=this;this.Ue(function(){h.eh();});}this.Ha.push(g);};var e=fa.setTimeout;c.prototype.Ue=function(g){e(g,0);};c.prototype.eh=function(){for(;this.Ha&&this.Ha.length;){var g=this.Ha;this.Ha=[];for(var h= +0;h=d?b++:2047=d&&(b+=2);56320<=d&&57343>=d&&c--;}return b}function Qa(a,b,c,d){(d="string"===typeof a||null===a&&d)||x.error("Cannot "+b+" because "+c+' "'+a+'" is invalid.');return d}function Ra(a,b,c){var d=null!=a&&"string"===typeof a&&(""===a||a.match(Sa));d||x.error("Cannot "+b+" because "+c+' "'+a+'" is invalid.');return d} +function Ta(a,b,c,d,e){null==a&&(a={});if("object"!==typeof a||Ca(a))return x.error(b+" requires that "+c+" be an object. Ignoring "+e+"."),[!1,null];b=JSON.stringify(a);if(Pa(b)>Ua)return x.error("Could not "+d+" because "+c+" was greater than the max size of "+Va+"."),[!1,null];try{var f=JSON.parse(b);}catch(k){return x.error("Could not "+d+" because "+c+" did not contain valid JSON."),[!1,null]}for(var g in a){if(!Ra(g,d,"the "+e+" property name"))return [!1,null];c=a[g];if(null==c)delete a[g],delete f[g]; +else{Da(c)&&(f[g]=Ka(c));var h=d,l="the "+e+' property "'+g+'"';(b=Ea(c)||Ca(c)?Wa(c,f[g]):Ya(c))||x.error("Cannot "+h+" because "+l+' "'+c+'" is invalid.');if(!b)return [!1,null]}}return [!0,f]}function Wa(a,b){if(Ca(a)&&Ca(b))for(var c=0;c=a.length)return x.error("addAlias requires a non-empty alias"),!1;if(!Qa(b,"add alias","the label",!1)||0>=b.length)return x.error("addAlias requires a non-empty label"),!1;var c=this.H,d=new $a,e=ab(c.D),f=z.Df;d.j.push(new E(c.f.o(),f,(new Date).valueOf(),e,{a:a,l:b}));d.h=bb(c.b,d.j);return d.h};p.Eh=function(a){return Qa(a,"set first name","the firstName",!0)?cb(this.f,"first_name",a):!1}; +p.Ih=function(a){return Qa(a,"set last name","the lastName",!0)?cb(this.f,"last_name",a):!1};p.Ch=function(a){return null===a||"string"===typeof a&&null!=a.toLowerCase().match(Za)?cb(this.f,"email",a):(x.error('Cannot set email address - "'+a+'" did not pass RFC-5322 validation.'),!1)};p.Fh=function(a){"string"===typeof a&&(a=a.toLowerCase());return null===a||Aa(db,a,'Gender "'+a+'" is not a valid gender.',"User.Genders")?cb(this.f,"gender",a):!1}; +p.Bh=function(a,b,c){if(null===a&&null===b&&null===c)return cb(this.f,"dob",null);a=parseInt(a);b=parseInt(b);c=parseInt(c);return isNaN(a)||isNaN(b)||isNaN(c)||12b||31c?(x.error("Cannot set date of birth - parameters should comprise a valid date e.g. setDateOfBirth(1776, 7, 4);"),!1):cb(this.f,"dob",""+a+"-"+b+"-"+c)};p.yh=function(a){return Qa(a,"set country","the country",!0)?cb(this.f,"country",a):!1}; +p.Gh=function(a){return Qa(a,"set home city","the homeCity",!0)?cb(this.f,"home_city",a):!1};p.Hh=function(a){return Qa(a,"set language","the language",!0)?cb(this.f,"language",a):!1};p.Dh=function(a){return Aa(eb,a,'Email notification setting "'+a+'" is not a valid subscription type.',"User.NotificationSubscriptionTypes")?cb(this.f,"email_subscribe",a):!1}; +p.Ud=function(a){return Aa(eb,a,'Push notification setting "'+a+'" is not a valid subscription type.',"User.NotificationSubscriptionTypes")?cb(this.f,"push_subscribe",a):!1};p.Jh=function(a){return Qa(a,"set phone number","the phoneNumber",!0)?null===a||a.match(fb)?cb(this.f,"phone",a):(x.error('Cannot set phone number - "'+a+'" did not pass validation.'),!1):!1};p.xh=function(a){return cb(this.f,"image_url",a)}; +p.Oc=function(a,b,c,d,e){if(null==a||null==b)return x.error("Cannot set last-known location - latitude and longitude are required."),!1;a=parseFloat(a);b=parseFloat(b);null!=c&&(c=parseFloat(c));null!=d&&(d=parseFloat(d));null!=e&&(e=parseFloat(e));return isNaN(a)||isNaN(b)||null!=c&&isNaN(c)||null!=d&&isNaN(d)||null!=e&&isNaN(e)?(x.error("Cannot set last-known location - all supplied parameters must be numeric."),!1):90a||180b?(x.error("Cannot set last-known location - latitude and longitude are bounded by \u00b190 and \u00b1180 respectively."), +!1):null!=c&&0>c||null!=e&&0>e?(x.error("Cannot set last-known location - accuracy and altitudeAccuracy may not be negative."),!1):this.H.Oc(this.f.o(),a,b,d,c,e).h}; +p.Sd=function(a,b){if(!Ra(a,"set custom user attribute","the given key"))return !1;var c=typeof b,d=Da(b),e=Ca(b);if("number"!==c&&"boolean"!==c&&!d&&!e&&null!==b&&!Ra(b,'set custom user attribute "'+a+'"',"the given value"))return !1;d&&(b=Ka(b));if(e){for(c=0;cb||isNaN(c)||180c)return x.error("Received invalid values for latitude and/or longitude. Latitude and longitude are bounded by \u00b190 and \u00b1180 respectively, or must both be null for removal."),!1;var d=this.H,e=c;c=new $a;if(ib(d.J,a))x.info('Custom Attribute "'+a+'" is blocklisted, ignoring.'),c.h=!1;else{var f=ab(d.D); +if(null===b&&null===e){var g=z.kg;a={key:a};}else g=z.jg,a={key:a,latitude:b,longitude:e};c.j.push(new E(d.f.o(),g,(new Date).valueOf(),f,a));c.h=bb(d.b,c.j);}return c.h};p.Rg=function(a){return !Qa(a,"add user to subscription group","subscription group ID",!1)||0>=a.length?(x.error("addToSubscriptionGroup requires a non-empty subscription group ID"),!1):jb(this.H,a,kb).h}; +p.rh=function(a){return !Qa(a,"remove user from subscription group","subscription group ID",!1)||0>=a.length?(x.error("removeFromSubscriptionGroup requires a non-empty subscription group ID"),!1):jb(this.H,a,lb).h};var fb=/^[0-9 .\\(\\)\\+\\-]+$/,db={MALE:"m",FEMALE:"f",OTHER:"o",UNKNOWN:"u",NOT_APPLICABLE:"n",PREFER_NOT_TO_SAY:"p"},eb={OPTED_IN:"opted_in",SUBSCRIBED:"subscribed",UNSUBSCRIBED:"unsubscribed"},kb="subscribed",lb="unsubscribed";J.User=K;J.User.Genders=db; +J.User.NotificationSubscriptionTypes=eb;J.User.prototype.getUserId=K.prototype.o;J.User.prototype.setFirstName=K.prototype.Eh;J.User.prototype.setLastName=K.prototype.Ih;J.User.prototype.setEmail=K.prototype.Ch;J.User.prototype.setGender=K.prototype.Fh;J.User.prototype.setDateOfBirth=K.prototype.Bh;J.User.prototype.setCountry=K.prototype.yh;J.User.prototype.setHomeCity=K.prototype.Gh;J.User.prototype.setLanguage=K.prototype.Hh;J.User.prototype.setEmailNotificationSubscriptionType=K.prototype.Dh; +J.User.prototype.setPushNotificationSubscriptionType=K.prototype.Ud;J.User.prototype.setPhoneNumber=K.prototype.Jh;J.User.prototype.setAvatarImageUrl=K.prototype.xh;J.User.prototype.setLastKnownLocation=K.prototype.Oc;J.User.prototype.setCustomUserAttribute=K.prototype.Sd;J.User.prototype.addToCustomAttributeArray=K.prototype.Qg;J.User.prototype.removeFromCustomAttributeArray=K.prototype.qh;J.User.prototype.incrementCustomUserAttribute=K.prototype.kh;J.User.prototype.addAlias=K.prototype.Pg; +J.User.prototype.setCustomLocationAttribute=K.prototype.Ah;J.User.prototype.addToSubscriptionGroup=K.prototype.Rg;J.User.prototype.removeFromSubscriptionGroup=K.prototype.rh;function mb(){}mb.prototype.Ed=function(){};mb.prototype.Fd=function(){};mb.prototype.qb=function(){};function nb(a,b){if(a&&b)if(a=a.toLowerCase(),Ca(b.O))for(var c=0;cthis.Ke)return x.info("Storage failure: object is \u2248"+d+" bytes which is greater than the max of "+this.Ke),!1;this.ud[a]=c;return !0};Lb.prototype.Z=function(a){a=this.ud[a];return null==a?null:a.value}; +Lb.prototype.remove=function(a){this.ud[a]=null;};function Mb(a,b,c){this.ma=[];b&&this.ma.push(new Ib(a));c&&this.ma.push(new Hb(a));this.ma.push(new Lb);}Mb.prototype.store=function(a,b){for(var c=!0,d=0;dMath.abs(h)&&25<=Math.abs(g)?(0g&&b===Xb&&c(f),e=d=null):25<=Math.abs(h)&&(0h&&b===Zb&&0===a.scrollTop&&c(f),e=d=null);}});} +function $b(a,b,c){var d=document.createElementNS("http://www.w3.org/2000/svg","svg");d.setAttribute("viewBox",a);d.setAttribute("xmlns","http://www.w3.org/2000/svg");a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d",b);null!=c&&a.setAttribute("fill",c);d.appendChild(a);return d}var Rb=null,Yb="up",Zb="down",Wb="left",Xb="right";function ac(a,b,c){var d=document.createElement("button");d.setAttribute("aria-label",a);d.setAttribute("tabindex","0");d.setAttribute("role","button");Sb(d,"touchstart",function(){});d.className="ab-close-button";a=$b("0 0 15 15","M15 1.5L13.5 0l-6 6-6-6L0 1.5l6 6-6 6L1.5 15l6-6 6 6 1.5-1.5-6-6 6-6z",b);d.appendChild(a);d.addEventListener("keydown",function(e){if(32===e.keyCode||13===e.keyCode)c(),e.stopPropagation();});d.onclick=function(e){c();e.stopPropagation();};return d}var bc={nh:function(){return 600>=screen.width},hh:function(){if("orientation"in window)return 90===Math.abs(window.orientation)||270===window.orientation?bc.Sa.Zc:bc.Sa.jc;if("screen"in window){var a=window.screen.orientation||screen.ci||screen.ei;null!=a&&"object"===typeof a&&(a=a.type);if("landscape-primary"===a||"landscape-secondary"===a)return bc.Sa.Zc}return bc.Sa.jc},oh:function(a,b,c){c||null!=b&&b.metaKey?window.open(a):window.location=a;},Sa:{jc:0,Zc:1}};J.WindowUtils=bc; +J.WindowUtils.openUri=bc.oh;function cc(a,b,c,d,e,f,g,h,l,k,m,q,v,t,w,r){this.id=a;this.viewed=b||!1;this.title=c||"";this.imageUrl=d;this.description=e||"";this.created=f||null;this.updated=g||null;this.categories=h||[];this.expiresAt=l||null;this.url=k;this.linkText=m;q=parseFloat(q);this.aspectRatio=isNaN(q)?null:q;this.extras=v;this.pinned=t||!1;this.dismissible=w||!1;this.dismissed=!1;this.clicked=r||!1;this.test=!1;this.pd=this.X=null;}function dc(a){null==a.X&&(a.X=new Nb);return a.X} +function ec(a){null==a.pd&&(a.pd=new Nb);return a.pd}p=cc.prototype;p.Vb=function(a){return Ob(dc(this),a)};p.Wd=function(a){return Ob(ec(this),a)};p.N=function(a){dc(this).N(a);ec(this).N(a);};p.K=function(){dc(this).K();ec(this).K();};p.Od=function(){this.viewed=!0;};p.fb=function(){this.clicked=this.viewed=!0;Pb(dc(this));};p.Nd=function(){return this.dismissible&&!this.dismissed?(this.dismissed=!0,Pb(ec(this)),!0):!1}; +function fc(a,b){if(null==b||b[T.wa]!==a.id)return !0;if(b[T.pe])return !1;if(null!=b[T.ea]&&null!=a.updated&&b[T.ea]>>24}function sc(a){a=parseInt(a);if(isNaN(a))return "";var b=parseFloat(b);isNaN(b)&&(b=1);a>>>=0;var c=a&255,d=(a&65280)>>>8,e=(a&16711680)>>>16;return (vb.Ya===ob.dc?8>>24)/255*b].join()+")":"rgb("+[e,d,c].join()+")"}function W(a,b,c,d,e,f,g,h,l,k,m,q,v,t,w,r,F,D,G,H,A,N,L,I,V,Q,n,u,y,B,P){this.message=a;this.messageAlignment=b||tc;this.duration=q||5E3;this.slideFrom=c||uc;this.extras=d||{};this.campaignId=e;this.cardId=f;this.triggerId=g;this.clickAction=h||vc;this.uri=l;this.openTarget=k||wc;this.dismissType=m||xc;this.icon=v;this.imageUrl=t;this.imageStyle=w||yc;this.iconColor=r||zc.nd;this.iconBackgroundColor=F||zc.$d;this.backgroundColor=D||zc.nd;this.textColor=G||zc.ce;this.closeButtonColor=H||zc.Sf;this.animateIn= +A;null==this.animateIn&&(this.animateIn=!0);this.animateOut=N;null==this.animateOut&&(this.animateOut=!0);this.header=L;this.headerAlignment=I||tc;this.headerTextColor=V||zc.ce;this.frameColor=Q||zc.vg;this.buttons=n||[];this.cropType=u||Ac;this.orientation=y;this.htmlId=B;this.css=P;this.Fe=this.Wa=this.Ge=!1;this.X=new Nb;this.nc=new Nb;}p=W.prototype;p.Ja=function(){return !0};p.xf=function(){return this.Ja()};function Bc(a){return null!=a.htmlId&&4a.target.clientHeight||document.querySelector("."+Sc)&&a.preventDefault();} +p.Kc=function(a){this.Ja()&&null!=a.parentNode&&this.orientation!==Zc&&(null!=a.parentNode.classList&&a.parentNode.classList.add(Sc),document.body.addEventListener("touchmove",Tc,Qb()?{passive:!1}:!1));a.className+=" "+Uc;};p.oa=function(){var a="";this.animateIn&&(a+=" ab-animate-in");this.animateOut&&(a+=" ab-animate-out");return a}; +var zc={ce:4281545523,nd:4294967295,$d:4278219733,Tf:4293914607,Uf:4283782485,vg:3224580915,Sf:4288387995},dd={ge:"hd",Bf:"ias",rg:"of",Vf:"do",Ab:"umt",yb:"tf",ie:"te"},uc="BOTTOM",ed={TOP:"TOP",BOTTOM:uc},bd="NEWS_FEED",$c="URI",vc="NONE",fd={NEWS_FEED:bd,URI:$c,NONE:vc},xc="AUTO_DISMISS",gd={AUTO_DISMISS:xc,MANUAL:"SWIPE"},wc="NONE",ad="BLANK",hd={NONE:wc,BLANK:ad},yc="TOP",Yc="GRAPHIC",id={TOP:yc,GRAPHIC:Yc},Zc="LANDSCAPE",jd={PORTRAIT:"PORTRAIT",LANDSCAPE:Zc},tc="CENTER",kd={START:"START",CENTER:tc, +END:"END"},cd="CENTER_CROP",Ac="FIT_CENTER",ld={CENTER_CROP:cd,FIT_CENTER:Ac},Mc="SLIDEUP",Hc="MODAL",Ic="MODAL_STYLED",Kc="FULL",Oc="WEB_HTML",Pc="HTML",Xc=500,Uc="ab-show",Vc="ab-hide",Sc="ab-pause-scrolling";J.InAppMessage=W;J.InAppMessage.SlideFrom=ed;J.InAppMessage.ClickAction=fd;J.InAppMessage.DismissType=gd;J.InAppMessage.OpenTarget=hd;J.InAppMessage.ImageStyle=id;J.InAppMessage.TextAlignment=kd;J.InAppMessage.Orientation=jd;J.InAppMessage.CropType=ld;J.InAppMessage.fromJson=Ec; +J.InAppMessage.prototype.subscribeToClickedEvent=W.prototype.Vb;J.InAppMessage.prototype.subscribeToDismissedEvent=W.prototype.Wd;J.InAppMessage.prototype.removeSubscription=W.prototype.N;J.InAppMessage.prototype.removeAllSubscriptions=W.prototype.K;J.InAppMessage.prototype.closeMessage=W.prototype.Ye;function Gc(a,b,c,d,e,f,g){this.text=a||"";this.backgroundColor=b||zc.$d;this.textColor=c||zc.nd;this.borderColor=d||this.backgroundColor;this.clickAction=e||vc;this.uri=f;null==g&&(g=md);this.id=g;this.Wa=!1;this.X=new Nb;}Gc.prototype.Vb=function(a){return Ob(this.X,a)};Gc.prototype.N=function(a){this.X.N(a);};Gc.prototype.K=function(){this.X.K();};Gc.prototype.fb=function(){return this.Wa?!1:(this.Wa=!0,Pb(this.X),!0)};var md=-1;J.InAppMessageButton=Gc; +J.InAppMessageButton.prototype.subscribeToClickedEvent=Gc.prototype.Vb;J.InAppMessageButton.prototype.removeSubscription=Gc.prototype.N;J.InAppMessageButton.prototype.removeAllSubscriptions=Gc.prototype.K;function Fc(a){this.triggerId=a;}J.ControlMessage=Fc;function nd(a){for(var b=a.querySelectorAll(".ab-close-button, .ab-message-text, .ab-message-button"),c=0;c/g,"