@piwikpro/tracking-base-library
Version:
Piwik PRO basic tracking library for the frontend.
850 lines (849 loc) • 31 kB
JavaScript
(function(global, factory) {
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["tracking-base-library"] = {}));
})(this, function(exports2) {
"use strict";
const sanitizeUrl = (url) => url.replace(/\/+$/, "");
const DEFAULT_DATA_LAYER_NAME = "dataLayer";
let dataLayerName = DEFAULT_DATA_LAYER_NAME;
function setDataLayerName(name) {
dataLayerName = name;
}
function push$1(data) {
if (typeof window[dataLayerName] !== "object") {
window[dataLayerName] = [];
}
IS_DEBUG && console.log("DataLayer push", data);
return window[dataLayerName].push(data);
}
const dataLayer_service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
push: push$1,
setDataLayerName
}, Symbol.toStringTag, { value: "Module" }));
function getConfig(nonceOrOptions) {
if (typeof nonceOrOptions === "string") {
return {
dataLayerName: DEFAULT_DATA_LAYER_NAME,
nonce: nonceOrOptions
};
}
if (!nonceOrOptions) {
return {
dataLayerName: DEFAULT_DATA_LAYER_NAME
};
}
return nonceOrOptions;
}
const init = (containerId, containerUrl, nonceOrOptions) => {
if (!containerId) {
console.error("Empty tracking code for Piwik Pro.");
return;
}
if (!containerUrl) {
console.error("Empty tracking URL for Piwik Pro.");
return;
}
if (typeof window === "undefined") {
console.error("Was not possible to access window. Make sure this module is running in a browser");
return;
}
const config = getConfig(nonceOrOptions);
if (config.dataLayerName) {
setDataLayerName(config.dataLayerName);
}
const scriptEl = document.createElement("script");
scriptEl.id = "PiwikPROInitializer";
scriptEl.async = true;
if (config.nonce) {
scriptEl.nonce = config.nonce;
}
scriptEl.text = getInitScript({
containerId,
containerUrl,
dataLayerName: config.dataLayerName,
nonceValue: config.nonce
});
const body = document.getElementsByTagName("body")[0];
body.prepend(scriptEl);
};
function getInitScript({ containerId, containerUrl, dataLayerName: dataLayerName2, nonceValue }) {
const dataLayer = dataLayerName2 || DEFAULT_DATA_LAYER_NAME;
const nonceTag = nonceValue ? `,tags.nonce="${nonceValue}"` : "";
const sanitizedContainerUrl = sanitizeUrl(containerUrl);
return `(function(window, document, dataLayerName, id) {
window[dataLayerName]=window[dataLayerName]||[],window[dataLayerName].push({start:(new Date).getTime(),event:"stg.start"});var scripts=document.getElementsByTagName('script')[0],tags=document.createElement('script');
function stgCreateCookie(a,b,c){var d="";if(c){var e=new Date;e.setTime(e.getTime()+24*c*60*60*1e3),d="; expires="+e.toUTCString();f="; SameSite=Strict"}document.cookie=a+"="+b+d+f+"; path=/"}
var isStgDebug=(window.location.href.match("stg_debug")||document.cookie.match("stg_debug"))&&!window.location.href.match("stg_disable_debug");stgCreateCookie("stg_debug",isStgDebug?1:"",isStgDebug?14:-1);
var qP=[];dataLayerName!=="dataLayer"&&qP.push("data_layer_name="+dataLayerName)${nonceTag},isStgDebug&&qP.push("stg_debug");var qPString=qP.length>0?("?"+qP.join("&")):"";
tags.async=!0,tags.src="${sanitizedContainerUrl}/"+id+".js"+qPString,scripts.parentNode.insertBefore(tags,scripts);
!function(a,n,i){a[n]=a[n]||{};for(var c=0;c<i.length;c++)!function(i){a[n][i]=a[n][i]||{},a[n][i].api=a[n][i].api||function(){var a=[].slice.call(arguments,0);"string"==typeof a[0]&&window[dataLayerName].push({event:n+"."+i+":"+a[0],parameters:[].slice.call(arguments,1)})}}(i[c])}(window,"ppms",["tm","cm"]);
})(window, document, '${dataLayer}', '${containerId}');`;
}
const IS_DEBUG = typeof process !== "undefined" && process.env.NODE_ENV === "development" || typeof window !== "undefined" && window.IS_DEBUG || false;
var ECOMMERCE_TRACK_EVENT;
(function(ECOMMERCE_TRACK_EVENT2) {
ECOMMERCE_TRACK_EVENT2["TRACK_ECOMMERCE_CART_UPDATE"] = "trackEcommerceCartUpdate";
ECOMMERCE_TRACK_EVENT2["TRACK_ECOMMERCE_ORDER"] = "trackEcommerceOrder";
ECOMMERCE_TRACK_EVENT2["REMOVE_ECOMMERCE_ITEM"] = "removeEcommerceItem";
ECOMMERCE_TRACK_EVENT2["SET_ECOMMERCE_VIEW"] = "setEcommerceView";
ECOMMERCE_TRACK_EVENT2["CLEAR_ECOMMERCE_CART"] = "clearEcommerceCart";
ECOMMERCE_TRACK_EVENT2["ADD_ECOMMERCE_ITEM"] = "addEcommerceItem";
})(ECOMMERCE_TRACK_EVENT || (ECOMMERCE_TRACK_EVENT = {}));
var ECOMMERCE_V2_TRACK_EVENT;
(function(ECOMMERCE_V2_TRACK_EVENT2) {
ECOMMERCE_V2_TRACK_EVENT2["ECOMMERCE_ADD_TO_CART"] = "ecommerceAddToCart";
ECOMMERCE_V2_TRACK_EVENT2["ECOMMERCE_REMOVE_FROM_CART"] = "ecommerceRemoveFromCart";
ECOMMERCE_V2_TRACK_EVENT2["ECOMMERCE_PRODUCT_DETAIL_VIEW"] = "ecommerceProductDetailView";
ECOMMERCE_V2_TRACK_EVENT2["ECOMMERCE_CART_UPDATE"] = "ecommerceCartUpdate";
ECOMMERCE_V2_TRACK_EVENT2["ECOMMERCE_ORDER"] = "ecommerceOrder";
})(ECOMMERCE_V2_TRACK_EVENT || (ECOMMERCE_V2_TRACK_EVENT = {}));
var COOKIE_TRACK_EVENT;
(function(COOKIE_TRACK_EVENT2) {
COOKIE_TRACK_EVENT2["DISABLE_COOKIES"] = "disableCookies";
COOKIE_TRACK_EVENT2["ENABLE_COOKIES"] = "enableCookies";
COOKIE_TRACK_EVENT2["DELETE_COOKIES"] = "deleteCookies";
COOKIE_TRACK_EVENT2["SET_COOKIE_NAME_PREFIX"] = "setCookieNamePrefix";
COOKIE_TRACK_EVENT2["SET_COOKIE_DOMAIN"] = "setCookieDomain";
COOKIE_TRACK_EVENT2["SET_COOKIE_PATH"] = "setCookiePath";
COOKIE_TRACK_EVENT2["SET_SECURE_COOKIE"] = "setSecureCookie";
COOKIE_TRACK_EVENT2["SET_VISITOR_COOKIE_TIMEOUT"] = "setVisitorCookieTimeout";
COOKIE_TRACK_EVENT2["SET_SESSION_COOKIE_TIMEOUT"] = "setSessionCookieTimeout";
COOKIE_TRACK_EVENT2["SET_VISITOR_ID_COOKIE"] = "setVisitorIdCookie";
COOKIE_TRACK_EVENT2["SET_REFERRAL_COOKIE_TIMEOUT"] = "setReferralCookieTimeout";
})(COOKIE_TRACK_EVENT || (COOKIE_TRACK_EVENT = {}));
var CONTENT_TRACK_EVENT;
(function(CONTENT_TRACK_EVENT2) {
CONTENT_TRACK_EVENT2["ALL_CONTENT_IMPRESSIONS"] = "trackAllContentImpressions";
CONTENT_TRACK_EVENT2["VISIBLE_CONTENT_IMPRESSIONS"] = "trackVisibleContentImpressions";
CONTENT_TRACK_EVENT2["CONTENT_IMPRESSIONS_WITH_NODE"] = "trackContentImpressionsWithinNode";
CONTENT_TRACK_EVENT2["CONTENT_IMPRESSION"] = "trackContentImpression";
CONTENT_TRACK_EVENT2["LOG_ALL_CONTENT_BLOCKS_ON_PAGE"] = "logAllContentBlocksOnPage";
CONTENT_TRACK_EVENT2["CONTENT_INTERACTION_NODE"] = "trackContentInteractionNode";
CONTENT_TRACK_EVENT2["CONTENT_INTERACTION"] = "trackContentInteraction";
})(CONTENT_TRACK_EVENT || (CONTENT_TRACK_EVENT = {}));
var CUSTOM_DIMENSIONS_TRACK_EVENT;
(function(CUSTOM_DIMENSIONS_TRACK_EVENT2) {
CUSTOM_DIMENSIONS_TRACK_EVENT2["SET_CUSTOM_DIMENSION_VALUE"] = "setCustomDimensionValue";
CUSTOM_DIMENSIONS_TRACK_EVENT2["DELETE_CUSTOM_DIMENSION"] = "deleteCustomDimension";
CUSTOM_DIMENSIONS_TRACK_EVENT2["SET_CUSTOM_DIMENSION"] = "setCustomDimension";
})(CUSTOM_DIMENSIONS_TRACK_EVENT || (CUSTOM_DIMENSIONS_TRACK_EVENT = {}));
var CUSTOM_EVENT_TRACK_EVENT;
(function(CUSTOM_EVENT_TRACK_EVENT2) {
CUSTOM_EVENT_TRACK_EVENT2["CUSTOM_EVENT"] = "trackEvent";
})(CUSTOM_EVENT_TRACK_EVENT || (CUSTOM_EVENT_TRACK_EVENT = {}));
var DOWNLOAD_AND_OUTLINK_TRACK_EVENT;
(function(DOWNLOAD_AND_OUTLINK_TRACK_EVENT2) {
DOWNLOAD_AND_OUTLINK_TRACK_EVENT2["LINK"] = "trackLink";
DOWNLOAD_AND_OUTLINK_TRACK_EVENT2["ENABLE_LINK_TRACKING"] = "enableLinkTracking";
DOWNLOAD_AND_OUTLINK_TRACK_EVENT2["SET_IGNORE_CLASSES"] = "setIgnoreClasses";
DOWNLOAD_AND_OUTLINK_TRACK_EVENT2["SET_LINK_CLASSES"] = "setLinkClasses";
DOWNLOAD_AND_OUTLINK_TRACK_EVENT2["SET_DOWNLOAD_CLASSES"] = "setDownloadClasses";
DOWNLOAD_AND_OUTLINK_TRACK_EVENT2["SET_DOWNLOAD_EXTENSIONS"] = "setDownloadExtensions";
DOWNLOAD_AND_OUTLINK_TRACK_EVENT2["ADD_DOWNLOAD_EXTENSIONS"] = "addDownloadExtensions";
DOWNLOAD_AND_OUTLINK_TRACK_EVENT2["REMOVE_DOWNLOAD_EXTENSIONS"] = "removeDownloadExtensions";
DOWNLOAD_AND_OUTLINK_TRACK_EVENT2["SET_LINK_TRACKING_TIMER"] = "setLinkTrackingTimer";
})(DOWNLOAD_AND_OUTLINK_TRACK_EVENT || (DOWNLOAD_AND_OUTLINK_TRACK_EVENT = {}));
var GOAL_CONVERSIONS_TRACK_EVENT;
(function(GOAL_CONVERSIONS_TRACK_EVENT2) {
GOAL_CONVERSIONS_TRACK_EVENT2["GOAL"] = "trackGoal";
})(GOAL_CONVERSIONS_TRACK_EVENT || (GOAL_CONVERSIONS_TRACK_EVENT = {}));
var PAGE_VIEWS_TRACK_EVENT;
(function(PAGE_VIEWS_TRACK_EVENT2) {
PAGE_VIEWS_TRACK_EVENT2["PAGE_VIEW"] = "trackPageView";
})(PAGE_VIEWS_TRACK_EVENT || (PAGE_VIEWS_TRACK_EVENT = {}));
var SITE_SEARCH_TRACK_EVENT;
(function(SITE_SEARCH_TRACK_EVENT2) {
SITE_SEARCH_TRACK_EVENT2["SEARCH"] = "trackSiteSearch";
})(SITE_SEARCH_TRACK_EVENT || (SITE_SEARCH_TRACK_EVENT = {}));
var CROSS_DOMAIN_TRACK_EVENT;
(function(CROSS_DOMAIN_TRACK_EVENT2) {
CROSS_DOMAIN_TRACK_EVENT2["ENABLE_CROSS_DOMAIN_LINKING"] = "enableCrossDomainLinking";
CROSS_DOMAIN_TRACK_EVENT2["DISABLE_CROSS_DOMAIN_LINKING"] = "disableCrossDomainLinking";
CROSS_DOMAIN_TRACK_EVENT2["SET_CROSS_DOMAIN_LINKING_TIMEOUT"] = "setCrossDomainLinkingTimeout";
CROSS_DOMAIN_TRACK_EVENT2["IS_CROSS_DOMAIN_LINKING_ENABLED"] = "isCrossDomainLinkingEnabled";
CROSS_DOMAIN_TRACK_EVENT2["GET_CROSS_DOMAIN_LINKING_URL_PARAMETER"] = "getCrossDomainLinkingUrlParameter";
CROSS_DOMAIN_TRACK_EVENT2["CUSTOM_CROSS_DOMAIN_LINK_DECORATOR"] = "customCrossDomainLinkDecorator";
CROSS_DOMAIN_TRACK_EVENT2["CUSTOM_CROSS_DOMAIN_LINK_VISITOR_ID_GETTER"] = "customCrossDomainLinkVisitorIdGetter";
})(CROSS_DOMAIN_TRACK_EVENT || (CROSS_DOMAIN_TRACK_EVENT = {}));
var USER_MANAGEMENT_TRACK_EVENT;
(function(USER_MANAGEMENT_TRACK_EVENT2) {
USER_MANAGEMENT_TRACK_EVENT2["SET_USER_ID"] = "setUserId";
USER_MANAGEMENT_TRACK_EVENT2["RESET_USER_ID"] = "resetUserId";
USER_MANAGEMENT_TRACK_EVENT2["SET_USER_IS_ANONYMOUS"] = "setUserIsAnonymous";
USER_MANAGEMENT_TRACK_EVENT2["DEANONYMIZE_USER"] = "deanonymizeUser";
})(USER_MANAGEMENT_TRACK_EVENT || (USER_MANAGEMENT_TRACK_EVENT = {}));
var PAQ_SERVICE_TRACK_EVENT;
(function(PAQ_SERVICE_TRACK_EVENT2) {
PAQ_SERVICE_TRACK_EVENT2["SET_CUSTOM_URL"] = "setCustomUrl";
PAQ_SERVICE_TRACK_EVENT2["SET_DOCUMENT_TITLE"] = "setDocumentTitle";
})(PAQ_SERVICE_TRACK_EVENT || (PAQ_SERVICE_TRACK_EVENT = {}));
var ERROR_TRACKING_TRACK_EVENT;
(function(ERROR_TRACKING_TRACK_EVENT2) {
ERROR_TRACKING_TRACK_EVENT2["ENABLE_JS_ERROR_TRACKING"] = "enableJSErrorTracking";
ERROR_TRACKING_TRACK_EVENT2["TRACK_ERROR"] = "trackError";
})(ERROR_TRACKING_TRACK_EVENT || (ERROR_TRACKING_TRACK_EVENT = {}));
var CLIENT_CONFIG_TRACK_EVENT;
(function(CLIENT_CONFIG_TRACK_EVENT2) {
CLIENT_CONFIG_TRACK_EVENT2["SET_DOMAINS"] = "setDomains";
CLIENT_CONFIG_TRACK_EVENT2["GET_DOMAINS"] = "getDomains";
})(CLIENT_CONFIG_TRACK_EVENT || (CLIENT_CONFIG_TRACK_EVENT = {}));
var HEARTBEAT_TRACK_EVENT;
(function(HEARTBEAT_TRACK_EVENT2) {
HEARTBEAT_TRACK_EVENT2["ENABLE_HEARTBEAT_TIMER"] = "enableHeartBeatTimer";
HEARTBEAT_TRACK_EVENT2["DISABLE_HEARTBEAT_TIMER"] = "disableHeartBeatTimer";
})(HEARTBEAT_TRACK_EVENT || (HEARTBEAT_TRACK_EVENT = {}));
var MISCELLANEOUS_TRACK_EVENT;
(function(MISCELLANEOUS_TRACK_EVENT2) {
MISCELLANEOUS_TRACK_EVENT2["SET_TRACKING_SOURCE_PROVIDER"] = "setTrackingSourceProvider";
})(MISCELLANEOUS_TRACK_EVENT || (MISCELLANEOUS_TRACK_EVENT = {}));
function push(collection, options) {
if (!window._paq) {
window._paq = [];
}
if (!(options == null ? void 0 : options.skipSettingPageData)) {
window._paq.push([
PAQ_SERVICE_TRACK_EVENT.SET_CUSTOM_URL,
window.location.href
]);
window._paq.push([
PAQ_SERVICE_TRACK_EVENT.SET_DOCUMENT_TITLE,
document.title
]);
}
IS_DEBUG && console.log("Push", collection);
return window._paq.push(collection);
}
function trackPageView(customPageTitle) {
push([
PAGE_VIEWS_TRACK_EVENT.PAGE_VIEW,
...customPageTitle ? [customPageTitle] : []
]);
}
const pageViews_service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
trackPageView
}, Symbol.toStringTag, { value: "Module" }));
function trackEvent(category, action, name, value, dimensions) {
const eventArguments = [category, action, name, value, dimensions];
push([CUSTOM_EVENT_TRACK_EVENT.CUSTOM_EVENT, ...eventArguments]);
}
const customEvents_service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
trackEvent
}, Symbol.toStringTag, { value: "Module" }));
function trackAllContentImpressions() {
push([CONTENT_TRACK_EVENT.ALL_CONTENT_IMPRESSIONS]);
}
function trackVisibleContentImpressions(checkOnScroll = true, watchInterval = 750) {
push([
CONTENT_TRACK_EVENT.VISIBLE_CONTENT_IMPRESSIONS,
checkOnScroll,
watchInterval
]);
}
function trackContentImpressionsWithinNode(domNode) {
push([CONTENT_TRACK_EVENT.CONTENT_IMPRESSIONS_WITH_NODE, domNode]);
}
function trackContentImpression(contentName, contentPiece, contentTarget) {
push([
CONTENT_TRACK_EVENT.CONTENT_IMPRESSION,
contentName,
contentPiece,
contentTarget
]);
}
function logAllContentBlocksOnPage() {
push([CONTENT_TRACK_EVENT.LOG_ALL_CONTENT_BLOCKS_ON_PAGE]);
}
function trackContentInteractionNode(domNode, contentInteraction = "Unknown") {
push([
CONTENT_TRACK_EVENT.CONTENT_INTERACTION_NODE,
domNode,
contentInteraction
]);
}
function trackContentInteraction(contentInteraction, contentName, contentPiece, contentTarget) {
push([
CONTENT_TRACK_EVENT.CONTENT_INTERACTION,
contentInteraction,
contentName,
contentPiece,
contentTarget
]);
}
const contentTracking_service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
logAllContentBlocksOnPage,
trackAllContentImpressions,
trackContentImpression,
trackContentImpressionsWithinNode,
trackContentInteraction,
trackContentInteractionNode,
trackVisibleContentImpressions
}, Symbol.toStringTag, { value: "Module" }));
function disableCookies() {
push([COOKIE_TRACK_EVENT.DISABLE_COOKIES]);
}
function enableCookies() {
push([COOKIE_TRACK_EVENT.ENABLE_COOKIES]);
}
function deleteCookies() {
push([COOKIE_TRACK_EVENT.DELETE_COOKIES]);
}
function hasCookies() {
return new Promise((resolve, reject) => {
try {
push([
function() {
resolve(this.hasCookies());
}
]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function getCookieDomain() {
return new Promise((resolve, reject) => {
try {
push([
function() {
resolve(this.getCookieDomain());
}
]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function getCookiePath() {
return new Promise((resolve, reject) => {
try {
push([
function() {
resolve(this.getCookiePath());
}
]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function getConfigVisitorCookieTimeout() {
return new Promise((resolve, reject) => {
try {
push([
function() {
resolve(this.getConfigVisitorCookieTimeout());
}
]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function setReferralCookieTimeout(seconds) {
push([COOKIE_TRACK_EVENT.SET_REFERRAL_COOKIE_TIMEOUT, seconds]);
}
function getSessionCookieTimeout() {
return new Promise((resolve, reject) => {
try {
push([
function() {
resolve(this.getSessionCookieTimeout());
}
]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function setCookieNamePrefix(prefix) {
push([COOKIE_TRACK_EVENT.SET_COOKIE_NAME_PREFIX, prefix]);
}
function setCookieDomain(domain) {
push([COOKIE_TRACK_EVENT.SET_COOKIE_DOMAIN, domain]);
}
function setCookiePath(path) {
push([COOKIE_TRACK_EVENT.SET_COOKIE_PATH, path]);
}
function setSecureCookie(secure) {
push([COOKIE_TRACK_EVENT.SET_SECURE_COOKIE, secure]);
}
function setVisitorCookieTimeout(seconds) {
push([COOKIE_TRACK_EVENT.SET_VISITOR_COOKIE_TIMEOUT, seconds]);
}
function setSessionCookieTimeout(seconds) {
push([COOKIE_TRACK_EVENT.SET_SESSION_COOKIE_TIMEOUT, seconds]);
}
function setVisitorIdCookie() {
push([COOKIE_TRACK_EVENT.SET_VISITOR_ID_COOKIE]);
}
const cookieManagement_service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
deleteCookies,
disableCookies,
enableCookies,
getConfigVisitorCookieTimeout,
getCookieDomain,
getCookiePath,
getSessionCookieTimeout,
hasCookies,
setCookieDomain,
setCookieNamePrefix,
setCookiePath,
setReferralCookieTimeout,
setSecureCookie,
setSessionCookieTimeout,
setVisitorCookieTimeout,
setVisitorIdCookie
}, Symbol.toStringTag, { value: "Module" }));
function setCustomDimensionValue(customDimensionId, customDimensionValue) {
push([
CUSTOM_DIMENSIONS_TRACK_EVENT.SET_CUSTOM_DIMENSION_VALUE,
customDimensionId,
customDimensionValue
]);
}
function deleteCustomDimension(customDimensionId) {
push([
CUSTOM_DIMENSIONS_TRACK_EVENT.DELETE_CUSTOM_DIMENSION,
customDimensionId
]);
}
function getCustomDimensionValue(customDimensionId) {
return new Promise((resolve, reject) => {
try {
push([
function() {
resolve(this.getCustomDimensionValue(customDimensionId));
}
]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
const customDimensions_service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
deleteCustomDimension,
getCustomDimensionValue,
setCustomDimensionValue
}, Symbol.toStringTag, { value: "Module" }));
function trackLink(url, linkType, dimensions, callback) {
push([
DOWNLOAD_AND_OUTLINK_TRACK_EVENT.LINK,
url,
linkType,
dimensions,
callback
]);
}
function enableLinkTracking(trackAlsoMiddleAndRightClicks = true) {
push([
DOWNLOAD_AND_OUTLINK_TRACK_EVENT.ENABLE_LINK_TRACKING,
trackAlsoMiddleAndRightClicks
]);
}
function setLinkClasses(classes) {
push([DOWNLOAD_AND_OUTLINK_TRACK_EVENT.SET_LINK_CLASSES, classes]);
}
function setDownloadClasses(classes) {
push([DOWNLOAD_AND_OUTLINK_TRACK_EVENT.SET_DOWNLOAD_CLASSES, classes]);
}
function setDownloadExtensions(extensions) {
push([DOWNLOAD_AND_OUTLINK_TRACK_EVENT.SET_DOWNLOAD_EXTENSIONS, extensions]);
}
function addDownloadExtensions(extensions) {
push([DOWNLOAD_AND_OUTLINK_TRACK_EVENT.ADD_DOWNLOAD_EXTENSIONS, extensions]);
}
function removeDownloadExtensions(extensions) {
push([
DOWNLOAD_AND_OUTLINK_TRACK_EVENT.REMOVE_DOWNLOAD_EXTENSIONS,
extensions
]);
}
function setLinkTrackingTimer(time) {
push([DOWNLOAD_AND_OUTLINK_TRACK_EVENT.SET_LINK_TRACKING_TIMER, time]);
}
function getLinkTrackingTimer() {
return new Promise((resolve, reject) => {
try {
push([
function() {
resolve(this.getLinkTrackingTimer());
}
]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function setIgnoreClasses(classes) {
push([DOWNLOAD_AND_OUTLINK_TRACK_EVENT.SET_IGNORE_CLASSES, classes]);
}
const downloadAndOutlink_service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
addDownloadExtensions,
enableLinkTracking,
getLinkTrackingTimer,
removeDownloadExtensions,
setDownloadClasses,
setDownloadExtensions,
setIgnoreClasses,
setLinkClasses,
setLinkTrackingTimer,
trackLink
}, Symbol.toStringTag, { value: "Module" }));
function addEcommerceItem(productSKU, productName, productCategory, productPrice, productQuantity) {
push([
ECOMMERCE_TRACK_EVENT.ADD_ECOMMERCE_ITEM,
productSKU,
productName,
productCategory,
productPrice,
productQuantity
]);
}
function ecommerceAddToCart(products, options) {
push([ECOMMERCE_V2_TRACK_EVENT.ECOMMERCE_ADD_TO_CART, products, options]);
}
function removeEcommerceItem(productSKU) {
push([ECOMMERCE_TRACK_EVENT.REMOVE_ECOMMERCE_ITEM, productSKU]);
}
function ecommerceRemoveFromCart(products, options) {
push([ECOMMERCE_V2_TRACK_EVENT.ECOMMERCE_REMOVE_FROM_CART, products, options]);
}
function getEcommerceItems() {
return new Promise((resolve, reject) => {
try {
push([
function() {
resolve(this.getEcommerceItems());
}
]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function trackEcommerceOrder(orderId, orderGrandTotal, orderSubTotal, orderTax, orderShipping, orderDiscount) {
push([
ECOMMERCE_TRACK_EVENT.TRACK_ECOMMERCE_ORDER,
orderId,
orderGrandTotal,
orderSubTotal,
orderTax,
orderShipping,
orderDiscount
]);
}
function ecommerceOrder(products, paymentInformation, options) {
push([
ECOMMERCE_V2_TRACK_EVENT.ECOMMERCE_ORDER,
products,
paymentInformation,
options
]);
}
function trackEcommerceCartUpdate(cartAmount) {
push([ECOMMERCE_TRACK_EVENT.TRACK_ECOMMERCE_CART_UPDATE, cartAmount]);
}
function ecommerceCartUpdate(products, grandTotal, options) {
push([
ECOMMERCE_V2_TRACK_EVENT.ECOMMERCE_CART_UPDATE,
products,
grandTotal,
options
]);
}
function ecommerceProductDetailView(products, options) {
push([
ECOMMERCE_V2_TRACK_EVENT.ECOMMERCE_PRODUCT_DETAIL_VIEW,
products,
options
]);
}
function clearEcommerceCart() {
push([ECOMMERCE_TRACK_EVENT.CLEAR_ECOMMERCE_CART]);
}
function setEcommerceView(productSKU, productName, productCategory, productPrice) {
push([
ECOMMERCE_TRACK_EVENT.SET_ECOMMERCE_VIEW,
productSKU,
productName,
productCategory,
productPrice
]);
}
const eCommerce_service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
addEcommerceItem,
clearEcommerceCart,
ecommerceAddToCart,
ecommerceCartUpdate,
ecommerceOrder,
ecommerceProductDetailView,
ecommerceRemoveFromCart,
getEcommerceItems,
removeEcommerceItem,
setEcommerceView,
trackEcommerceCartUpdate,
trackEcommerceOrder
}, Symbol.toStringTag, { value: "Module" }));
function trackGoal(goalId, conversionValue, dimensions, options) {
push([
GOAL_CONVERSIONS_TRACK_EVENT.GOAL,
goalId,
conversionValue,
// prevent mutating user-provided object
dimensions ? { ...dimensions } : void 0,
options
]);
}
const goalConversions_service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
trackGoal
}, Symbol.toStringTag, { value: "Module" }));
function trackSiteSearch(keyword, category, searchCount, dimensions) {
push([
SITE_SEARCH_TRACK_EVENT.SEARCH,
keyword,
category,
searchCount,
dimensions
]);
}
const siteSearch_service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
trackSiteSearch
}, Symbol.toStringTag, { value: "Module" }));
function getUserId() {
return new Promise((resolve, reject) => {
try {
push([
function() {
resolve(this.getUserId());
}
]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function setUserId(userId) {
push([USER_MANAGEMENT_TRACK_EVENT.SET_USER_ID, userId]);
}
function resetUserId() {
push([USER_MANAGEMENT_TRACK_EVENT.RESET_USER_ID]);
}
function getVisitorId() {
return new Promise((resolve, reject) => {
try {
push([
function() {
resolve(this.getVisitorId());
}
]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function getVisitorInfo() {
return new Promise((resolve, reject) => {
try {
push([
function() {
resolve(this.getVisitorInfo());
}
]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function setUserIsAnonymous(isAnonymous) {
push([USER_MANAGEMENT_TRACK_EVENT.SET_USER_IS_ANONYMOUS, isAnonymous]);
}
function deanonymizeUser() {
push([USER_MANAGEMENT_TRACK_EVENT.DEANONYMIZE_USER]);
}
const userManagement_service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
deanonymizeUser,
getUserId,
getVisitorId,
getVisitorInfo,
resetUserId,
setUserId,
setUserIsAnonymous
}, Symbol.toStringTag, { value: "Module" }));
function enableJSErrorTracking(unique = true) {
push([ERROR_TRACKING_TRACK_EVENT.ENABLE_JS_ERROR_TRACKING, unique]);
}
function trackError(error) {
push([ERROR_TRACKING_TRACK_EVENT.TRACK_ERROR, error]);
}
const errorTracking_service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
enableJSErrorTracking,
trackError
}, Symbol.toStringTag, { value: "Module" }));
function enableCrossDomainLinking() {
push([CROSS_DOMAIN_TRACK_EVENT.ENABLE_CROSS_DOMAIN_LINKING]);
}
function disableCrossDomainLinking() {
push([CROSS_DOMAIN_TRACK_EVENT.DISABLE_CROSS_DOMAIN_LINKING]);
}
function setCrossDomainLinkingTimeout(timeout) {
push([CROSS_DOMAIN_TRACK_EVENT.SET_CROSS_DOMAIN_LINKING_TIMEOUT, timeout]);
}
function isCrossDomainLinkingEnabled() {
return new Promise((resolve, reject) => {
try {
push([
function() {
resolve(this.isCrossDomainLinkingEnabled());
}
]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function getCrossDomainLinkingUrlParameter() {
return new Promise((resolve, reject) => {
try {
push([
function() {
resolve(this.getCrossDomainLinkingUrlParameter());
}
]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function customCrossDomainLinkDecorator(decorator) {
push([
CROSS_DOMAIN_TRACK_EVENT.CUSTOM_CROSS_DOMAIN_LINK_DECORATOR,
function(...args) {
return decorator(...args);
}
]);
}
function customCrossDomainLinkVisitorIdGetter(getter) {
push([
CROSS_DOMAIN_TRACK_EVENT.CUSTOM_CROSS_DOMAIN_LINK_VISITOR_ID_GETTER,
function(...args) {
return getter(...args);
}
]);
}
const crossDomainTracking_service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
customCrossDomainLinkDecorator,
customCrossDomainLinkVisitorIdGetter,
disableCrossDomainLinking,
enableCrossDomainLinking,
getCrossDomainLinkingUrlParameter,
isCrossDomainLinkingEnabled,
setCrossDomainLinkingTimeout
}, Symbol.toStringTag, { value: "Module" }));
function setDomains(domains) {
push([CLIENT_CONFIG_TRACK_EVENT.SET_DOMAINS, domains]);
}
function getDomains() {
return new Promise((resolve, reject) => {
try {
push([
function() {
resolve(this.getDomains());
}
]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
const clientConfiguration_service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
getDomains,
setDomains
}, Symbol.toStringTag, { value: "Module" }));
function enableHeartBeatTimer(delays) {
push([HEARTBEAT_TRACK_EVENT.ENABLE_HEARTBEAT_TIMER, delays]);
}
function disableHeartBeatTimer() {
push([HEARTBEAT_TRACK_EVENT.DISABLE_HEARTBEAT_TIMER]);
}
const heartbeat_service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
disableHeartBeatTimer,
enableHeartBeatTimer
}, Symbol.toStringTag, { value: "Module" }));
function setTrackingSourceProvider(provider, version) {
push(
[MISCELLANEOUS_TRACK_EVENT.SET_TRACKING_SOURCE_PROVIDER, provider, version],
// this function should be called on the startup,
// we don't want to modify any other configurations as the page may not be fully loaded yet
{ skipSettingPageData: true }
);
}
const miscellaneous_service = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
setTrackingSourceProvider
}, Symbol.toStringTag, { value: "Module" }));
const index = {
initialize: init,
getInitScript
};
exports2.ClientConfiguration = clientConfiguration_service;
exports2.ContentTracking = contentTracking_service;
exports2.CookieManagement = cookieManagement_service;
exports2.CrossDomainTracking = crossDomainTracking_service;
exports2.CustomDimensions = customDimensions_service;
exports2.CustomEvent = customEvents_service;
exports2.DataLayer = dataLayer_service;
exports2.DownloadAndOutlink = downloadAndOutlink_service;
exports2.ErrorTracking = errorTracking_service;
exports2.GoalConversions = goalConversions_service;
exports2.Heartbeat = heartbeat_service;
exports2.Miscellaneous = miscellaneous_service;
exports2.PageViews = pageViews_service;
exports2.SiteSearch = siteSearch_service;
exports2.UserManagement = userManagement_service;
exports2.default = index;
exports2.eCommerce = eCommerce_service;
Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
});
//# sourceMappingURL=index.umd.cjs.map