Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@piwikpro/react-piwik-pro

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@piwikpro/react-piwik-pro - npm Package Compare versions

Comparing version 1.3.3 to 2.0.0

17

dist/index.d.ts

@@ -1,15 +0,2 @@

export * as PageViews from './services/pageViews/pageViews.service';
export * as CustomEvent from './services/custom-events/customEvents.service';
export * as ContentTracking from './services/content-tracking/contentTracking.service';
export * as CookieManagement from './services/cookie-management/cookieManagement.service';
export * as CustomDimensions from './services/custom-dimensions/customDimensions.service';
export * as DownloadAndOutlink from './services/download-and-outlink/download-and-outlink.service';
export * as eCommerce from './services/e-commerce/e-commerce.service';
export * as GoalConversions from './services/goal-conversions/goal-conversions.service';
export * as SiteSearch from './services/site-search/site-search.service';
export * as UserManagement from './services/user-management/userManagement.service';
export * as DataLayer from './services/dataLayer/dataLayer.service';
declare const _default: {
initialize: (containerId: string, containerUrl: string, nonce?: string | undefined) => void;
};
export default _default;
export { default } from '@piwikpro/tracking-base-library';
export * from '@piwikpro/tracking-base-library';

@@ -1,507 +0,17 @@

function init(containerId, containerUrl, nonce) {
if (!containerId) {
console.error('Empty tracking code for Piwik Pro.');
return;
}
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
if (!containerUrl) {
console.error('Empty tracking URL for Piwik Pro.');
return;
}
var trackingBaseLibrary = require('@piwikpro/tracking-base-library');
var trackingBaseLibrary__default = _interopDefault(trackingBaseLibrary);
if (!document) {
console.error('Was not possible to access Document interface. Make sure this module is running on a Browser w/ access do Document interface.');
}
var s = document.createElement('script');
s.async = false;
if (nonce) {
s.setAttribute('nonce', nonce);
}
s.text = "(function(window, document, dataLayerName, id) {\nwindow[dataLayerName]=window[dataLayerName]||[],window[dataLayerName].push({start:(new Date).getTime(),event:\"stg.start\"});var scripts=document.getElementsByTagName('script')[0],tags=document.createElement('script');\nfunction 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=/\"}\nvar 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);\nvar qP=[];dataLayerName!==\"dataLayer\"&&qP.push(\"data_layer_name=\"+dataLayerName),isStgDebug&&qP.push(\"stg_debug\");var qPString=qP.length>0?(\"?\"+qP.join(\"&\")):\"\";\ntags.async=!0,tags.src=\"" + containerUrl + "/\"+id+\".js\"+qPString,scripts.parentNode.insertBefore(tags,scripts);\n!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\"]);\n})(window, document, 'dataLayer', '" + containerId + "')";
var head = document.getElementsByTagName('body')[0];
head.appendChild(s);
}
var IS_DEBUG = typeof process !== 'undefined' && process.env.NODE_ENV === 'development' || typeof window !== 'undefined' && window.IS_DEBUG || false;
var index = {
init: init
};
var TRACK_EVENT;
(function (TRACK_EVENT) {
TRACK_EVENT["PAGE_VIEW"] = "trackPageView";
TRACK_EVENT["CUSTOM_EVENT"] = "trackEvent";
TRACK_EVENT["GOAL"] = "trackGoal";
TRACK_EVENT["SEARCH"] = "trackSiteSearch";
TRACK_EVENT["ECOMMERCE_ADD_TO_CART"] = "ecommerceAddToCart";
TRACK_EVENT["ADD_ECOMMERCE_ITEM"] = "addEcommerceItem";
TRACK_EVENT["REMOVE_ECOMMERCE_ITEM"] = "removeEcommerceItem";
TRACK_EVENT["ECOMMERCE_REMOVE_FROM_CART"] = "ecommerceRemoveFromCart";
TRACK_EVENT["ECOMMERCE_PRODUCT_DETAIL_VIEW"] = "ecommerceProductDetailView";
TRACK_EVENT["ECOMMERCE_CART_UPDATE"] = "ecommerceCartUpdate";
TRACK_EVENT["TRACK_ECOMMERCE_CART_UPDATE"] = "trackEcommerceCartUpdate";
TRACK_EVENT["TRACK_ECOMMERCE_ORDER"] = "trackEcommerceOrder";
TRACK_EVENT["ECOMMERCE_ORDER"] = "ecommerceOrder";
TRACK_EVENT["SET_ECOMMERCE_VIEW"] = "setEcommerceView";
TRACK_EVENT["CLEAR_ECOMMERCE_CART"] = "clearEcommerceCart";
TRACK_EVENT["SET_CUSTOM_VARIABLE"] = "setCustomVariable";
TRACK_EVENT["DELETE_CUSTOM_VARIABLE"] = "deleteCustomVariable";
TRACK_EVENT["STORE_CUSTOM_VARIABLES_IN_COOKIE"] = "storeCustomVariablesInCookie";
TRACK_EVENT["SET_CUSTOM_DIMENSION_VALUE"] = "setCustomDimensionValue";
TRACK_EVENT["DELETE_CUSTOM_DIMENSION"] = "deleteCustomDimension";
TRACK_EVENT["SET_CUSTOM_DIMENSION"] = "setCustomDimension";
TRACK_EVENT["ALL_CONTENT_IMPRESSIONS"] = "trackAllContentImpressions";
TRACK_EVENT["VISIBLE_CONTENT_IMPRESSIONS"] = "trackVisibleContentImpressions";
TRACK_EVENT["CONTENT_IMPRESSIONS_WITH_NODE"] = "trackContentImpressionsWithinNode";
TRACK_EVENT["CONTENT_IMPRESSION"] = "trackContentImpression";
TRACK_EVENT["LOG_ALL_CONTENT_BLOCKS_ON_PAGE"] = "logAllContentBlocksOnPage";
TRACK_EVENT["CONTENT_INTERACTION_NODE"] = "trackContentInteractionNode";
TRACK_EVENT["CONTENT_INTERACTION"] = "trackContentInteraction";
TRACK_EVENT["LINK"] = "trackLink";
TRACK_EVENT["ENABLE_LINK_TRACKING"] = "enableLinkTracking";
TRACK_EVENT["SET_IGNORE_CLASSES"] = "setIgnoreClasses";
TRACK_EVENT["SET_LINK_CLASSES"] = "setLinkClasses";
TRACK_EVENT["SET_DOWNLOAD_CLASSES"] = "setDownloadClasses";
TRACK_EVENT["SET_DOWNLOAD_EXTENSIONS"] = "setDownloadExtensions";
TRACK_EVENT["ADD_DOWNLOAD_EXTENSIONS"] = "addDownloadExtensions";
TRACK_EVENT["REMOVE_DOWNLOAD_EXTENSIONS"] = "removeDownloadExtensions";
TRACK_EVENT["SET_LINK_TRACKING_TIMER"] = "setLinkTrackingTimer";
TRACK_EVENT["SET_USER_ID"] = "setUserId";
TRACK_EVENT["RESET_USER_ID"] = "resetUserId";
TRACK_EVENT["SET_USER_IS_ANONYMOUS"] = "setUserIsAnonymous";
TRACK_EVENT["DEANONYMIZE_USER"] = "deanonymizeUser";
TRACK_EVENT["SET_SESSION_ID_STRICT_PRIVACY_MODE"] = "setSessionIdStrictPrivacyMode";
TRACK_EVENT["DISABLE_COOKIES"] = "disableCookies";
TRACK_EVENT["ENABLE_COOKIES"] = "enableCookies";
TRACK_EVENT["DELETE_COOKIES"] = "deleteCookies";
TRACK_EVENT["SET_COOKIE_NAME_PREFIX"] = "setCookieNamePrefix";
TRACK_EVENT["SET_COOKIE_DOMAIN"] = "setCookieDomain";
TRACK_EVENT["SET_COOKIE_PATH"] = "setCookiePath";
TRACK_EVENT["SET_SECURE_COOKIE"] = "setSecureCookie";
TRACK_EVENT["SET_VISITOR_COOKIE_TIMEOUT"] = "setVisitorCookieTimeout";
TRACK_EVENT["SET_SESSION_COOKIE_TIMEOUT"] = "setSessionCookieTimeout";
TRACK_EVENT["SET_VISITOR_ID_COOKIE"] = "setVisitorIdCookie";
TRACK_EVENT["SET_DOCUMENT_TITLE"] = "setDocumentTitle";
TRACK_EVENT["SET_DOMAINS"] = "setDomains";
TRACK_EVENT["SET_CUSTOM_URL"] = "setCustomUrl";
TRACK_EVENT["SET_REFERRER_URL"] = "setReferrerUrl";
TRACK_EVENT["SET_API_URL"] = "setApiUrl";
TRACK_EVENT["GET_PIWIK_URL"] = "getPiwikUrl";
TRACK_EVENT["GET_CURRENT_URL"] = "getCurrentUrl";
TRACK_EVENT["DISCARD_HASH_TAG"] = "discardHashTag";
TRACK_EVENT["SET_GENERATION_TIME_MS"] = "setGenerationTimeMs";
TRACK_EVENT["APPEND_TO_TRACKING_URL"] = "appendToTrackingUrl";
TRACK_EVENT["SET_DO_NOT_TRACK"] = "setDoNotTrack";
TRACK_EVENT["KILL_FRAME"] = "killFrame";
TRACK_EVENT["REDIRECT_FILE"] = "redirectFile";
TRACK_EVENT["SET_CAMPAIGN_NAME_KEY"] = "setCampaignNameKey";
TRACK_EVENT["SET_CAMPAIGN_KEYWORD_KEY"] = "setCampaignKeywordKey";
TRACK_EVENT["PING"] = "ping";
TRACK_EVENT["ADD_LISTENER"] = "addListener";
TRACK_EVENT["SET_REQUEST_METHOD"] = "setRequestMethod";
TRACK_EVENT["SET_CUSTOM_REQUEST_PROCESSING"] = "setCustomRequestProcessing";
TRACK_EVENT["SET_REQUEST_CONTENT_TYPE"] = "setRequestContentType";
TRACK_EVENT["ENABLE_JS_ERROR_TRACKING"] = "enableJSErrorTracking";
TRACK_EVENT["ERROR"] = "trackError";
TRACK_EVENT["SET_TRACKING_SOURCE"] = "setTrackingSource";
})(TRACK_EVENT || (TRACK_EVENT = {}));
function push(collection) {
if (!window._paq) {
window._paq = [];
}
window._paq.push(["setCustomUrl", window.location.href]);
window._paq.push(["setDocumentTitle", document.title]);
IS_DEBUG && console.log('Push', collection);
return window._paq.push(collection);
}
var PaqService = {
push: push
};
function trackPageView(customPageTitle) {
PaqService.push([TRACK_EVENT.PAGE_VIEW].concat(customPageTitle ? [customPageTitle] : []));
}
var pageViews_service = {
__proto__: null,
trackPageView: trackPageView
};
function trackEvent(category, action, name, value) {
var eventArguments = [category, action].concat(name ? [name] : [], name ? [value] : []);
PaqService.push([TRACK_EVENT.CUSTOM_EVENT].concat(eventArguments));
}
var customEvents_service = {
__proto__: null,
trackEvent: trackEvent
};
function trackAllContentImpressions() {
PaqService.push([TRACK_EVENT.ALL_CONTENT_IMPRESSIONS]);
}
function trackVisibleContentImpressions(checkOnScroll, watchIterval) {
PaqService.push([TRACK_EVENT.VISIBLE_CONTENT_IMPRESSIONS, checkOnScroll, watchIterval]);
}
function trackContentImpressionsWithinNode(domNode) {
PaqService.push([TRACK_EVENT.CONTENT_IMPRESSIONS_WITH_NODE, domNode]);
}
function trackContentImpression(contentName, contentPiece, contentTarget) {
PaqService.push([TRACK_EVENT.CONTENT_IMPRESSION, contentName, contentPiece, contentTarget]);
}
function logAllContentBlocksOnPage() {
PaqService.push([TRACK_EVENT.LOG_ALL_CONTENT_BLOCKS_ON_PAGE]);
}
function trackContentInteractionNode(domNode, contentInteraction) {
PaqService.push([TRACK_EVENT.CONTENT_INTERACTION_NODE, domNode, contentInteraction]);
}
function trackContentInteraction(contentInteraction, contentName, contentPiece, contentTarget) {
PaqService.push([TRACK_EVENT.CONTENT_INTERACTION, contentInteraction, contentName, contentPiece, contentTarget]);
}
var contentTracking_service = {
__proto__: null,
trackAllContentImpressions: trackAllContentImpressions,
trackVisibleContentImpressions: trackVisibleContentImpressions,
trackContentImpressionsWithinNode: trackContentImpressionsWithinNode,
trackContentImpression: trackContentImpression,
logAllContentBlocksOnPage: logAllContentBlocksOnPage,
trackContentInteractionNode: trackContentInteractionNode,
trackContentInteraction: trackContentInteraction
};
function disableCookies() {
PaqService.push([TRACK_EVENT.DISABLE_COOKIES]);
}
function enableCookies() {
PaqService.push([TRACK_EVENT.ENABLE_COOKIES]);
}
function deleteCookies() {
PaqService.push([TRACK_EVENT.DELETE_COOKIES]);
}
function hasCookies() {
return new Promise(function (resolve, reject) {
try {
PaqService.push([function () {
resolve(this.hasCookies());
}]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function setCookieNamePrefix(prefix) {
PaqService.push([TRACK_EVENT.SET_COOKIE_NAME_PREFIX, prefix]);
}
function setCookieDomain(domain) {
PaqService.push([TRACK_EVENT.SET_COOKIE_DOMAIN, domain]);
}
function setCookiePath(path) {
PaqService.push([TRACK_EVENT.SET_COOKIE_PATH, path]);
}
function setSecureCookie(secure) {
PaqService.push([TRACK_EVENT.SET_SECURE_COOKIE, secure]);
}
function setVisitorCookieTimeout(seconds) {
PaqService.push([TRACK_EVENT.SET_VISITOR_COOKIE_TIMEOUT, seconds]);
}
function setSessionCookieTimeout(seconds) {
PaqService.push([TRACK_EVENT.SET_SESSION_COOKIE_TIMEOUT, seconds]);
}
function setVisitorIdCookie() {
PaqService.push([TRACK_EVENT.SET_VISITOR_ID_COOKIE]);
}
var cookieManagement_service = {
__proto__: null,
disableCookies: disableCookies,
enableCookies: enableCookies,
deleteCookies: deleteCookies,
hasCookies: hasCookies,
setCookieNamePrefix: setCookieNamePrefix,
setCookieDomain: setCookieDomain,
setCookiePath: setCookiePath,
setSecureCookie: setSecureCookie,
setVisitorCookieTimeout: setVisitorCookieTimeout,
setSessionCookieTimeout: setSessionCookieTimeout,
setVisitorIdCookie: setVisitorIdCookie
};
function setCustomDimensionValue(customDimensionId, customDimensionValue) {
PaqService.push([TRACK_EVENT.SET_CUSTOM_DIMENSION_VALUE, customDimensionId, customDimensionValue]);
}
function deleteCustomDimension(customDimensionId) {
PaqService.push([TRACK_EVENT.DELETE_CUSTOM_DIMENSION, customDimensionId]);
}
function getCustomDimensionValue(customDimensionId) {
return new Promise(function (resolve, reject) {
try {
PaqService.push([function () {
resolve(this.getCustomDimensionValue(customDimensionId));
}]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
var customDimensions_service = {
__proto__: null,
setCustomDimensionValue: setCustomDimensionValue,
deleteCustomDimension: deleteCustomDimension,
getCustomDimensionValue: getCustomDimensionValue
};
function trackLink(url, linkType, customData, callback) {
PaqService.push([TRACK_EVENT.LINK, url, linkType, customData, callback]);
}
function enableLinkTracking(enable) {
PaqService.push([TRACK_EVENT.ENABLE_LINK_TRACKING, enable]);
}
function setLinkClasses(classes) {
PaqService.push([TRACK_EVENT.SET_LINK_CLASSES, classes]);
}
function setDownloadClasses(classes) {
PaqService.push([TRACK_EVENT.SET_DOWNLOAD_CLASSES, classes]);
}
function setDownloadExtensions(extensions) {
PaqService.push([TRACK_EVENT.SET_DOWNLOAD_EXTENSIONS, extensions]);
}
function addDownloadExtensions(extensions) {
PaqService.push([TRACK_EVENT.ADD_DOWNLOAD_EXTENSIONS, extensions]);
}
function removeDownloadExtensions(extensions) {
PaqService.push([TRACK_EVENT.REMOVE_DOWNLOAD_EXTENSIONS, extensions]);
}
function setLinkTrackingTimer(time) {
PaqService.push([TRACK_EVENT.SET_LINK_TRACKING_TIMER, time]);
}
function getLinkTrackingTimer() {
return new Promise(function (resolve, reject) {
try {
PaqService.push([function () {
resolve(this.getLinkTrackingTimer());
}]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function setIgnoreClasses(classes) {
PaqService.push([TRACK_EVENT.SET_IGNORE_CLASSES, classes]);
}
var downloadAndOutlink_service = {
__proto__: null,
trackLink: trackLink,
enableLinkTracking: enableLinkTracking,
setLinkClasses: setLinkClasses,
setDownloadClasses: setDownloadClasses,
setDownloadExtensions: setDownloadExtensions,
addDownloadExtensions: addDownloadExtensions,
removeDownloadExtensions: removeDownloadExtensions,
setLinkTrackingTimer: setLinkTrackingTimer,
getLinkTrackingTimer: getLinkTrackingTimer,
setIgnoreClasses: setIgnoreClasses
};
function addEcommerceItem(productSKU, productName, productCategory, productPrice, productQuantity) {
PaqService.push([TRACK_EVENT.ADD_ECOMMERCE_ITEM, productSKU, productName, productCategory, productPrice, productQuantity]);
}
function ecommerceAddToCart(products) {
PaqService.push([TRACK_EVENT.ECOMMERCE_ADD_TO_CART, products]);
}
function removeEcommerceItem(productSKU) {
PaqService.push([TRACK_EVENT.REMOVE_ECOMMERCE_ITEM, productSKU]);
}
function ecommerceRemoveFromCart(products) {
PaqService.push([TRACK_EVENT.ECOMMERCE_REMOVE_FROM_CART, products]);
}
function getEcommerceItems() {
return new Promise(function (resolve, reject) {
try {
PaqService.push([function () {
resolve(this.getEcommerceItems());
}]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function trackEcommerceOrder(orderId, orderGrandTotal, orderSubTotal, orderTax, orderShipping, orderDiscount) {
PaqService.push([TRACK_EVENT.TRACK_ECOMMERCE_ORDER, orderId, orderGrandTotal, orderSubTotal, orderTax, orderShipping, orderDiscount]);
}
function ecommerceOrder(products, paymentInformation) {
PaqService.push([TRACK_EVENT.ECOMMERCE_ORDER, products, paymentInformation]);
}
function trackEcommerceCartUpdate(cartAmount) {
PaqService.push([TRACK_EVENT.TRACK_ECOMMERCE_CART_UPDATE, cartAmount]);
}
function ecommerceCartUpdate(products, grandTotal) {
PaqService.push([TRACK_EVENT.ECOMMERCE_CART_UPDATE, products, grandTotal]);
}
function ecommerceProductDetailView(products) {
PaqService.push([TRACK_EVENT.ECOMMERCE_PRODUCT_DETAIL_VIEW, products]);
}
function clearEcommerceCart() {
PaqService.push([TRACK_EVENT.CLEAR_ECOMMERCE_CART]);
}
function setEcommerceView(productSKU, productName, productCategory, productPrice) {
PaqService.push([TRACK_EVENT.SET_ECOMMERCE_VIEW, productSKU, productName, productCategory, productPrice]);
}
var eCommerce_service = {
__proto__: null,
addEcommerceItem: addEcommerceItem,
ecommerceAddToCart: ecommerceAddToCart,
removeEcommerceItem: removeEcommerceItem,
ecommerceRemoveFromCart: ecommerceRemoveFromCart,
getEcommerceItems: getEcommerceItems,
trackEcommerceOrder: trackEcommerceOrder,
ecommerceOrder: ecommerceOrder,
trackEcommerceCartUpdate: trackEcommerceCartUpdate,
ecommerceCartUpdate: ecommerceCartUpdate,
ecommerceProductDetailView: ecommerceProductDetailView,
clearEcommerceCart: clearEcommerceCart,
setEcommerceView: setEcommerceView
};
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function trackGoal(goalId, conversionValue, dimensions) {
PaqService.push([TRACK_EVENT.GOAL, goalId, conversionValue].concat(dimensions ? [_extends({}, dimensions)] : []));
}
var goalConversions_service = {
__proto__: null,
trackGoal: trackGoal
};
function trackSiteSearch(keyword, category, searchCount, dimensions) {
PaqService.push([TRACK_EVENT.SEARCH, keyword, category, searchCount, dimensions]);
}
var siteSearch_service = {
__proto__: null,
trackSiteSearch: trackSiteSearch
};
function getUserId() {
return new Promise(function (resolve, reject) {
try {
PaqService.push([function () {
resolve(this.getUserId());
}]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function setUserId(userId) {
PaqService.push([TRACK_EVENT.SET_USER_ID, userId]);
}
function resetUserId() {
PaqService.push([TRACK_EVENT.RESET_USER_ID]);
}
function getVisitorId() {
return new Promise(function (resolve, reject) {
try {
PaqService.push([function () {
resolve(this.getVisitorId());
}]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function getVisitorInfo() {
return new Promise(function (resolve, reject) {
try {
PaqService.push([function () {
resolve(this.getVisitorInfo());
}]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
var userManagement_service = {
__proto__: null,
getUserId: getUserId,
setUserId: setUserId,
resetUserId: resetUserId,
getVisitorId: getVisitorId,
getVisitorInfo: getVisitorInfo
};
function push$1(data) {
if (!window.dataLayer) {
window.dataLayer = [];
}
IS_DEBUG && console.log('DataLayer push', data);
return window.dataLayer.push(data);
}
var dataLayer_service = {
__proto__: null,
push: push$1
};
var index$1 = {
initialize: index.init
};
exports.ContentTracking = contentTracking_service;
exports.CookieManagement = cookieManagement_service;
exports.CustomDimensions = customDimensions_service;
exports.CustomEvent = customEvents_service;
exports.DataLayer = dataLayer_service;
exports.DownloadAndOutlink = downloadAndOutlink_service;
exports.GoalConversions = goalConversions_service;
exports.PageViews = pageViews_service;
exports.SiteSearch = siteSearch_service;
exports.UserManagement = userManagement_service;
exports.default = index$1;
exports.eCommerce = eCommerce_service;
Object.keys(trackingBaseLibrary).forEach(function (k) {
if (k !== 'default') Object.defineProperty(exports, k, {
enumerable: true,
get: function () {
return trackingBaseLibrary[k];
}
});
});
exports.default = trackingBaseLibrary__default;
//# sourceMappingURL=index.js.map

@@ -1,497 +0,3 @@

function init(containerId, containerUrl, nonce) {
if (!containerId) {
console.error('Empty tracking code for Piwik Pro.');
return;
}
if (!containerUrl) {
console.error('Empty tracking URL for Piwik Pro.');
return;
}
if (!document) {
console.error('Was not possible to access Document interface. Make sure this module is running on a Browser w/ access do Document interface.');
}
var s = document.createElement('script');
s.async = false;
if (nonce) {
s.setAttribute('nonce', nonce);
}
s.text = "(function(window, document, dataLayerName, id) {\nwindow[dataLayerName]=window[dataLayerName]||[],window[dataLayerName].push({start:(new Date).getTime(),event:\"stg.start\"});var scripts=document.getElementsByTagName('script')[0],tags=document.createElement('script');\nfunction 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=/\"}\nvar 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);\nvar qP=[];dataLayerName!==\"dataLayer\"&&qP.push(\"data_layer_name=\"+dataLayerName),isStgDebug&&qP.push(\"stg_debug\");var qPString=qP.length>0?(\"?\"+qP.join(\"&\")):\"\";\ntags.async=!0,tags.src=\"" + containerUrl + "/\"+id+\".js\"+qPString,scripts.parentNode.insertBefore(tags,scripts);\n!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\"]);\n})(window, document, 'dataLayer', '" + containerId + "')";
var head = document.getElementsByTagName('body')[0];
head.appendChild(s);
}
var IS_DEBUG = typeof process !== 'undefined' && process.env.NODE_ENV === 'development' || typeof window !== 'undefined' && window.IS_DEBUG || false;
var index = {
init: init
};
var TRACK_EVENT;
(function (TRACK_EVENT) {
TRACK_EVENT["PAGE_VIEW"] = "trackPageView";
TRACK_EVENT["CUSTOM_EVENT"] = "trackEvent";
TRACK_EVENT["GOAL"] = "trackGoal";
TRACK_EVENT["SEARCH"] = "trackSiteSearch";
TRACK_EVENT["ECOMMERCE_ADD_TO_CART"] = "ecommerceAddToCart";
TRACK_EVENT["ADD_ECOMMERCE_ITEM"] = "addEcommerceItem";
TRACK_EVENT["REMOVE_ECOMMERCE_ITEM"] = "removeEcommerceItem";
TRACK_EVENT["ECOMMERCE_REMOVE_FROM_CART"] = "ecommerceRemoveFromCart";
TRACK_EVENT["ECOMMERCE_PRODUCT_DETAIL_VIEW"] = "ecommerceProductDetailView";
TRACK_EVENT["ECOMMERCE_CART_UPDATE"] = "ecommerceCartUpdate";
TRACK_EVENT["TRACK_ECOMMERCE_CART_UPDATE"] = "trackEcommerceCartUpdate";
TRACK_EVENT["TRACK_ECOMMERCE_ORDER"] = "trackEcommerceOrder";
TRACK_EVENT["ECOMMERCE_ORDER"] = "ecommerceOrder";
TRACK_EVENT["SET_ECOMMERCE_VIEW"] = "setEcommerceView";
TRACK_EVENT["CLEAR_ECOMMERCE_CART"] = "clearEcommerceCart";
TRACK_EVENT["SET_CUSTOM_VARIABLE"] = "setCustomVariable";
TRACK_EVENT["DELETE_CUSTOM_VARIABLE"] = "deleteCustomVariable";
TRACK_EVENT["STORE_CUSTOM_VARIABLES_IN_COOKIE"] = "storeCustomVariablesInCookie";
TRACK_EVENT["SET_CUSTOM_DIMENSION_VALUE"] = "setCustomDimensionValue";
TRACK_EVENT["DELETE_CUSTOM_DIMENSION"] = "deleteCustomDimension";
TRACK_EVENT["SET_CUSTOM_DIMENSION"] = "setCustomDimension";
TRACK_EVENT["ALL_CONTENT_IMPRESSIONS"] = "trackAllContentImpressions";
TRACK_EVENT["VISIBLE_CONTENT_IMPRESSIONS"] = "trackVisibleContentImpressions";
TRACK_EVENT["CONTENT_IMPRESSIONS_WITH_NODE"] = "trackContentImpressionsWithinNode";
TRACK_EVENT["CONTENT_IMPRESSION"] = "trackContentImpression";
TRACK_EVENT["LOG_ALL_CONTENT_BLOCKS_ON_PAGE"] = "logAllContentBlocksOnPage";
TRACK_EVENT["CONTENT_INTERACTION_NODE"] = "trackContentInteractionNode";
TRACK_EVENT["CONTENT_INTERACTION"] = "trackContentInteraction";
TRACK_EVENT["LINK"] = "trackLink";
TRACK_EVENT["ENABLE_LINK_TRACKING"] = "enableLinkTracking";
TRACK_EVENT["SET_IGNORE_CLASSES"] = "setIgnoreClasses";
TRACK_EVENT["SET_LINK_CLASSES"] = "setLinkClasses";
TRACK_EVENT["SET_DOWNLOAD_CLASSES"] = "setDownloadClasses";
TRACK_EVENT["SET_DOWNLOAD_EXTENSIONS"] = "setDownloadExtensions";
TRACK_EVENT["ADD_DOWNLOAD_EXTENSIONS"] = "addDownloadExtensions";
TRACK_EVENT["REMOVE_DOWNLOAD_EXTENSIONS"] = "removeDownloadExtensions";
TRACK_EVENT["SET_LINK_TRACKING_TIMER"] = "setLinkTrackingTimer";
TRACK_EVENT["SET_USER_ID"] = "setUserId";
TRACK_EVENT["RESET_USER_ID"] = "resetUserId";
TRACK_EVENT["SET_USER_IS_ANONYMOUS"] = "setUserIsAnonymous";
TRACK_EVENT["DEANONYMIZE_USER"] = "deanonymizeUser";
TRACK_EVENT["SET_SESSION_ID_STRICT_PRIVACY_MODE"] = "setSessionIdStrictPrivacyMode";
TRACK_EVENT["DISABLE_COOKIES"] = "disableCookies";
TRACK_EVENT["ENABLE_COOKIES"] = "enableCookies";
TRACK_EVENT["DELETE_COOKIES"] = "deleteCookies";
TRACK_EVENT["SET_COOKIE_NAME_PREFIX"] = "setCookieNamePrefix";
TRACK_EVENT["SET_COOKIE_DOMAIN"] = "setCookieDomain";
TRACK_EVENT["SET_COOKIE_PATH"] = "setCookiePath";
TRACK_EVENT["SET_SECURE_COOKIE"] = "setSecureCookie";
TRACK_EVENT["SET_VISITOR_COOKIE_TIMEOUT"] = "setVisitorCookieTimeout";
TRACK_EVENT["SET_SESSION_COOKIE_TIMEOUT"] = "setSessionCookieTimeout";
TRACK_EVENT["SET_VISITOR_ID_COOKIE"] = "setVisitorIdCookie";
TRACK_EVENT["SET_DOCUMENT_TITLE"] = "setDocumentTitle";
TRACK_EVENT["SET_DOMAINS"] = "setDomains";
TRACK_EVENT["SET_CUSTOM_URL"] = "setCustomUrl";
TRACK_EVENT["SET_REFERRER_URL"] = "setReferrerUrl";
TRACK_EVENT["SET_API_URL"] = "setApiUrl";
TRACK_EVENT["GET_PIWIK_URL"] = "getPiwikUrl";
TRACK_EVENT["GET_CURRENT_URL"] = "getCurrentUrl";
TRACK_EVENT["DISCARD_HASH_TAG"] = "discardHashTag";
TRACK_EVENT["SET_GENERATION_TIME_MS"] = "setGenerationTimeMs";
TRACK_EVENT["APPEND_TO_TRACKING_URL"] = "appendToTrackingUrl";
TRACK_EVENT["SET_DO_NOT_TRACK"] = "setDoNotTrack";
TRACK_EVENT["KILL_FRAME"] = "killFrame";
TRACK_EVENT["REDIRECT_FILE"] = "redirectFile";
TRACK_EVENT["SET_CAMPAIGN_NAME_KEY"] = "setCampaignNameKey";
TRACK_EVENT["SET_CAMPAIGN_KEYWORD_KEY"] = "setCampaignKeywordKey";
TRACK_EVENT["PING"] = "ping";
TRACK_EVENT["ADD_LISTENER"] = "addListener";
TRACK_EVENT["SET_REQUEST_METHOD"] = "setRequestMethod";
TRACK_EVENT["SET_CUSTOM_REQUEST_PROCESSING"] = "setCustomRequestProcessing";
TRACK_EVENT["SET_REQUEST_CONTENT_TYPE"] = "setRequestContentType";
TRACK_EVENT["ENABLE_JS_ERROR_TRACKING"] = "enableJSErrorTracking";
TRACK_EVENT["ERROR"] = "trackError";
TRACK_EVENT["SET_TRACKING_SOURCE"] = "setTrackingSource";
})(TRACK_EVENT || (TRACK_EVENT = {}));
function push(collection) {
if (!window._paq) {
window._paq = [];
}
window._paq.push(["setCustomUrl", window.location.href]);
window._paq.push(["setDocumentTitle", document.title]);
IS_DEBUG && console.log('Push', collection);
return window._paq.push(collection);
}
var PaqService = {
push: push
};
function trackPageView(customPageTitle) {
PaqService.push([TRACK_EVENT.PAGE_VIEW].concat(customPageTitle ? [customPageTitle] : []));
}
var pageViews_service = {
__proto__: null,
trackPageView: trackPageView
};
function trackEvent(category, action, name, value) {
var eventArguments = [category, action].concat(name ? [name] : [], name ? [value] : []);
PaqService.push([TRACK_EVENT.CUSTOM_EVENT].concat(eventArguments));
}
var customEvents_service = {
__proto__: null,
trackEvent: trackEvent
};
function trackAllContentImpressions() {
PaqService.push([TRACK_EVENT.ALL_CONTENT_IMPRESSIONS]);
}
function trackVisibleContentImpressions(checkOnScroll, watchIterval) {
PaqService.push([TRACK_EVENT.VISIBLE_CONTENT_IMPRESSIONS, checkOnScroll, watchIterval]);
}
function trackContentImpressionsWithinNode(domNode) {
PaqService.push([TRACK_EVENT.CONTENT_IMPRESSIONS_WITH_NODE, domNode]);
}
function trackContentImpression(contentName, contentPiece, contentTarget) {
PaqService.push([TRACK_EVENT.CONTENT_IMPRESSION, contentName, contentPiece, contentTarget]);
}
function logAllContentBlocksOnPage() {
PaqService.push([TRACK_EVENT.LOG_ALL_CONTENT_BLOCKS_ON_PAGE]);
}
function trackContentInteractionNode(domNode, contentInteraction) {
PaqService.push([TRACK_EVENT.CONTENT_INTERACTION_NODE, domNode, contentInteraction]);
}
function trackContentInteraction(contentInteraction, contentName, contentPiece, contentTarget) {
PaqService.push([TRACK_EVENT.CONTENT_INTERACTION, contentInteraction, contentName, contentPiece, contentTarget]);
}
var contentTracking_service = {
__proto__: null,
trackAllContentImpressions: trackAllContentImpressions,
trackVisibleContentImpressions: trackVisibleContentImpressions,
trackContentImpressionsWithinNode: trackContentImpressionsWithinNode,
trackContentImpression: trackContentImpression,
logAllContentBlocksOnPage: logAllContentBlocksOnPage,
trackContentInteractionNode: trackContentInteractionNode,
trackContentInteraction: trackContentInteraction
};
function disableCookies() {
PaqService.push([TRACK_EVENT.DISABLE_COOKIES]);
}
function enableCookies() {
PaqService.push([TRACK_EVENT.ENABLE_COOKIES]);
}
function deleteCookies() {
PaqService.push([TRACK_EVENT.DELETE_COOKIES]);
}
function hasCookies() {
return new Promise(function (resolve, reject) {
try {
PaqService.push([function () {
resolve(this.hasCookies());
}]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function setCookieNamePrefix(prefix) {
PaqService.push([TRACK_EVENT.SET_COOKIE_NAME_PREFIX, prefix]);
}
function setCookieDomain(domain) {
PaqService.push([TRACK_EVENT.SET_COOKIE_DOMAIN, domain]);
}
function setCookiePath(path) {
PaqService.push([TRACK_EVENT.SET_COOKIE_PATH, path]);
}
function setSecureCookie(secure) {
PaqService.push([TRACK_EVENT.SET_SECURE_COOKIE, secure]);
}
function setVisitorCookieTimeout(seconds) {
PaqService.push([TRACK_EVENT.SET_VISITOR_COOKIE_TIMEOUT, seconds]);
}
function setSessionCookieTimeout(seconds) {
PaqService.push([TRACK_EVENT.SET_SESSION_COOKIE_TIMEOUT, seconds]);
}
function setVisitorIdCookie() {
PaqService.push([TRACK_EVENT.SET_VISITOR_ID_COOKIE]);
}
var cookieManagement_service = {
__proto__: null,
disableCookies: disableCookies,
enableCookies: enableCookies,
deleteCookies: deleteCookies,
hasCookies: hasCookies,
setCookieNamePrefix: setCookieNamePrefix,
setCookieDomain: setCookieDomain,
setCookiePath: setCookiePath,
setSecureCookie: setSecureCookie,
setVisitorCookieTimeout: setVisitorCookieTimeout,
setSessionCookieTimeout: setSessionCookieTimeout,
setVisitorIdCookie: setVisitorIdCookie
};
function setCustomDimensionValue(customDimensionId, customDimensionValue) {
PaqService.push([TRACK_EVENT.SET_CUSTOM_DIMENSION_VALUE, customDimensionId, customDimensionValue]);
}
function deleteCustomDimension(customDimensionId) {
PaqService.push([TRACK_EVENT.DELETE_CUSTOM_DIMENSION, customDimensionId]);
}
function getCustomDimensionValue(customDimensionId) {
return new Promise(function (resolve, reject) {
try {
PaqService.push([function () {
resolve(this.getCustomDimensionValue(customDimensionId));
}]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
var customDimensions_service = {
__proto__: null,
setCustomDimensionValue: setCustomDimensionValue,
deleteCustomDimension: deleteCustomDimension,
getCustomDimensionValue: getCustomDimensionValue
};
function trackLink(url, linkType, customData, callback) {
PaqService.push([TRACK_EVENT.LINK, url, linkType, customData, callback]);
}
function enableLinkTracking(enable) {
PaqService.push([TRACK_EVENT.ENABLE_LINK_TRACKING, enable]);
}
function setLinkClasses(classes) {
PaqService.push([TRACK_EVENT.SET_LINK_CLASSES, classes]);
}
function setDownloadClasses(classes) {
PaqService.push([TRACK_EVENT.SET_DOWNLOAD_CLASSES, classes]);
}
function setDownloadExtensions(extensions) {
PaqService.push([TRACK_EVENT.SET_DOWNLOAD_EXTENSIONS, extensions]);
}
function addDownloadExtensions(extensions) {
PaqService.push([TRACK_EVENT.ADD_DOWNLOAD_EXTENSIONS, extensions]);
}
function removeDownloadExtensions(extensions) {
PaqService.push([TRACK_EVENT.REMOVE_DOWNLOAD_EXTENSIONS, extensions]);
}
function setLinkTrackingTimer(time) {
PaqService.push([TRACK_EVENT.SET_LINK_TRACKING_TIMER, time]);
}
function getLinkTrackingTimer() {
return new Promise(function (resolve, reject) {
try {
PaqService.push([function () {
resolve(this.getLinkTrackingTimer());
}]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function setIgnoreClasses(classes) {
PaqService.push([TRACK_EVENT.SET_IGNORE_CLASSES, classes]);
}
var downloadAndOutlink_service = {
__proto__: null,
trackLink: trackLink,
enableLinkTracking: enableLinkTracking,
setLinkClasses: setLinkClasses,
setDownloadClasses: setDownloadClasses,
setDownloadExtensions: setDownloadExtensions,
addDownloadExtensions: addDownloadExtensions,
removeDownloadExtensions: removeDownloadExtensions,
setLinkTrackingTimer: setLinkTrackingTimer,
getLinkTrackingTimer: getLinkTrackingTimer,
setIgnoreClasses: setIgnoreClasses
};
function addEcommerceItem(productSKU, productName, productCategory, productPrice, productQuantity) {
PaqService.push([TRACK_EVENT.ADD_ECOMMERCE_ITEM, productSKU, productName, productCategory, productPrice, productQuantity]);
}
function ecommerceAddToCart(products) {
PaqService.push([TRACK_EVENT.ECOMMERCE_ADD_TO_CART, products]);
}
function removeEcommerceItem(productSKU) {
PaqService.push([TRACK_EVENT.REMOVE_ECOMMERCE_ITEM, productSKU]);
}
function ecommerceRemoveFromCart(products) {
PaqService.push([TRACK_EVENT.ECOMMERCE_REMOVE_FROM_CART, products]);
}
function getEcommerceItems() {
return new Promise(function (resolve, reject) {
try {
PaqService.push([function () {
resolve(this.getEcommerceItems());
}]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function trackEcommerceOrder(orderId, orderGrandTotal, orderSubTotal, orderTax, orderShipping, orderDiscount) {
PaqService.push([TRACK_EVENT.TRACK_ECOMMERCE_ORDER, orderId, orderGrandTotal, orderSubTotal, orderTax, orderShipping, orderDiscount]);
}
function ecommerceOrder(products, paymentInformation) {
PaqService.push([TRACK_EVENT.ECOMMERCE_ORDER, products, paymentInformation]);
}
function trackEcommerceCartUpdate(cartAmount) {
PaqService.push([TRACK_EVENT.TRACK_ECOMMERCE_CART_UPDATE, cartAmount]);
}
function ecommerceCartUpdate(products, grandTotal) {
PaqService.push([TRACK_EVENT.ECOMMERCE_CART_UPDATE, products, grandTotal]);
}
function ecommerceProductDetailView(products) {
PaqService.push([TRACK_EVENT.ECOMMERCE_PRODUCT_DETAIL_VIEW, products]);
}
function clearEcommerceCart() {
PaqService.push([TRACK_EVENT.CLEAR_ECOMMERCE_CART]);
}
function setEcommerceView(productSKU, productName, productCategory, productPrice) {
PaqService.push([TRACK_EVENT.SET_ECOMMERCE_VIEW, productSKU, productName, productCategory, productPrice]);
}
var eCommerce_service = {
__proto__: null,
addEcommerceItem: addEcommerceItem,
ecommerceAddToCart: ecommerceAddToCart,
removeEcommerceItem: removeEcommerceItem,
ecommerceRemoveFromCart: ecommerceRemoveFromCart,
getEcommerceItems: getEcommerceItems,
trackEcommerceOrder: trackEcommerceOrder,
ecommerceOrder: ecommerceOrder,
trackEcommerceCartUpdate: trackEcommerceCartUpdate,
ecommerceCartUpdate: ecommerceCartUpdate,
ecommerceProductDetailView: ecommerceProductDetailView,
clearEcommerceCart: clearEcommerceCart,
setEcommerceView: setEcommerceView
};
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function trackGoal(goalId, conversionValue, dimensions) {
PaqService.push([TRACK_EVENT.GOAL, goalId, conversionValue].concat(dimensions ? [_extends({}, dimensions)] : []));
}
var goalConversions_service = {
__proto__: null,
trackGoal: trackGoal
};
function trackSiteSearch(keyword, category, searchCount, dimensions) {
PaqService.push([TRACK_EVENT.SEARCH, keyword, category, searchCount, dimensions]);
}
var siteSearch_service = {
__proto__: null,
trackSiteSearch: trackSiteSearch
};
function getUserId() {
return new Promise(function (resolve, reject) {
try {
PaqService.push([function () {
resolve(this.getUserId());
}]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function setUserId(userId) {
PaqService.push([TRACK_EVENT.SET_USER_ID, userId]);
}
function resetUserId() {
PaqService.push([TRACK_EVENT.RESET_USER_ID]);
}
function getVisitorId() {
return new Promise(function (resolve, reject) {
try {
PaqService.push([function () {
resolve(this.getVisitorId());
}]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
function getVisitorInfo() {
return new Promise(function (resolve, reject) {
try {
PaqService.push([function () {
resolve(this.getVisitorInfo());
}]);
} catch (e) {
if (e instanceof ReferenceError) {
reject(e);
}
}
});
}
var userManagement_service = {
__proto__: null,
getUserId: getUserId,
setUserId: setUserId,
resetUserId: resetUserId,
getVisitorId: getVisitorId,
getVisitorInfo: getVisitorInfo
};
function push$1(data) {
if (!window.dataLayer) {
window.dataLayer = [];
}
IS_DEBUG && console.log('DataLayer push', data);
return window.dataLayer.push(data);
}
var dataLayer_service = {
__proto__: null,
push: push$1
};
var index$1 = {
initialize: index.init
};
export default index$1;
export { contentTracking_service as ContentTracking, cookieManagement_service as CookieManagement, customDimensions_service as CustomDimensions, customEvents_service as CustomEvent, dataLayer_service as DataLayer, downloadAndOutlink_service as DownloadAndOutlink, goalConversions_service as GoalConversions, pageViews_service as PageViews, siteSearch_service as SiteSearch, userManagement_service as UserManagement, eCommerce_service as eCommerce };
export * from '@piwikpro/tracking-base-library';
export { default } from '@piwikpro/tracking-base-library';
//# sourceMappingURL=index.modern.js.map

28

package.json
{
"name": "@piwikpro/react-piwik-pro",
"version": "1.3.3",
"version": "2.0.0",
"description": "Piwik PRO tracking library for ReactJS",

@@ -8,2 +8,3 @@ "author": "Piwik Pro Integration Team <integrations@piwik.pro>",

"repository": "https://github.com/PiwikPRO/react-piwik-pro",
"type": "module",
"main": "dist/index.js",

@@ -13,6 +14,7 @@ "module": "dist/index.modern.js",

"engines": {
"node": ">=10"
"node": ">=18"
},
"scripts": {
"build": "microbundle-crl --no-compress --format modern,cjs",
"build:docs": "typedoc && concat-md docs_raw > README.md && node scripts/postProcessDocs.js",
"start": "microbundle-crl watch --no-compress --format modern,cjs",

@@ -26,3 +28,6 @@ "prepare": "run-s build",

"predeploy": "cd example && yarn install && yarn run build",
"deploy": "gh-pages -d example/build"
"deploy": "gh-pages -d example/build",
"format": "prettier src/**/*.ts --list-different",
"format:fix": "npm run format -- --write",
"typecheck": "tsc --noEmit"
},

@@ -45,13 +50,5 @@ "peerDependencies": {

"babel-eslint": "^10.1.0",
"concat-md": "^0.5.1",
"cross-env": "^7.0.3",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard": "^17.1.0",
"eslint-config-standard-react": "^13.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-standard": "^5.0.0",
"gh-pages": "^6.1.1",

@@ -63,2 +60,4 @@ "microbundle-crl": "^0.13.11",

"react-scripts": "^5.0.1",
"typedoc": "^0.25.13",
"typedoc-plugin-markdown": "^3.17.1",
"typescript": "^5.3.3"

@@ -68,3 +67,6 @@ },

"dist"
]
],
"dependencies": {
"@piwikpro/tracking-base-library": "^1.1.1"
}
}

@@ -0,1 +1,5 @@

<a name="readmemd"></a>
# Piwik PRO Library for React

@@ -5,22 +9,2 @@

* [Installation](#installation)
* [NPM](#npm)
* [Basic setup](#basic-setup)
[comment]: <> ( * [Routing setup]&#40;#set-up-the-pageviews&#41;)
* [Piwik PRO Services](#piwik-pro-services)
* [Custom Events](#send-custom-events)
* [Page Views](#send-page-views-and-virtual-page-views)
* [API](#api)
* [Page Views Service](#page-views-service)
* [User Management](#user-management)
* [Custom Event](#custom-event)
* [Site search Service](#site-search-service)
* [E-Commerce Service](#e-commerce-service)
* [Content Tracking Service](#content-tracking-service)
* [Download and outlink Service](#download-and-outlink-service)
* [Goal Conversions](#goal-conversions)
* [Custom Dimensions](#custom-dimensions)
* [DataLayer Service](#data-layer)
## Installation

@@ -36,3 +20,2 @@

### Basic setup

@@ -66,27 +49,2 @@

[comment]: <> (### Set up the PageViews)
[comment]: <> (Page view is the most basic type of the tracked event. It represents a single page viewing action. We provide a hooks perform automatic page views every time your application navigates to another page.)
[comment]: <> (Add ```useTrackPageViews&#40;&#41;``` to the component of your application.)
[comment]: <> (```ts)
[comment]: <> (import { useTrackPageViews } from '@piwikpro/react-piwik-pro';)
[comment]: <> (...)
[comment]: <> (const App = &#40;&#41; => {)
[comment]: <> ( useTrackPageViews&#40;&#41;;)
[comment]: <> ( return ...;)
[comment]: <> (})
[comment]: <> (export default App)
[comment]: <> (```)
## Piwik PRO Services

@@ -151,124 +109,1246 @@

## API
### Initialize
<a name="modulesmd"></a>
```ts
import PiwikPro from '@piwikpro/react-piwik-pro';
```
#### Methods
* initialize(containerId: string, containerUrl:string, nonce?: string) - initialisation of the library
### Page Views Service
A page view is the most basic type of a tracked event. It represents a single page viewing action.
#### Import
```ts
import { PageViews } from '@piwikpro/react-piwik-pro'
```
#### Methods
* `trackPageView(customPageTitle?: string)` - Tracks a visit on the page that the function was run on.
### User Management
#### Import
```ts
import { UserManagement } from '@piwikpro/react-piwik-pro'
```
#### Methods
* `getUserId()` - The function that will return user ID.
* `setUserId(userId: string)` - user ID is an additional parameter that allows you to aggregate data. When set up, you will be able to search through sessions by this parameter, filter reports through it or create Multi attribution reports using User ID.
* `resetUserId()` - Clears previously set `userID`, e.g. when visitor logs out.
* `getVisitorId()` - Returns 16-character hex ID of the visitor.
* `getVisitorInfo()` - Returns visitor information in an array:
* new visitor flag indicating new (1) or returning (0) visitor
* visitor ID (UUID)
* first visit timestamp (Unix epoch time)
* previous visit count (0 for first visit)
* current visit timestamp (Unix epoch time)
* last visit timestamp (Unix epoch time or '' if N/A)
* last e-commerce order timestamp (Unix epoch time or '' if N/A)
## Table of contents
### Custom Event
Custom events enable tracking visitor actions that are not predefined in the existing [JavaScript Tracking Client API](https://developers.piwik.pro/en/latest/data_collection/web/javascript_tracking_client/api.html), allowing web analysts to accurately measure and analyze any domain.
#### Import
```ts
import { CustomEvent } from '@piwikpro/react-piwik-pro'
```
#### Methods
* `trackEvent(category: string, action: string, name?: string, value?: number) ` - Tracks a custom event, e.g. when a visitor interacts with the page.
### Namespaces
### Site search Service
Site search tracking gives you insights into how visitors interact with the search engine on your website - what they search for and how many results they get back.
#### Import
```ts
import { SiteSearch } from '@piwikpro/react-piwik-pro'
```
#### Methods
* `trackSiteSearch(keyword: string, category?: string, searchCount?: number, dimensions?: Object)` - Tracks search requests on a website.
- [ContentTracking](#modulescontenttrackingmd)
- [CookieManagement](#modulescookiemanagementmd)
- [CustomDimensions](#modulescustomdimensionsmd)
- [CustomEvent](#modulescustomeventmd)
- [DataLayer](#modulesdatalayermd)
- [DownloadAndOutlink](#modulesdownloadandoutlinkmd)
- [GoalConversions](#modulesgoalconversionsmd)
- [PageViews](#modulespageviewsmd)
- [SiteSearch](#modulessitesearchmd)
- [UserManagement](#modulesusermanagementmd)
- [eCommerce](#modulesecommercemd)
### E-Commerce Service
#### Import
```ts
import { eCommerce } from '@piwikpro/react-piwik-pro'
```
#### Methods
* `ecommerceAddToCart(products: Product[])` - Tracks action of adding products to a cart.
* `ecommerceRemoveFromCart(products: Product[])` - Tracks action of removing a products from a cart.
* `ecommerceOrder(products: Product[], paymentInformation: PaymentInformation)` - Tracks conversion (including products and payment details).
* `ecommerceCartUpdate(products: Product[], grandTotal: PaymentInformation['grandTotal'])` - Tracks current state of a cart.
* `ecommerceProductDetailView(products: Product[])` - Tracks product or category view. Must be followed by a page view.
### Type Aliases
### Content Tracking Service
Content Tracking lets you track what content is visible on your site and how users interact with it.
#### Import
```ts
import { ContentTracking } from '@piwikpro/react-piwik-pro'
```
### Methods
* `trackContentImpression(contentName: string, contentPiece: string, contentTarget: string)` - Tracks manual content impression event.
* `trackContentInteraction(contentInteraction: string, contentName: string, contentPiece: string, contentTarget: string)` - Tracks manual content interaction event.
- [Dimensions](#dimensions)
- [PaymentInformation](#paymentinformation)
- [Product](#product)
- [VisitorInfo](#visitorinfo)
### Download and outlink Service
#### Import
```ts
import { DownloadAndOutlink } from '@piwikpro/react-piwik-pro'
```
#### Methods
* `trackLink(url: string, linkType: string, customData?: object, callback?: (params: any) => void)` - Manually tracks outlink or download event with provided values.
* `enableLinkTracking(enable: boolean)` - Enables or disables automatic link tracking. If enabled, left, right and middle clicks on links will be treated as opening a link. Opening a links to an external site (different domain) creates an outlink event. Opening a link to a downloadable file creates a download event.
* `setLinkClasses(classes: string[])` - Sets a list of class names that indicate whether a link is an outlink and not download.
* `setDownloadClasses(classes: string[])` - Sets a list of class names that indicate whether a list is a download and not an outlink.
* `setDownloadExtensions(extensions: string[])` - Overwrites the list of file extensions indicating that a link is a download.
* `addDownloadExtensions(extensions: string[])` - Adds new extensions to the download extensions list.
* `removeDownloadExtensions(extensions: string[])` - Removes extensions from the download extensions list.
* `setLinkTrackingTimer(time: number)` - When a visitor produces an events and closes the page immediately afterwards, e.g. when opening a link, the request might get cancelled. To avoid loosing the last event this way, JavaScript Tracking Client will lock the page for a fraction of a second (if wait time hasn’t passed), giving the request time to reach the Collecting & Processing Pipeline.
* `getLinkTrackingTimer()` - Returns lock/wait time after a request set by setLinkTrackingTimer.
* `setIgnoreClasses(classes: string[])` - Set a list of class names that indicate a link should not be tracked.
### Variables
### Goal Conversions
Goals let you define important actions registered in your application and track conversions when the conditions for the action are fulfilled.
#### Import
```ts
import { GoalConversions } from '@piwikpro/react-piwik-pro'
```
#### Methods
* `trackGoal(goalId: number | string, conversionValue: number, dimensions?: Object)` - Tracks manual goal conversion.
- [default](#default)
### Custom Dimensions
#### Import
```ts
import { CustomDimensions } from '@piwikpro/react-piwik-pro'
```
#### Methods
* `setCustomDimensionValue(customDimensionId: string | number, customDimensionValue: string)` - Sets a custom dimension value to be used later.
* `deleteCustomDimension(customDimensionId: string)` - Removes a custom dimension with the specified ID.
* `getCustomDimensionValue(customDimensionId: string | number)` - Returns the value of a custom dimension with the specified ID.
## Type Aliases
### Data Layer
A data layer is a data structure on your site or app where you can store data and access it with tools like Tag Manager. You can include any data you want in your data layer.
#### Import
```ts
import { DataLayer } from '@piwikpro/react-piwik-pro';
```
#### Methods
* `push(dataLayerObject: Object)` - Adds an event to a data layer.
### Dimensions
Ƭ **Dimensions**: `Record`\<\`dimension$\{number}\`, `string`\>
___
### PaymentInformation
Ƭ **PaymentInformation**: `Object`
#### Type declaration
| Name | Type |
| :------ | :------ |
| `discount?` | `number` \| `string` |
| `grandTotal` | `number` \| `string` |
| `orderId` | `string` |
| `shipping?` | `number` \| `string` |
| `subTotal?` | `number` \| `string` |
| `tax?` | `number` \| `string` |
___
### Product
Ƭ **Product**: `Object`
#### Type declaration
| Name | Type |
| :------ | :------ |
| `brand?` | `string` |
| `category?` | `LimitedArrayFiveStrings` |
| `customDimensions?` | `Record`\<`number`, `string`\> |
| `name?` | `string` |
| `price?` | `number` |
| `quantity?` | `number` |
| `sku` | `string` |
| `variant?` | `string` |
___
### VisitorInfo
Ƭ **VisitorInfo**: [isNew: "0" \| "1", visitorId: string, firstVisitTS: number, previousVisitCount: string \| number, currentVisitTS: number, lastVisitTS: number \| "", lastEcommerceOrderTS: number \| ""]
## Variables
### default
• `Const` **default**: `Object`
#### Type declaration
| Name | Type |
| :------ | :------ |
| `getInitScript` | typeof `PiwikPro.getInitScript` |
| `initialize` | typeof `PiwikPro.init` |
<a name="modulescontenttrackingmd"></a>
# ContentTracking
## Table of contents
- [logAllContentBlocksOnPage](#logallcontentblocksonpage)
- [trackAllContentImpressions](#trackallcontentimpressions)
- [trackContentImpression](#trackcontentimpression)
- [trackContentImpressionsWithinNode](#trackcontentimpressionswithinnode)
- [trackContentInteraction](#trackcontentinteraction)
- [trackContentInteractionNode](#trackcontentinteractionnode)
- [trackVisibleContentImpressions](#trackvisiblecontentimpressions)
## Functions
### logAllContentBlocksOnPage
▸ **logAllContentBlocksOnPage**(): `void`
Print all content blocks to the console for debugging purposes
#### Returns
`void`
___
### trackAllContentImpressions
▸ **trackAllContentImpressions**(): `void`
Scans the entire DOM for content blocks and tracks impressions after all page
elements load. It does not send duplicates on repeated calls unless
trackPageView was called in between trackAllContentImpressions invocations
#### Returns
`void`
___
### trackContentImpression
▸ **trackContentImpression**(`contentName`, `contentPiece`, `contentTarget`): `void`
#### Parameters
| Name | Type |
| :------ | :------ |
| `contentName` | `string` |
| `contentPiece` | `string` |
| `contentTarget` | `string` |
#### Returns
`void`
___
### trackContentImpressionsWithinNode
▸ **trackContentImpressionsWithinNode**(`domNode`): `void`
#### Parameters
| Name | Type |
| :------ | :------ |
| `domNode` | `Node` |
#### Returns
`void`
___
### trackContentInteraction
▸ **trackContentInteraction**(`contentInteraction`, `contentName`, `contentPiece`, `contentTarget`): `void`
Tracks manual content interaction event
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `contentInteraction` | `string` | Type of interaction (e.g. "click") |
| `contentName` | `string` | Name of a content block |
| `contentPiece` | `string` | Name of the content that was displayed (e.g. link to an image) |
| `contentTarget` | `string` | Where the content leads to (e.g. URL of some external website) |
#### Returns
`void`
___
### trackContentInteractionNode
▸ **trackContentInteractionNode**(`domNode`, `contentInteraction?`): `void`
Tracks interaction with a block in domNode. Can be called from code placed in onclick attribute
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `domNode` | `Node` | Node marked as content block or containing content blocks. If content block can’t be found, nothing will tracked. |
| `contentInteraction?` | `string` | Name of interaction (e.g. "click") |
#### Returns
`void`
___
### trackVisibleContentImpressions
▸ **trackVisibleContentImpressions**(`checkOnScroll?`, `watchInterval?`): `void`
Scans DOM for all visible content blocks and tracks impressions
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `checkOnScroll?` | `boolean` | Whether to scan for visible content on scroll event |
| `watchInterval?` | `number` | Delay, in milliseconds, between scans for new visible content. Periodic checks can be disabled by passing 0 |
#### Returns
`void`
<a name="modulescookiemanagementmd"></a>
# CookieManagement
## Table of contents
- [deleteCookies](#deletecookies)
- [disableCookies](#disablecookies)
- [enableCookies](#enablecookies)
- [getConfigVisitorCookieTimeout](#getconfigvisitorcookietimeout)
- [getCookieDomain](#getcookiedomain)
- [getCookiePath](#getcookiepath)
- [getSessionCookieTimeout](#getsessioncookietimeout)
- [hasCookies](#hascookies)
- [setCookieDomain](#setcookiedomain)
- [setCookieNamePrefix](#setcookienameprefix)
- [setCookiePath](#setcookiepath)
- [setReferralCookieTimeout](#setreferralcookietimeout)
- [setSecureCookie](#setsecurecookie)
- [setSessionCookieTimeout](#setsessioncookietimeout)
- [setVisitorCookieTimeout](#setvisitorcookietimeout)
- [setVisitorIdCookie](#setvisitoridcookie)
## Functions
### deleteCookies
▸ **deleteCookies**(): `void`
Deletes existing tracking cookies on the next page view
#### Returns
`void`
___
### disableCookies
▸ **disableCookies**(): `void`
Disables all first party cookies. Existing cookies will be deleted in the next page view
#### Returns
`void`
___
### enableCookies
▸ **enableCookies**(): `void`
Enables all first party cookies. Cookies will be created on the next tracking request
#### Returns
`void`
___
### getConfigVisitorCookieTimeout
▸ **getConfigVisitorCookieTimeout**(): `Promise`\<`number`\>
Returns expiration time of visitor cookies (in milliseconds)
#### Returns
`Promise`\<`number`\>
___
### getCookieDomain
▸ **getCookieDomain**(): `Promise`\<`string`\>
Returns domain of the analytics tracking cookies (set with setCookieDomain()).
#### Returns
`Promise`\<`string`\>
___
### getCookiePath
▸ **getCookiePath**(): `Promise`\<`string`\>
Returns the analytics tracking cookies path
#### Returns
`Promise`\<`string`\>
___
### getSessionCookieTimeout
▸ **getSessionCookieTimeout**(): `Promise`\<`number`\>
Returns expiration time of session cookies
#### Returns
`Promise`\<`number`\>
___
### hasCookies
▸ **hasCookies**(): `Promise`\<`boolean`\>
Returns true if cookies are enabled in this browser
#### Returns
`Promise`\<`boolean`\>
___
### setCookieDomain
▸ **setCookieDomain**(`domain`): `void`
Sets the domain for the analytics tracking cookies
#### Parameters
| Name | Type |
| :------ | :------ |
| `domain` | `string` |
#### Returns
`void`
___
### setCookieNamePrefix
▸ **setCookieNamePrefix**(`prefix`): `void`
Sets the prefix for analytics tracking cookies. Default is "_pk_".
#### Parameters
| Name | Type |
| :------ | :------ |
| `prefix` | `string` |
#### Returns
`void`
___
### setCookiePath
▸ **setCookiePath**(`path`): `void`
Sets the analytics tracking cookies path
#### Parameters
| Name | Type |
| :------ | :------ |
| `path` | `string` |
#### Returns
`void`
___
### setReferralCookieTimeout
▸ **setReferralCookieTimeout**(`seconds`): `void`
Sets the expiration time of referral cookies
#### Parameters
| Name | Type |
| :------ | :------ |
| `seconds` | `number` |
#### Returns
`void`
___
### setSecureCookie
▸ **setSecureCookie**(`secure`): `void`
Toggles the secure cookie flag on all first party cookies (if you are using HTTPS)
#### Parameters
| Name | Type |
| :------ | :------ |
| `secure` | `boolean` |
#### Returns
`void`
___
### setSessionCookieTimeout
▸ **setSessionCookieTimeout**(`seconds`): `void`
Sets the expiration time of session cookies
#### Parameters
| Name | Type |
| :------ | :------ |
| `seconds` | `number` |
#### Returns
`void`
___
### setVisitorCookieTimeout
▸ **setVisitorCookieTimeout**(`seconds`): `void`
Sets the expiration time of visitor cookies
#### Parameters
| Name | Type |
| :------ | :------ |
| `seconds` | `number` |
#### Returns
`void`
___
### setVisitorIdCookie
▸ **setVisitorIdCookie**(): `void`
Sets cookie containing [analytics ID](https://developers.piwik.pro/en/latest/glossary.html#term-analytics-id) in browser
#### Returns
`void`
<a name="modulescustomdimensionsmd"></a>
# CustomDimensions
## Table of contents
- [deleteCustomDimension](#deletecustomdimension)
- [getCustomDimensionValue](#getcustomdimensionvalue)
- [setCustomDimensionValue](#setcustomdimensionvalue)
## Functions
### deleteCustomDimension
▸ **deleteCustomDimension**(`customDimensionId`): `void`
Removes a custom dimension with the specified ID.
#### Parameters
| Name | Type |
| :------ | :------ |
| `customDimensionId` | `string` |
#### Returns
`void`
___
### getCustomDimensionValue
▸ **getCustomDimensionValue**(`customDimensionId`): `Promise`\<`string` \| `undefined`\>
Returns the value of a custom dimension with the specified ID.
#### Parameters
| Name | Type |
| :------ | :------ |
| `customDimensionId` | `string` \| `number` |
#### Returns
`Promise`\<`string` \| `undefined`\>
___
### setCustomDimensionValue
▸ **setCustomDimensionValue**(`customDimensionId`, `customDimensionValue`): `void`
Sets a custom dimension value to be used later.
#### Parameters
| Name | Type |
| :------ | :------ |
| `customDimensionId` | `string` \| `number` |
| `customDimensionValue` | `string` |
#### Returns
`void`
<a name="modulescustomeventmd"></a>
# CustomEvent
## Table of contents
- [trackEvent](#trackevent)
## Functions
### trackEvent
▸ **trackEvent**(`category`, `action`, `name?`, `value?`, `dimensions?`): `void`
Tracks a custom event, e.g. when a visitor interacts with the page
#### Parameters
| Name | Type |
| :------ | :------ |
| `category` | `string` |
| `action` | `string` |
| `name?` | `string` |
| `value?` | `number` |
| `dimensions?` | [`Dimensions`](#dimensions) |
#### Returns
`void`
<a name="modulesdatalayermd"></a>
# DataLayer
## Table of contents
- [push](#push)
## Functions
### push
▸ **push**(`data`): `number`
Adds entry to a data layer
#### Parameters
| Name | Type |
| :------ | :------ |
| `data` | `any` |
#### Returns
`number`
<a name="modulesdownloadandoutlinkmd"></a>
# DownloadAndOutlink
## Table of contents
- [addDownloadExtensions](#adddownloadextensions)
- [enableLinkTracking](#enablelinktracking)
- [getLinkTrackingTimer](#getlinktrackingtimer)
- [removeDownloadExtensions](#removedownloadextensions)
- [setDownloadClasses](#setdownloadclasses)
- [setDownloadExtensions](#setdownloadextensions)
- [setIgnoreClasses](#setignoreclasses)
- [setLinkClasses](#setlinkclasses)
- [setLinkTrackingTimer](#setlinktrackingtimer)
- [trackLink](#tracklink)
## Functions
### addDownloadExtensions
▸ **addDownloadExtensions**(`extensions`): `void`
Adds new extensions to the download extensions list
#### Parameters
| Name | Type |
| :------ | :------ |
| `extensions` | `string`[] |
#### Returns
`void`
___
### enableLinkTracking
▸ **enableLinkTracking**(`trackAlsoMiddleAndRightClicks?`): `void`
Enables automatic link tracking. If called with `true`, left, right and
middle clicks on links will be treated as opening a link. Opening a links to
an external site (different domain) creates an outlink event. Opening a link
to a downloadable file creates a download event
#### Parameters
| Name | Type |
| :------ | :------ |
| `trackAlsoMiddleAndRightClicks?` | `boolean` |
#### Returns
`void`
___
### getLinkTrackingTimer
▸ **getLinkTrackingTimer**(): `Promise`\<`number`\>
Returns lock/wait time after a request set by setLinkTrackingTimer
#### Returns
`Promise`\<`number`\>
___
### removeDownloadExtensions
▸ **removeDownloadExtensions**(`extensions`): `void`
Removes extensions from the download extensions list
#### Parameters
| Name | Type |
| :------ | :------ |
| `extensions` | `string`[] |
#### Returns
`void`
___
### setDownloadClasses
▸ **setDownloadClasses**(`classes`): `void`
Sets a list of class names that indicate whether a list is a download and not an outlink
#### Parameters
| Name | Type |
| :------ | :------ |
| `classes` | `string`[] |
#### Returns
`void`
___
### setDownloadExtensions
▸ **setDownloadExtensions**(`extensions`): `void`
Overwrites the list of file extensions indicating that a link is a download
#### Parameters
| Name | Type |
| :------ | :------ |
| `extensions` | `string`[] |
#### Returns
`void`
___
### setIgnoreClasses
▸ **setIgnoreClasses**(`classes`): `void`
Set a list of class names that indicate a link should not be tracked
#### Parameters
| Name | Type |
| :------ | :------ |
| `classes` | `string`[] |
#### Returns
`void`
___
### setLinkClasses
▸ **setLinkClasses**(`classes`): `void`
Sets a list of class names that indicate whether a link is an outlink and not download
#### Parameters
| Name | Type |
| :------ | :------ |
| `classes` | `string`[] |
#### Returns
`void`
___
### setLinkTrackingTimer
▸ **setLinkTrackingTimer**(`time`): `void`
When a visitor produces an events and closes the page immediately afterwards,
e.g. when opening a link, the request might get cancelled. To avoid loosing
the last event this way, JavaScript Tracking Client will lock the page for a
fraction of a second (if wait time hasn’t passed), giving the request time to
reach the Collecting & Processing Pipeline
#### Parameters
| Name | Type |
| :------ | :------ |
| `time` | `number` |
#### Returns
`void`
___
### trackLink
▸ **trackLink**(`url`, `linkType`, `dimensions?`, `callback?`): `void`
Manually tracks outlink or download event with provided values
#### Parameters
| Name | Type |
| :------ | :------ |
| `url` | `string` |
| `linkType` | `string` |
| `dimensions?` | [`Dimensions`](#dimensions) |
| `callback?` | () => `void` |
#### Returns
`void`
<a name="modulesgoalconversionsmd"></a>
# GoalConversions
## Table of contents
- [trackGoal](#trackgoal)
## Functions
### trackGoal
▸ **trackGoal**(`goalId`, `conversionValue`, `dimensions?`): `void`
Tracks manual goal conversion
#### Parameters
| Name | Type |
| :------ | :------ |
| `goalId` | `string` \| `number` |
| `conversionValue` | `number` |
| `dimensions?` | [`Dimensions`](#dimensions) |
#### Returns
`void`
<a name="modulespageviewsmd"></a>
# PageViews
## Table of contents
- [trackPageView](#trackpageview)
## Functions
### trackPageView
▸ **trackPageView**(`customPageTitle?`): `void`
Tracks a visit on the page that the function was run on
#### Parameters
| Name | Type |
| :------ | :------ |
| `customPageTitle?` | `string` |
#### Returns
`void`
<a name="modulessitesearchmd"></a>
# SiteSearch
## Table of contents
- [trackSiteSearch](#tracksitesearch)
## Functions
### trackSiteSearch
▸ **trackSiteSearch**(`keyword`, `category?`, `searchCount?`, `dimensions?`): `void`
Tracks search requests on a website
#### Parameters
| Name | Type |
| :------ | :------ |
| `keyword` | `string` |
| `category?` | `string` |
| `searchCount?` | `number` |
| `dimensions?` | [`Dimensions`](#dimensions) |
#### Returns
`void`
<a name="modulesusermanagementmd"></a>
# UserManagement
## Table of contents
- [getUserId](#getuserid)
- [getVisitorId](#getvisitorid)
- [getVisitorInfo](#getvisitorinfo)
- [resetUserId](#resetuserid)
- [setUserId](#setuserid)
## Functions
### getUserId
▸ **getUserId**(): `Promise`\<`string`\>
The function that will return user ID
#### Returns
`Promise`\<`string`\>
___
### getVisitorId
▸ **getVisitorId**(): `Promise`\<`string`\>
Returns 16-character hex ID of the visitor
#### Returns
`Promise`\<`string`\>
___
### getVisitorInfo
▸ **getVisitorInfo**(): `Promise`\<[`VisitorInfo`](#visitorinfo)\>
Returns visitor information in an array
#### Returns
`Promise`\<[`VisitorInfo`](#visitorinfo)\>
___
### resetUserId
▸ **resetUserId**(): `void`
Clears previously set userID, e.g. when visitor logs out
#### Returns
`void`
___
### setUserId
▸ **setUserId**(`userId`): `void`
User ID is an additional parameter that allows you to aggregate data. When
set up, you will be able to search through sessions by this parameter, filter
reports through it or create Multi attribution reports using User ID
#### Parameters
| Name | Type |
| :------ | :------ |
| `userId` | `string` |
#### Returns
`void`
<a name="modulesecommercemd"></a>
# eCommerce
## Table of contents
- [addEcommerceItem](#addecommerceitem)
- [clearEcommerceCart](#clearecommercecart)
- [ecommerceAddToCart](#ecommerceaddtocart)
- [ecommerceCartUpdate](#ecommercecartupdate)
- [ecommerceOrder](#ecommerceorder)
- [ecommerceProductDetailView](#ecommerceproductdetailview)
- [ecommerceRemoveFromCart](#ecommerceremovefromcart)
- [getEcommerceItems](#getecommerceitems)
- [removeEcommerceItem](#removeecommerceitem)
- [setEcommerceView](#setecommerceview)
- [trackEcommerceCartUpdate](#trackecommercecartupdate)
- [trackEcommerceOrder](#trackecommerceorder)
## Functions
### addEcommerceItem
▸ **addEcommerceItem**(`productSKU`, `productName`, `productCategory`, `productPrice`, `productQuantity`): `void`
#### Parameters
| Name | Type |
| :------ | :------ |
| `productSKU` | `string` |
| `productName` | `string` |
| `productCategory` | `string` \| `string`[] |
| `productPrice` | `number` |
| `productQuantity` | `number` |
#### Returns
`void`
**`Deprecated`**
Please use the ecommerceAddToCart instead.
___
### clearEcommerceCart
▸ **clearEcommerceCart**(): `void`
#### Returns
`void`
**`Deprecated`**
___
### ecommerceAddToCart
▸ **ecommerceAddToCart**(`products`): `void`
Tracks action of adding products to a cart
#### Parameters
| Name | Type |
| :------ | :------ |
| `products` | [`Product`](#product)[] |
#### Returns
`void`
___
### ecommerceCartUpdate
▸ **ecommerceCartUpdate**(`products`, `grandTotal`): `void`
Tracks current state of a cart
#### Parameters
| Name | Type |
| :------ | :------ |
| `products` | [`Product`](#product)[] |
| `grandTotal` | `string` \| `number` |
#### Returns
`void`
___
### ecommerceOrder
▸ **ecommerceOrder**(`products`, `paymentInformation`): `void`
Tracks conversion, including products and payment details
#### Parameters
| Name | Type |
| :------ | :------ |
| `products` | [`Product`](#product)[] |
| `paymentInformation` | [`PaymentInformation`](#paymentinformation) |
#### Returns
`void`
___
### ecommerceProductDetailView
▸ **ecommerceProductDetailView**(`products`): `void`
Tracks action of viewing product page
#### Parameters
| Name | Type |
| :------ | :------ |
| `products` | [`Product`](#product)[] |
#### Returns
`void`
___
### ecommerceRemoveFromCart
▸ **ecommerceRemoveFromCart**(`products`): `void`
Tracks action of removing a products from a cart
#### Parameters
| Name | Type |
| :------ | :------ |
| `products` | [`Product`](#product)[] |
#### Returns
`void`
___
### getEcommerceItems
▸ **getEcommerceItems**(): `Promise`\<`object`\>
#### Returns
`Promise`\<`object`\>
**`Deprecated`**
___
### removeEcommerceItem
▸ **removeEcommerceItem**(`productSKU`): `void`
#### Parameters
| Name | Type |
| :------ | :------ |
| `productSKU` | `string` |
#### Returns
`void`
**`Deprecated`**
Please use the ecommerceRemoveFromCart instead.
___
### setEcommerceView
▸ **setEcommerceView**(`productSKU`, `productName?`, `productCategory?`, `productPrice?`): `void`
#### Parameters
| Name | Type |
| :------ | :------ |
| `productSKU` | `string` |
| `productName?` | `string` |
| `productCategory?` | `string`[] |
| `productPrice?` | `string` |
#### Returns
`void`
**`Deprecated`**
___
### trackEcommerceCartUpdate
▸ **trackEcommerceCartUpdate**(`cartAmount`): `void`
#### Parameters
| Name | Type |
| :------ | :------ |
| `cartAmount` | `number` |
#### Returns
`void`
**`Deprecated`**
Please use the ecommerceCartUpdate instead.
___
### trackEcommerceOrder
▸ **trackEcommerceOrder**(`orderId`, `orderGrandTotal`, `orderSubTotal?`, `orderTax?`, `orderShipping?`, `orderDiscount?`): `void`
#### Parameters
| Name | Type |
| :------ | :------ |
| `orderId` | `string` |
| `orderGrandTotal` | `number` |
| `orderSubTotal?` | `number` |
| `orderTax?` | `number` |
| `orderShipping?` | `number` |
| `orderDiscount?` | `number` |
#### Returns
`void`
**`Deprecated`**
Please use the ecommerceOrder instead.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc