@analytics/snowplow
Advanced tools
Comparing version 0.1.1 to 0.2.1
@@ -6,4 +6,24 @@ # Change Log | ||
## [0.2.1](https://github.com/DavidWells/analytics/compare/@analytics/snowplow@0.1.1...@analytics/snowplow@0.2.1) (2020-08-24) | ||
**Note:** Version bump only for package @analytics/snowplow | ||
# [0.2.0](https://github.com/DavidWells/analytics/compare/@analytics/snowplow@0.1.1...@analytics/snowplow@0.2.0) (2020-08-23) | ||
### Features | ||
* Update Snowplow Plugin to support 2.15.0 features ([ee750ff](https://github.com/DavidWells/analytics/commit/ee750ff)), closes [#82](https://github.com/DavidWells/analytics/issues/82) | ||
## 0.1.1 (2020-08-15) | ||
**Note:** Version bump only for package @analytics/snowplow |
@@ -62,55 +62,61 @@ var analyticsSnowplow = (function () { | ||
} | ||
/** | ||
* Snowplow analytics integration | ||
* @link https://getanalytics.io/plugins/snowplow/ | ||
* @link https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/javascript-tracker/ | ||
* @param {Object} pluginConfig - Plugin settings | ||
* @param {string} pluginConfig.scriptSrc - Self-hosted Snowplow sp.js file location | ||
* @param {string} pluginConfig.collectorUrl - The URL to a Snowplow collector | ||
* @param {string} [pluginConfig.name] - The name to identify this instance of the tracker, use if using multiple tracker instances ('snowplow' default) | ||
* @param {Object} [pluginConfig.trackerSettings] - The arg map to pass to the Snowplow Tracker | ||
* @param {string} [pluginConfig.trackerSettings.appId] - The appId to identify this application | ||
* @param {string} [pluginConfig.trackerSettings.platform] - Platform of tracking ("web" default) | ||
* @param {string} [pluginConfig.trackerSettings.cookieDomain] - Domain to set cookie against | ||
* @param {string} [pluginConfig.trackerSettings.discoverRootDomain] - Automatically discover root domain | ||
* @param {string} [pluginConfig.trackerSettings.cookieName] - Prefix for cookies ("_sp_" default) | ||
* @param {string} [pluginConfig.trackerSettings.cookieSameSite] - SameSite cookie setting ("None" default) | ||
* @param {boolean} [pluginConfig.trackerSettings.cookieSecure] - Secure cookie setting (true default) | ||
* @param {boolean} [pluginConfig.trackerSettings.encodeBase64] - Encode JSON objects as Base64 (true default) | ||
* @param {bolean} [pluginConfig.trackerSettings.respectDoNotTrack] - Respect do not track (consider analytics-plugin-do-not-track) (false default) | ||
* @param {number} [pluginConfig.trackerSettings.pageUnloadTimer] - Timeout in ms to block page navigation until buffer is empty (500 default) | ||
* @param {boolean} [pluginConfig.trackerSettings.forceSecureTracker] - Forces requests to be sent https (false default) | ||
* @param {string} [pluginConfig.trackerSettings.eventMethod] - Method to send events, GET, POST, Beacon (POST default) | ||
* @param {number} [pluginConfig.trackerSettings.bufferSize] - Amount of events to buffer before sending (1 default) | ||
* @param {number} [pluginConfig.trackerSettings.maxPostBytes] - Maximum size of POST or Beacon before sending (40000 default) | ||
* @param {string} [pluginConfig.trackerSettings.crossDomainLinker] - function to configure which links to add cross domain linking | ||
* @param {number} [pluginConfig.trackerSettings.cookieLifetime] - Cookie lifetime (63072000 default) | ||
* @param {string} [pluginConfig.trackerSettings.stateStorageStrategy] - Use cookies and/or localstorage ("cookieAndLocalStorage" default) | ||
* @param {number} [pluginConfig.trackerSettings.maxLocalStorageQueueSize] - Maximum numbers of events to buffer in localstorage to prevent filling local storage (1000 default) | ||
* @param {boolean} [pluginConfig.trackerSettings.resetActivityTrackingOnPageView] - Flag to decide whether to reset page ping timers on virtual page view (true default) | ||
* @param {boolean} [pluginConfig.trackerSettings.connectionTimeout] - The timeout, in milliseconds, before GET and POST requests will timeout (5000 default) (Snowplow JS 2.15.0+) | ||
* @param {string[]} [pluginConfig.trackerSettings.skippedBrowserFeatures] - Array to skip browser feature collection ([] default) (Snowplow JS 2.15.0+) | ||
* @param {(Object|boolean)} [pluginConfig.trackerSettings.anonymousTracking] - Flag to enable anonymous tracking functionality (false default) | ||
* @param {boolean} [pluginConfig.trackerSettings.anonymousTracking.withSessionTracking] - Flag to enable whether to continue tracking sessions in anonymous tracking mode (false default) | ||
* @param {Object} [pluginConfig.trackerSettings.contexts] - The auto contexts for each event | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.webPage] - The webpage context, containing the page view id. (true default) | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.performanceTiming] - Add performance timing information | ||
* @param {(Object|boolean)} [pluginConfig.trackerSettings.contexts.clientHints] - Add Client Hint information (Snowplow JS 2.15.0+) | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.clientHints.includeHighEntropy] - Capture High Entropy Client Hints (Snowplow JS 2.15.0+) | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.gaCookies] - Add gaCookie information | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.geolocation] - Add browser geolocation information | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.optimizelyXSummary] - Add browser geolocation information | ||
* @return {Object} Analytics plugin | ||
* | ||
* @example | ||
* | ||
* // Minimal recommended configuration | ||
* snowplowPlugin({ | ||
* name: 'snowplow', | ||
* scriptSrc: '//*.cloudfront.net/2.15.0/sp.js', | ||
* collectorUrl: 'collector.mysite.com', | ||
* trackerSettings: { | ||
* appId: 'myApp', | ||
* contexts: { | ||
* webPage: true | ||
* } | ||
* } | ||
* }) | ||
*/ | ||
}; | ||
var trackerInstances = {}; | ||
/** | ||
* Snowplow analytics integration | ||
* @link https://getanalytics.io/plugins/snowplow/ | ||
* @link https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/javascript-tracker/ | ||
* @param {Object} pluginConfig - Plugin settings | ||
* @param {string} pluginConfig.scriptSrc - Self-hosted Snowplow sp.js file location | ||
* @param {string} pluginConfig.collectorUrl - The URL to a Snowplow collector | ||
* @param {string} [pluginConfig.name] - The name to identify this instance of the tracker, use if using multiple tracker instances ('snowplow' default) | ||
* @param {Object} [pluginConfig.trackerSettings] - The arg map to pass to the Snowplow Tracker | ||
* @param {string} [pluginConfig.trackerSettings.appId] - The appId to identify this application | ||
* @param {string} [pluginConfig.trackerSettings.platform] - Platform of tracking ("web" default) | ||
* @param {string} [pluginConfig.trackerSettings.cookieDomain] - Domain to set cookie against | ||
* @param {string} [pluginConfig.trackerSettings.discoverRootDomain] - Automatically discover root domain | ||
* @param {string} [pluginConfig.trackerSettings.cookieName] - Prefix for cookies ("_sp_" default) | ||
* @param {string} [pluginConfig.trackerSettings.cookieSameSite] - SameSite cookie setting ("None" default) | ||
* @param {boolean} [pluginConfig.trackerSettings.cookieSecure] - Secure cookie setting (true default) | ||
* @param {boolean} [pluginConfig.trackerSettings.encodeBase64] - Encode JSON objects as Base64 (true default) | ||
* @param {bolean} [pluginConfig.trackerSettings.respectDoNotTrack] - Respect do not track (consider analytics-plugin-do-not-track) (false default) | ||
* @param {number} [pluginConfig.trackerSettings.pageUnloadTimer] - Timeout in ms to block page navigation until buffer is empty (500 default) | ||
* @param {boolean} [pluginConfig.trackerSettings.forceSecureTracker] - Forces requests to be sent https (false default) | ||
* @param {string} [pluginConfig.trackerSettings.eventMethod] - Method to send events, GET, POST, Beacon (POST default) | ||
* @param {number} [pluginConfig.trackerSettings.bufferSize] - Amount of events to buffer before sending (1 default) | ||
* @param {number} [pluginConfig.trackerSettings.maxPostBytes] - Maximum size of POST or Beacon before sending (40000 default) | ||
* @param {string} [pluginConfig.trackerSettings.crossDomainLinker] - function to configure which links to add cross domain linking | ||
* @param {number} [pluginConfig.trackerSettings.cookieLifetime] - Cookie lifetime (63072000 default) | ||
* @param {string} [pluginConfig.trackerSettings.stateStorageStrategy] - Use cookies and/or localstorage ("cookieAndLocalStorage" default) | ||
* @param {number} [pluginConfig.trackerSettings.maxLocalStorageQueueSize] - Maximum numbers of events to buffer in localstorage to prevent filling local storage (1000 default) | ||
* @param {boolean} [pluginConfig.trackerSettings.resetActivityTrackingOnPageView] - Flag to decide whether to reset page ping timers on virtual page view (true default) | ||
* @param {Object} [pluginConfig.trackerSettings.contexts] - The auto contexts for each event | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.webPage] - The webpage context, containing the page view id. (true default) | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.performanceTiming] - Add performance timing information | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.gaCookies] - Add gaCookie information | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.geolocation] - Add browser geolocation information | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.optimizelyXSummary] - Add browser geolocation information | ||
* @return {Object} Analytics plugin | ||
* | ||
* @example | ||
* | ||
* // Minimal recommended configuration | ||
* snowplowPlugin({ | ||
* name: 'snowplow', | ||
* scriptSrc: '//*.cloudfront.net/2.14.0/sp.js', | ||
* collectorUrl: 'collector.mysite.com', | ||
* trackerSettings: { | ||
* appId: 'myApp', | ||
* contexts: { | ||
* webPage: true | ||
* } | ||
* } | ||
* }) | ||
*/ | ||
@@ -161,9 +167,2 @@ function snowplowPlugin$1() { | ||
snowplow('newTracker', name, collectorUrl, trackerSettings); | ||
snowplow(function () { | ||
var tracker = this[name]; | ||
trackerInstances[name] = { | ||
idCookieName: tracker.getCookieName('id'), | ||
sesCookieName: tracker.getCookieName('ses') | ||
}; | ||
}); | ||
}, | ||
@@ -214,19 +213,6 @@ | ||
*/ | ||
reset: function reset(_ref2) { | ||
var instance = _ref2.instance; | ||
var name = config.name, | ||
trackerSettings = config.trackerSettings; | ||
reset: function reset() { | ||
var name = config.name; | ||
if (snowplowNotLoaded()) return; | ||
var opts = { | ||
storage: 'cookie' | ||
}; | ||
if (trackerSettings && trackerSettings.stateStorageStrategy === 'localStorage') { | ||
opts = { | ||
storage: 'localStorage' | ||
}; | ||
} | ||
instance.storage.removeItem(trackerInstances[name].idCookieName, opts); | ||
instance.storage.removeItem(trackerInstances[name].sesCookieName, opts); | ||
snowplow("clearUserData:".concat(name)); | ||
snowplow("setUserId:".concat(name), undefined); | ||
@@ -291,4 +277,4 @@ snowplow("clearGlobalContexts:".concat(name)); | ||
*/ | ||
track: function track(_ref3) { | ||
var payload = _ref3.payload; | ||
track: function track(_ref2) { | ||
var payload = _ref2.payload; | ||
var event = payload.event, | ||
@@ -308,4 +294,4 @@ properties = payload.properties; | ||
*/ | ||
identify: function identify(_ref4) { | ||
var payload = _ref4.payload; | ||
identify: function identify(_ref3) { | ||
var payload = _ref3.payload; | ||
var userId = payload.userId; | ||
@@ -427,2 +413,23 @@ var name = config.name; | ||
snowplow("clearGlobalContexts:".concat(name)); | ||
}, | ||
/** | ||
* Disables Anonymous Tracking | ||
* https://bit.ly/3gjZfNy | ||
* @param {string} stateStorageStrategy - Use to switch storage strategy, or don't use to leave the same | ||
*/ | ||
disableAnonymousTracking: function disableAnonymousTracking(stateStorageStrategy) { | ||
var name = config.name; | ||
snowplow("disableAnonymousTracking:".concat(name), stateStorageStrategy); | ||
}, | ||
/** | ||
* Enables Anonymous Tracking | ||
* https://bit.ly/3gjZfNy | ||
* @param {Object} anonymousTrackingArgs - Configures anonymous tracking features | ||
* @param {boolean} anonymousTrackingArgs.withSessionTracking - Enables session tracking when enabling Anonymous Tracking | ||
*/ | ||
enableAnonymousTracking: function enableAnonymousTracking(anonymousTrackingArgs) { | ||
var name = config.name; | ||
snowplow("enableAnonymousTracking:".concat(name), anonymousTrackingArgs); | ||
} | ||
@@ -429,0 +436,0 @@ } |
@@ -1,1 +0,1 @@ | ||
var analyticsSnowplow=function(){"use strict";function n(n,e){var o=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);e&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),o.push.apply(o,t)}return o}function o(a){for(var e=1;e<arguments.length;e++){var c=null!=arguments[e]?arguments[e]:{};e%2?n(c,!0).forEach(function(e){var n,o,t;n=a,t=c[o=e],o in n?Object.defineProperty(n,o,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[o]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(c)):n(c).forEach(function(e){Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(c,e))})}return a}var t={name:"snowplow",trackerSettings:{contexts:{webPage:!0}}},d={};function c(){return!window.snowplow}return function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},p=o(o({},t),e);return{NAMESPACE:p.name,initialize:function(){var e,n,o,t,a,c,r,i=p.scriptSrc,s=p.collectorUrl,l=p.name,w=p.trackerSettings;if(!i)throw new Error("No Snowplow sp.js location defined");if(!s)throw new Error("No collector url defined");e=window,n=document,o="script",t=i,e[a="snowplow"]||(e.GlobalSnowplowNamespace=e.GlobalSnowplowNamespace||[],e.GlobalSnowplowNamespace.push(a),e[a]=function(){(e[a].q=e[a].q||[]).push(arguments)},e[a].q=e[a].q||[],c=n.createElement(o),r=n.getElementsByTagName(o)[0],c.async=1,c.src=t,r.parentNode.insertBefore(c,r)),snowplow("newTracker",l,s,w),snowplow(function(){var e=this[l];d[l]={idCookieName:e.getCookieName("id"),sesCookieName:e.getCookieName("ses")}})},page:function(e){var n=e.payload.properties,o=p.name;c()||(snowplow("setCustomUrl:".concat(o),n.url),snowplow("setReferrerUrl:".concat(o),n.referrer),snowplow("trackPageView:".concat(o),n.title,n.contexts,n.dynamicContexts))},reset:function(e){var n=e.instance,o=p.name,t=p.trackerSettings;if(!c()){var a={storage:"cookie"};t&&"localStorage"===t.stateStorageStrategy&&(a={storage:"localStorage"}),n.storage.removeItem(d[o].idCookieName,a),n.storage.removeItem(d[o].sesCookieName,a),snowplow("setUserId:".concat(o),void 0),snowplow("clearGlobalContexts:".concat(o))}},track:function(e){var n=e.payload,o=n.event,t=n.properties,a=p.name;c()||function(e,n,o){if(n&&o)switch(n.toLowerCase()){case"selfdescribingevent":case"unstructevent":snowplow("trackSelfDescribingEvent:".concat(e),{schema:o.schema,data:o.data},o.contexts);break;case"socialinteraction":snowplow("trackSocialInteraction:".concat(e),o.action,o.network,o.target,o.contexts);break;case"adimpression":snowplow("trackAdImpression:".concat(e),o.impressionId,o.costModel,o.cost,o.targetUrl,o.bannerId,o.zoneId,o.advertiserId,o.campaignId,o.contexts);break;case"adclick":snowplow("trackAdClick:".concat(e),o.targetUrl,o.clickId,o.costModel,o.cost,o.bannerId,o.zoneId,o.impressionId,o.advertiserId,o.campaignId,o.contexts);break;case"adconversion":snowplow("trackAdConversion:".concat(e),o.conversionId,o.cost,o.category,o.action,o.property,o.initialValue,o.advertiserId,o.costModel,o.campaignId,o.contexts);break;case"linkclick":snowplow("trackLinkClick:".concat(e),o.targetUrl,o.elementId,o.elementClasses,o.elementTarget,o.elementContent,o.contexts);break;case"addtocart":snowplow("trackAddToCart:".concat(e),o.sku,o.name,o.category,o.unitPrice,o.quantity,o.currency,o.contexts);break;case"removefromcart":snowplow("trackRemoveToCart:".concat(e),o.sku,o.name,o.category,o.unitPrice,o.quantity,o.currency,o.contexts);break;case"sitesearch":snowplow("trackSiteSearch:".concat(e),o.searchTerms,o.filters,o.resultsFound,o.resultsDisplayed,o.contexts);break;case"consentgranted":snowplow("trackConsentGranted:".concat(e),o.id,o.version,o.name,o.description,o.expiry,o.contexts);break;case"consentwithdrawn":snowplow("trackConsentWithdrawn:".concat(e),o.all,o.id,o.version,o.name,o.description,o.contexts);break;case"error":snowplow("trackError:".concat(e),o.message,o.filename,o.lineno,o.colno,o.error,o.contexts);break;case"enhancedecommerceactioncontext":snowplow("addEnhancedEcommerceActionContext:".concat(e),o.id,o.affiliation,o.revenue,o.tax,o.shipping,o.coupon,o.list,o.step,o.option,o.currency);break;case"enhancedecommerceimpressioncontext":snowplow("addEnhancedEcommerceImpressionContext:".concat(e),o.id,o.name,o.list,o.brand,o.category,o.variant,o.position,o.price,o.currency);break;case"enhancedecommerceproductcontext":snowplow("addEnhancedEcommerceProductContext:".concat(e),o.id,o.name,o.list,o.brand,o.category,o.variant,o.price,o.quantity,o.coupon,o.position,o.currency);break;case"enhancedecommercepromocontext":snowplow("addEnhancedEcommercePromoContext:".concat(e),o.id,o.name,o.creative,o.position,o.currency);break;case"enhancedecommerceaction":snowplow("trackEnhancedEcommerceAction:".concat(e),o.action);break;case"timing":snowplow("trackTiming:".concat(e),o.category,o.variable,o.timing,o.label,o.contexts);case"structevent":default:snowplow("trackStructEvent:".concat(e),o.category||"All",n||o.action,o.label,o.property,o.value,o.contexts)}}(a,o,t)},identify:function(e){var n=e.payload.userId,o=p.name;c()||n&&snowplow("setUserId:".concat(o),n)},loaded:function(){return!c()},methods:{enableActivityTracking:function(e,n){var o=p.name;snowplow("enableActivityTracking:".concat(o),e,n)},refreshLinkClickTracking:function(){var e=p.name;snowplow("refreshLinkClickTracking:".concat(e))},enableFormTracking:function(e,n){var o=p.name;snowplow("enableFormTracking:".concat(o),e||{},n||null)},enableGdprContext:function(e,n,o,t){var a=p.name;snowplow("enableGdprContext:".concat(a),e,n||null,o||null,t||null)},enableLinkClickTracking:function(e,n,o,t){var a=p.name;snowplow("enableLinkClickTracking:".concat(a),e||{},n||!0,o||!1,t||null)},enableErrorTracking:function(e,n){var o=p.name;snowplow("enableErrorTracking:".concat(o),e||null,n||null)},addGlobalContexts:function(e){var n=p.name,o=e.contexts;e.filterConditions&&(o=[e.filterConditions,o]),snowplow("addGlobalContexts:".concat(n),o)},removeGlobalContexts:function(e){var n=p.name;snowplow("removeGlobalContexts:".concat(n),e)},clearGlobalContexts:function(){var e=p.name;snowplow("clearGlobalContexts:".concat(e))}}}}}(); | ||
var analyticsSnowplow=function(){"use strict";function n(n,e){var o=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);e&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),o.push.apply(o,t)}return o}function o(c){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{};e%2?n(a,!0).forEach(function(e){var n,o,t;n=c,t=a[o=e],o in n?Object.defineProperty(n,o,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[o]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(a)):n(a).forEach(function(e){Object.defineProperty(c,e,Object.getOwnPropertyDescriptor(a,e))})}return c}var t={name:"snowplow",trackerSettings:{contexts:{webPage:!0}}};function a(){return!window.snowplow}return function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},p=o(o({},t),e);return{NAMESPACE:p.name,initialize:function(){var e,n,o,t,c,a,r,s=p.scriptSrc,i=p.collectorUrl,l=p.name,w=p.trackerSettings;if(!s)throw new Error("No Snowplow sp.js location defined");if(!i)throw new Error("No collector url defined");e=window,n=document,o="script",t=s,e[c="snowplow"]||(e.GlobalSnowplowNamespace=e.GlobalSnowplowNamespace||[],e.GlobalSnowplowNamespace.push(c),e[c]=function(){(e[c].q=e[c].q||[]).push(arguments)},e[c].q=e[c].q||[],a=n.createElement(o),r=n.getElementsByTagName(o)[0],a.async=1,a.src=t,r.parentNode.insertBefore(a,r)),snowplow("newTracker",l,i,w)},page:function(e){var n=e.payload.properties,o=p.name;a()||(snowplow("setCustomUrl:".concat(o),n.url),snowplow("setReferrerUrl:".concat(o),n.referrer),snowplow("trackPageView:".concat(o),n.title,n.contexts,n.dynamicContexts))},reset:function(){var e=p.name;a()||(snowplow("clearUserData:".concat(e)),snowplow("setUserId:".concat(e),void 0),snowplow("clearGlobalContexts:".concat(e)))},track:function(e){var n=e.payload,o=n.event,t=n.properties,c=p.name;a()||function(e,n,o){if(n&&o)switch(n.toLowerCase()){case"selfdescribingevent":case"unstructevent":snowplow("trackSelfDescribingEvent:".concat(e),{schema:o.schema,data:o.data},o.contexts);break;case"socialinteraction":snowplow("trackSocialInteraction:".concat(e),o.action,o.network,o.target,o.contexts);break;case"adimpression":snowplow("trackAdImpression:".concat(e),o.impressionId,o.costModel,o.cost,o.targetUrl,o.bannerId,o.zoneId,o.advertiserId,o.campaignId,o.contexts);break;case"adclick":snowplow("trackAdClick:".concat(e),o.targetUrl,o.clickId,o.costModel,o.cost,o.bannerId,o.zoneId,o.impressionId,o.advertiserId,o.campaignId,o.contexts);break;case"adconversion":snowplow("trackAdConversion:".concat(e),o.conversionId,o.cost,o.category,o.action,o.property,o.initialValue,o.advertiserId,o.costModel,o.campaignId,o.contexts);break;case"linkclick":snowplow("trackLinkClick:".concat(e),o.targetUrl,o.elementId,o.elementClasses,o.elementTarget,o.elementContent,o.contexts);break;case"addtocart":snowplow("trackAddToCart:".concat(e),o.sku,o.name,o.category,o.unitPrice,o.quantity,o.currency,o.contexts);break;case"removefromcart":snowplow("trackRemoveToCart:".concat(e),o.sku,o.name,o.category,o.unitPrice,o.quantity,o.currency,o.contexts);break;case"sitesearch":snowplow("trackSiteSearch:".concat(e),o.searchTerms,o.filters,o.resultsFound,o.resultsDisplayed,o.contexts);break;case"consentgranted":snowplow("trackConsentGranted:".concat(e),o.id,o.version,o.name,o.description,o.expiry,o.contexts);break;case"consentwithdrawn":snowplow("trackConsentWithdrawn:".concat(e),o.all,o.id,o.version,o.name,o.description,o.contexts);break;case"error":snowplow("trackError:".concat(e),o.message,o.filename,o.lineno,o.colno,o.error,o.contexts);break;case"enhancedecommerceactioncontext":snowplow("addEnhancedEcommerceActionContext:".concat(e),o.id,o.affiliation,o.revenue,o.tax,o.shipping,o.coupon,o.list,o.step,o.option,o.currency);break;case"enhancedecommerceimpressioncontext":snowplow("addEnhancedEcommerceImpressionContext:".concat(e),o.id,o.name,o.list,o.brand,o.category,o.variant,o.position,o.price,o.currency);break;case"enhancedecommerceproductcontext":snowplow("addEnhancedEcommerceProductContext:".concat(e),o.id,o.name,o.list,o.brand,o.category,o.variant,o.price,o.quantity,o.coupon,o.position,o.currency);break;case"enhancedecommercepromocontext":snowplow("addEnhancedEcommercePromoContext:".concat(e),o.id,o.name,o.creative,o.position,o.currency);break;case"enhancedecommerceaction":snowplow("trackEnhancedEcommerceAction:".concat(e),o.action);break;case"timing":snowplow("trackTiming:".concat(e),o.category,o.variable,o.timing,o.label,o.contexts);case"structevent":default:snowplow("trackStructEvent:".concat(e),o.category||"All",n||o.action,o.label,o.property,o.value,o.contexts)}}(c,o,t)},identify:function(e){var n=e.payload.userId,o=p.name;a()||n&&snowplow("setUserId:".concat(o),n)},loaded:function(){return!a()},methods:{enableActivityTracking:function(e,n){var o=p.name;snowplow("enableActivityTracking:".concat(o),e,n)},refreshLinkClickTracking:function(){var e=p.name;snowplow("refreshLinkClickTracking:".concat(e))},enableFormTracking:function(e,n){var o=p.name;snowplow("enableFormTracking:".concat(o),e||{},n||null)},enableGdprContext:function(e,n,o,t){var c=p.name;snowplow("enableGdprContext:".concat(c),e,n||null,o||null,t||null)},enableLinkClickTracking:function(e,n,o,t){var c=p.name;snowplow("enableLinkClickTracking:".concat(c),e||{},n||!0,o||!1,t||null)},enableErrorTracking:function(e,n){var o=p.name;snowplow("enableErrorTracking:".concat(o),e||null,n||null)},addGlobalContexts:function(e){var n=p.name,o=e.contexts;e.filterConditions&&(o=[e.filterConditions,o]),snowplow("addGlobalContexts:".concat(n),o)},removeGlobalContexts:function(e){var n=p.name;snowplow("removeGlobalContexts:".concat(n),e)},clearGlobalContexts:function(){var e=p.name;snowplow("clearGlobalContexts:".concat(e))},disableAnonymousTracking:function(e){var n=p.name;snowplow("disableAnonymousTracking:".concat(n),e)},enableAnonymousTracking:function(e){var n=p.name;snowplow("enableAnonymousTracking:".concat(n),e)}}}}}(); |
@@ -61,55 +61,61 @@ 'use strict'; | ||
} | ||
/** | ||
* Snowplow analytics integration | ||
* @link https://getanalytics.io/plugins/snowplow/ | ||
* @link https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/javascript-tracker/ | ||
* @param {Object} pluginConfig - Plugin settings | ||
* @param {string} pluginConfig.scriptSrc - Self-hosted Snowplow sp.js file location | ||
* @param {string} pluginConfig.collectorUrl - The URL to a Snowplow collector | ||
* @param {string} [pluginConfig.name] - The name to identify this instance of the tracker, use if using multiple tracker instances ('snowplow' default) | ||
* @param {Object} [pluginConfig.trackerSettings] - The arg map to pass to the Snowplow Tracker | ||
* @param {string} [pluginConfig.trackerSettings.appId] - The appId to identify this application | ||
* @param {string} [pluginConfig.trackerSettings.platform] - Platform of tracking ("web" default) | ||
* @param {string} [pluginConfig.trackerSettings.cookieDomain] - Domain to set cookie against | ||
* @param {string} [pluginConfig.trackerSettings.discoverRootDomain] - Automatically discover root domain | ||
* @param {string} [pluginConfig.trackerSettings.cookieName] - Prefix for cookies ("_sp_" default) | ||
* @param {string} [pluginConfig.trackerSettings.cookieSameSite] - SameSite cookie setting ("None" default) | ||
* @param {boolean} [pluginConfig.trackerSettings.cookieSecure] - Secure cookie setting (true default) | ||
* @param {boolean} [pluginConfig.trackerSettings.encodeBase64] - Encode JSON objects as Base64 (true default) | ||
* @param {bolean} [pluginConfig.trackerSettings.respectDoNotTrack] - Respect do not track (consider analytics-plugin-do-not-track) (false default) | ||
* @param {number} [pluginConfig.trackerSettings.pageUnloadTimer] - Timeout in ms to block page navigation until buffer is empty (500 default) | ||
* @param {boolean} [pluginConfig.trackerSettings.forceSecureTracker] - Forces requests to be sent https (false default) | ||
* @param {string} [pluginConfig.trackerSettings.eventMethod] - Method to send events, GET, POST, Beacon (POST default) | ||
* @param {number} [pluginConfig.trackerSettings.bufferSize] - Amount of events to buffer before sending (1 default) | ||
* @param {number} [pluginConfig.trackerSettings.maxPostBytes] - Maximum size of POST or Beacon before sending (40000 default) | ||
* @param {string} [pluginConfig.trackerSettings.crossDomainLinker] - function to configure which links to add cross domain linking | ||
* @param {number} [pluginConfig.trackerSettings.cookieLifetime] - Cookie lifetime (63072000 default) | ||
* @param {string} [pluginConfig.trackerSettings.stateStorageStrategy] - Use cookies and/or localstorage ("cookieAndLocalStorage" default) | ||
* @param {number} [pluginConfig.trackerSettings.maxLocalStorageQueueSize] - Maximum numbers of events to buffer in localstorage to prevent filling local storage (1000 default) | ||
* @param {boolean} [pluginConfig.trackerSettings.resetActivityTrackingOnPageView] - Flag to decide whether to reset page ping timers on virtual page view (true default) | ||
* @param {boolean} [pluginConfig.trackerSettings.connectionTimeout] - The timeout, in milliseconds, before GET and POST requests will timeout (5000 default) (Snowplow JS 2.15.0+) | ||
* @param {string[]} [pluginConfig.trackerSettings.skippedBrowserFeatures] - Array to skip browser feature collection ([] default) (Snowplow JS 2.15.0+) | ||
* @param {(Object|boolean)} [pluginConfig.trackerSettings.anonymousTracking] - Flag to enable anonymous tracking functionality (false default) | ||
* @param {boolean} [pluginConfig.trackerSettings.anonymousTracking.withSessionTracking] - Flag to enable whether to continue tracking sessions in anonymous tracking mode (false default) | ||
* @param {Object} [pluginConfig.trackerSettings.contexts] - The auto contexts for each event | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.webPage] - The webpage context, containing the page view id. (true default) | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.performanceTiming] - Add performance timing information | ||
* @param {(Object|boolean)} [pluginConfig.trackerSettings.contexts.clientHints] - Add Client Hint information (Snowplow JS 2.15.0+) | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.clientHints.includeHighEntropy] - Capture High Entropy Client Hints (Snowplow JS 2.15.0+) | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.gaCookies] - Add gaCookie information | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.geolocation] - Add browser geolocation information | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.optimizelyXSummary] - Add browser geolocation information | ||
* @return {Object} Analytics plugin | ||
* | ||
* @example | ||
* | ||
* // Minimal recommended configuration | ||
* snowplowPlugin({ | ||
* name: 'snowplow', | ||
* scriptSrc: '//*.cloudfront.net/2.15.0/sp.js', | ||
* collectorUrl: 'collector.mysite.com', | ||
* trackerSettings: { | ||
* appId: 'myApp', | ||
* contexts: { | ||
* webPage: true | ||
* } | ||
* } | ||
* }) | ||
*/ | ||
}; | ||
var trackerInstances = {}; | ||
/** | ||
* Snowplow analytics integration | ||
* @link https://getanalytics.io/plugins/snowplow/ | ||
* @link https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/javascript-tracker/ | ||
* @param {Object} pluginConfig - Plugin settings | ||
* @param {string} pluginConfig.scriptSrc - Self-hosted Snowplow sp.js file location | ||
* @param {string} pluginConfig.collectorUrl - The URL to a Snowplow collector | ||
* @param {string} [pluginConfig.name] - The name to identify this instance of the tracker, use if using multiple tracker instances ('snowplow' default) | ||
* @param {Object} [pluginConfig.trackerSettings] - The arg map to pass to the Snowplow Tracker | ||
* @param {string} [pluginConfig.trackerSettings.appId] - The appId to identify this application | ||
* @param {string} [pluginConfig.trackerSettings.platform] - Platform of tracking ("web" default) | ||
* @param {string} [pluginConfig.trackerSettings.cookieDomain] - Domain to set cookie against | ||
* @param {string} [pluginConfig.trackerSettings.discoverRootDomain] - Automatically discover root domain | ||
* @param {string} [pluginConfig.trackerSettings.cookieName] - Prefix for cookies ("_sp_" default) | ||
* @param {string} [pluginConfig.trackerSettings.cookieSameSite] - SameSite cookie setting ("None" default) | ||
* @param {boolean} [pluginConfig.trackerSettings.cookieSecure] - Secure cookie setting (true default) | ||
* @param {boolean} [pluginConfig.trackerSettings.encodeBase64] - Encode JSON objects as Base64 (true default) | ||
* @param {bolean} [pluginConfig.trackerSettings.respectDoNotTrack] - Respect do not track (consider analytics-plugin-do-not-track) (false default) | ||
* @param {number} [pluginConfig.trackerSettings.pageUnloadTimer] - Timeout in ms to block page navigation until buffer is empty (500 default) | ||
* @param {boolean} [pluginConfig.trackerSettings.forceSecureTracker] - Forces requests to be sent https (false default) | ||
* @param {string} [pluginConfig.trackerSettings.eventMethod] - Method to send events, GET, POST, Beacon (POST default) | ||
* @param {number} [pluginConfig.trackerSettings.bufferSize] - Amount of events to buffer before sending (1 default) | ||
* @param {number} [pluginConfig.trackerSettings.maxPostBytes] - Maximum size of POST or Beacon before sending (40000 default) | ||
* @param {string} [pluginConfig.trackerSettings.crossDomainLinker] - function to configure which links to add cross domain linking | ||
* @param {number} [pluginConfig.trackerSettings.cookieLifetime] - Cookie lifetime (63072000 default) | ||
* @param {string} [pluginConfig.trackerSettings.stateStorageStrategy] - Use cookies and/or localstorage ("cookieAndLocalStorage" default) | ||
* @param {number} [pluginConfig.trackerSettings.maxLocalStorageQueueSize] - Maximum numbers of events to buffer in localstorage to prevent filling local storage (1000 default) | ||
* @param {boolean} [pluginConfig.trackerSettings.resetActivityTrackingOnPageView] - Flag to decide whether to reset page ping timers on virtual page view (true default) | ||
* @param {Object} [pluginConfig.trackerSettings.contexts] - The auto contexts for each event | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.webPage] - The webpage context, containing the page view id. (true default) | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.performanceTiming] - Add performance timing information | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.gaCookies] - Add gaCookie information | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.geolocation] - Add browser geolocation information | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.optimizelyXSummary] - Add browser geolocation information | ||
* @return {Object} Analytics plugin | ||
* | ||
* @example | ||
* | ||
* // Minimal recommended configuration | ||
* snowplowPlugin({ | ||
* name: 'snowplow', | ||
* scriptSrc: '//*.cloudfront.net/2.14.0/sp.js', | ||
* collectorUrl: 'collector.mysite.com', | ||
* trackerSettings: { | ||
* appId: 'myApp', | ||
* contexts: { | ||
* webPage: true | ||
* } | ||
* } | ||
* }) | ||
*/ | ||
@@ -160,9 +166,2 @@ function snowplowPlugin$1() { | ||
snowplow('newTracker', name, collectorUrl, trackerSettings); | ||
snowplow(function () { | ||
var tracker = this[name]; | ||
trackerInstances[name] = { | ||
idCookieName: tracker.getCookieName('id'), | ||
sesCookieName: tracker.getCookieName('ses') | ||
}; | ||
}); | ||
}, | ||
@@ -213,19 +212,6 @@ | ||
*/ | ||
reset: function reset(_ref2) { | ||
var instance = _ref2.instance; | ||
var name = config.name, | ||
trackerSettings = config.trackerSettings; | ||
reset: function reset() { | ||
var name = config.name; | ||
if (snowplowNotLoaded()) return; | ||
var opts = { | ||
storage: 'cookie' | ||
}; | ||
if (trackerSettings && trackerSettings.stateStorageStrategy === 'localStorage') { | ||
opts = { | ||
storage: 'localStorage' | ||
}; | ||
} | ||
instance.storage.removeItem(trackerInstances[name].idCookieName, opts); | ||
instance.storage.removeItem(trackerInstances[name].sesCookieName, opts); | ||
snowplow("clearUserData:".concat(name)); | ||
snowplow("setUserId:".concat(name), undefined); | ||
@@ -290,4 +276,4 @@ snowplow("clearGlobalContexts:".concat(name)); | ||
*/ | ||
track: function track(_ref3) { | ||
var payload = _ref3.payload; | ||
track: function track(_ref2) { | ||
var payload = _ref2.payload; | ||
var event = payload.event, | ||
@@ -307,4 +293,4 @@ properties = payload.properties; | ||
*/ | ||
identify: function identify(_ref4) { | ||
var payload = _ref4.payload; | ||
identify: function identify(_ref3) { | ||
var payload = _ref3.payload; | ||
var userId = payload.userId; | ||
@@ -426,2 +412,23 @@ var name = config.name; | ||
snowplow("clearGlobalContexts:".concat(name)); | ||
}, | ||
/** | ||
* Disables Anonymous Tracking | ||
* https://bit.ly/3gjZfNy | ||
* @param {string} stateStorageStrategy - Use to switch storage strategy, or don't use to leave the same | ||
*/ | ||
disableAnonymousTracking: function disableAnonymousTracking(stateStorageStrategy) { | ||
var name = config.name; | ||
snowplow("disableAnonymousTracking:".concat(name), stateStorageStrategy); | ||
}, | ||
/** | ||
* Enables Anonymous Tracking | ||
* https://bit.ly/3gjZfNy | ||
* @param {Object} anonymousTrackingArgs - Configures anonymous tracking features | ||
* @param {boolean} anonymousTrackingArgs.withSessionTracking - Enables session tracking when enabling Anonymous Tracking | ||
*/ | ||
enableAnonymousTracking: function enableAnonymousTracking(anonymousTrackingArgs) { | ||
var name = config.name; | ||
snowplow("enableAnonymousTracking:".concat(name), anonymousTrackingArgs); | ||
} | ||
@@ -428,0 +435,0 @@ } |
@@ -59,55 +59,61 @@ function _defineProperty(obj, key, value) { | ||
} | ||
/** | ||
* Snowplow analytics integration | ||
* @link https://getanalytics.io/plugins/snowplow/ | ||
* @link https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/javascript-tracker/ | ||
* @param {Object} pluginConfig - Plugin settings | ||
* @param {string} pluginConfig.scriptSrc - Self-hosted Snowplow sp.js file location | ||
* @param {string} pluginConfig.collectorUrl - The URL to a Snowplow collector | ||
* @param {string} [pluginConfig.name] - The name to identify this instance of the tracker, use if using multiple tracker instances ('snowplow' default) | ||
* @param {Object} [pluginConfig.trackerSettings] - The arg map to pass to the Snowplow Tracker | ||
* @param {string} [pluginConfig.trackerSettings.appId] - The appId to identify this application | ||
* @param {string} [pluginConfig.trackerSettings.platform] - Platform of tracking ("web" default) | ||
* @param {string} [pluginConfig.trackerSettings.cookieDomain] - Domain to set cookie against | ||
* @param {string} [pluginConfig.trackerSettings.discoverRootDomain] - Automatically discover root domain | ||
* @param {string} [pluginConfig.trackerSettings.cookieName] - Prefix for cookies ("_sp_" default) | ||
* @param {string} [pluginConfig.trackerSettings.cookieSameSite] - SameSite cookie setting ("None" default) | ||
* @param {boolean} [pluginConfig.trackerSettings.cookieSecure] - Secure cookie setting (true default) | ||
* @param {boolean} [pluginConfig.trackerSettings.encodeBase64] - Encode JSON objects as Base64 (true default) | ||
* @param {bolean} [pluginConfig.trackerSettings.respectDoNotTrack] - Respect do not track (consider analytics-plugin-do-not-track) (false default) | ||
* @param {number} [pluginConfig.trackerSettings.pageUnloadTimer] - Timeout in ms to block page navigation until buffer is empty (500 default) | ||
* @param {boolean} [pluginConfig.trackerSettings.forceSecureTracker] - Forces requests to be sent https (false default) | ||
* @param {string} [pluginConfig.trackerSettings.eventMethod] - Method to send events, GET, POST, Beacon (POST default) | ||
* @param {number} [pluginConfig.trackerSettings.bufferSize] - Amount of events to buffer before sending (1 default) | ||
* @param {number} [pluginConfig.trackerSettings.maxPostBytes] - Maximum size of POST or Beacon before sending (40000 default) | ||
* @param {string} [pluginConfig.trackerSettings.crossDomainLinker] - function to configure which links to add cross domain linking | ||
* @param {number} [pluginConfig.trackerSettings.cookieLifetime] - Cookie lifetime (63072000 default) | ||
* @param {string} [pluginConfig.trackerSettings.stateStorageStrategy] - Use cookies and/or localstorage ("cookieAndLocalStorage" default) | ||
* @param {number} [pluginConfig.trackerSettings.maxLocalStorageQueueSize] - Maximum numbers of events to buffer in localstorage to prevent filling local storage (1000 default) | ||
* @param {boolean} [pluginConfig.trackerSettings.resetActivityTrackingOnPageView] - Flag to decide whether to reset page ping timers on virtual page view (true default) | ||
* @param {boolean} [pluginConfig.trackerSettings.connectionTimeout] - The timeout, in milliseconds, before GET and POST requests will timeout (5000 default) (Snowplow JS 2.15.0+) | ||
* @param {string[]} [pluginConfig.trackerSettings.skippedBrowserFeatures] - Array to skip browser feature collection ([] default) (Snowplow JS 2.15.0+) | ||
* @param {(Object|boolean)} [pluginConfig.trackerSettings.anonymousTracking] - Flag to enable anonymous tracking functionality (false default) | ||
* @param {boolean} [pluginConfig.trackerSettings.anonymousTracking.withSessionTracking] - Flag to enable whether to continue tracking sessions in anonymous tracking mode (false default) | ||
* @param {Object} [pluginConfig.trackerSettings.contexts] - The auto contexts for each event | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.webPage] - The webpage context, containing the page view id. (true default) | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.performanceTiming] - Add performance timing information | ||
* @param {(Object|boolean)} [pluginConfig.trackerSettings.contexts.clientHints] - Add Client Hint information (Snowplow JS 2.15.0+) | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.clientHints.includeHighEntropy] - Capture High Entropy Client Hints (Snowplow JS 2.15.0+) | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.gaCookies] - Add gaCookie information | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.geolocation] - Add browser geolocation information | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.optimizelyXSummary] - Add browser geolocation information | ||
* @return {Object} Analytics plugin | ||
* | ||
* @example | ||
* | ||
* // Minimal recommended configuration | ||
* snowplowPlugin({ | ||
* name: 'snowplow', | ||
* scriptSrc: '//*.cloudfront.net/2.15.0/sp.js', | ||
* collectorUrl: 'collector.mysite.com', | ||
* trackerSettings: { | ||
* appId: 'myApp', | ||
* contexts: { | ||
* webPage: true | ||
* } | ||
* } | ||
* }) | ||
*/ | ||
}; | ||
var trackerInstances = {}; | ||
/** | ||
* Snowplow analytics integration | ||
* @link https://getanalytics.io/plugins/snowplow/ | ||
* @link https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/javascript-tracker/ | ||
* @param {Object} pluginConfig - Plugin settings | ||
* @param {string} pluginConfig.scriptSrc - Self-hosted Snowplow sp.js file location | ||
* @param {string} pluginConfig.collectorUrl - The URL to a Snowplow collector | ||
* @param {string} [pluginConfig.name] - The name to identify this instance of the tracker, use if using multiple tracker instances ('snowplow' default) | ||
* @param {Object} [pluginConfig.trackerSettings] - The arg map to pass to the Snowplow Tracker | ||
* @param {string} [pluginConfig.trackerSettings.appId] - The appId to identify this application | ||
* @param {string} [pluginConfig.trackerSettings.platform] - Platform of tracking ("web" default) | ||
* @param {string} [pluginConfig.trackerSettings.cookieDomain] - Domain to set cookie against | ||
* @param {string} [pluginConfig.trackerSettings.discoverRootDomain] - Automatically discover root domain | ||
* @param {string} [pluginConfig.trackerSettings.cookieName] - Prefix for cookies ("_sp_" default) | ||
* @param {string} [pluginConfig.trackerSettings.cookieSameSite] - SameSite cookie setting ("None" default) | ||
* @param {boolean} [pluginConfig.trackerSettings.cookieSecure] - Secure cookie setting (true default) | ||
* @param {boolean} [pluginConfig.trackerSettings.encodeBase64] - Encode JSON objects as Base64 (true default) | ||
* @param {bolean} [pluginConfig.trackerSettings.respectDoNotTrack] - Respect do not track (consider analytics-plugin-do-not-track) (false default) | ||
* @param {number} [pluginConfig.trackerSettings.pageUnloadTimer] - Timeout in ms to block page navigation until buffer is empty (500 default) | ||
* @param {boolean} [pluginConfig.trackerSettings.forceSecureTracker] - Forces requests to be sent https (false default) | ||
* @param {string} [pluginConfig.trackerSettings.eventMethod] - Method to send events, GET, POST, Beacon (POST default) | ||
* @param {number} [pluginConfig.trackerSettings.bufferSize] - Amount of events to buffer before sending (1 default) | ||
* @param {number} [pluginConfig.trackerSettings.maxPostBytes] - Maximum size of POST or Beacon before sending (40000 default) | ||
* @param {string} [pluginConfig.trackerSettings.crossDomainLinker] - function to configure which links to add cross domain linking | ||
* @param {number} [pluginConfig.trackerSettings.cookieLifetime] - Cookie lifetime (63072000 default) | ||
* @param {string} [pluginConfig.trackerSettings.stateStorageStrategy] - Use cookies and/or localstorage ("cookieAndLocalStorage" default) | ||
* @param {number} [pluginConfig.trackerSettings.maxLocalStorageQueueSize] - Maximum numbers of events to buffer in localstorage to prevent filling local storage (1000 default) | ||
* @param {boolean} [pluginConfig.trackerSettings.resetActivityTrackingOnPageView] - Flag to decide whether to reset page ping timers on virtual page view (true default) | ||
* @param {Object} [pluginConfig.trackerSettings.contexts] - The auto contexts for each event | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.webPage] - The webpage context, containing the page view id. (true default) | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.performanceTiming] - Add performance timing information | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.gaCookies] - Add gaCookie information | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.geolocation] - Add browser geolocation information | ||
* @param {boolean} [pluginConfig.trackerSettings.contexts.optimizelyXSummary] - Add browser geolocation information | ||
* @return {Object} Analytics plugin | ||
* | ||
* @example | ||
* | ||
* // Minimal recommended configuration | ||
* snowplowPlugin({ | ||
* name: 'snowplow', | ||
* scriptSrc: '//*.cloudfront.net/2.14.0/sp.js', | ||
* collectorUrl: 'collector.mysite.com', | ||
* trackerSettings: { | ||
* appId: 'myApp', | ||
* contexts: { | ||
* webPage: true | ||
* } | ||
* } | ||
* }) | ||
*/ | ||
@@ -158,9 +164,2 @@ function snowplowPlugin$1() { | ||
snowplow('newTracker', name, collectorUrl, trackerSettings); | ||
snowplow(function () { | ||
var tracker = this[name]; | ||
trackerInstances[name] = { | ||
idCookieName: tracker.getCookieName('id'), | ||
sesCookieName: tracker.getCookieName('ses') | ||
}; | ||
}); | ||
}, | ||
@@ -211,19 +210,6 @@ | ||
*/ | ||
reset: function reset(_ref2) { | ||
var instance = _ref2.instance; | ||
var name = config.name, | ||
trackerSettings = config.trackerSettings; | ||
reset: function reset() { | ||
var name = config.name; | ||
if (snowplowNotLoaded()) return; | ||
var opts = { | ||
storage: 'cookie' | ||
}; | ||
if (trackerSettings && trackerSettings.stateStorageStrategy === 'localStorage') { | ||
opts = { | ||
storage: 'localStorage' | ||
}; | ||
} | ||
instance.storage.removeItem(trackerInstances[name].idCookieName, opts); | ||
instance.storage.removeItem(trackerInstances[name].sesCookieName, opts); | ||
snowplow("clearUserData:".concat(name)); | ||
snowplow("setUserId:".concat(name), undefined); | ||
@@ -288,4 +274,4 @@ snowplow("clearGlobalContexts:".concat(name)); | ||
*/ | ||
track: function track(_ref3) { | ||
var payload = _ref3.payload; | ||
track: function track(_ref2) { | ||
var payload = _ref2.payload; | ||
var event = payload.event, | ||
@@ -305,4 +291,4 @@ properties = payload.properties; | ||
*/ | ||
identify: function identify(_ref4) { | ||
var payload = _ref4.payload; | ||
identify: function identify(_ref3) { | ||
var payload = _ref3.payload; | ||
var userId = payload.userId; | ||
@@ -424,2 +410,23 @@ var name = config.name; | ||
snowplow("clearGlobalContexts:".concat(name)); | ||
}, | ||
/** | ||
* Disables Anonymous Tracking | ||
* https://bit.ly/3gjZfNy | ||
* @param {string} stateStorageStrategy - Use to switch storage strategy, or don't use to leave the same | ||
*/ | ||
disableAnonymousTracking: function disableAnonymousTracking(stateStorageStrategy) { | ||
var name = config.name; | ||
snowplow("disableAnonymousTracking:".concat(name), stateStorageStrategy); | ||
}, | ||
/** | ||
* Enables Anonymous Tracking | ||
* https://bit.ly/3gjZfNy | ||
* @param {Object} anonymousTrackingArgs - Configures anonymous tracking features | ||
* @param {boolean} anonymousTrackingArgs.withSessionTracking - Enables session tracking when enabling Anonymous Tracking | ||
*/ | ||
enableAnonymousTracking: function enableAnonymousTracking(anonymousTrackingArgs) { | ||
var name = config.name; | ||
snowplow("enableAnonymousTracking:".concat(name), anonymousTrackingArgs); | ||
} | ||
@@ -426,0 +433,0 @@ } |
{ | ||
"name": "@analytics/snowplow", | ||
"version": "0.1.1", | ||
"version": "0.2.1", | ||
"description": "Snowplow integration for 'analytics' module for browser & node", | ||
@@ -60,3 +60,3 @@ "projectMeta": { | ||
}, | ||
"gitHead": "1ed2c1595e9a0a26da46eba425035b04eea6fbcc" | ||
"gitHead": "9d45cc506cb9fa6038967df4985169f8fa22bc9e" | ||
} |
@@ -56,3 +56,3 @@ <!-- | ||
name: 'snowplow', | ||
scriptSrc: '//*.cloudfront.net/2.14.0/sp.js', | ||
scriptSrc: '//*.cloudfront.net/2.15.0/sp.js', | ||
collectorUrl: 'collector.mysite.com', | ||
@@ -180,3 +180,3 @@ trackerSettings: { | ||
name: 'snowplow', | ||
scriptSrc: '//*.cloudfront.net/2.14.0/sp.js', | ||
scriptSrc: '//*.cloudfront.net/2.15.0/sp.js', | ||
collectorUrl: 'collector.mysite.com', | ||
@@ -222,5 +222,11 @@ trackerSettings: { | ||
| `trackerSettings.resetActivityTrackingOnPageView` <br/>_optional_ - boolean| Flag to decide whether to reset page ping timers on virtual page view (true default) | | ||
| `trackerSettings.connectionTimeout` <br/>_optional_ - boolean| The timeout, in milliseconds, before GET and POST requests will timeout (5000 default) (Snowplow JS 2.15.0+) | | ||
| `trackerSettings.skippedBrowserFeatures` <br/>_optional_ - Array.<string>| Array to skip browser feature collection ([] default) (Snowplow JS 2.15.0+) | | ||
| `trackerSettings.anonymousTracking` <br/>_optional_ - Object| Flag to enable anonymous tracking functionality (false default) | | ||
| `trackerSettings.anonymousTracking.withSessionTracking` <br/>_optional_ - boolean| Flag to enable whether to continue tracking sessions in anonymous tracking mode (false default) | | ||
| `trackerSettings.contexts` <br/>_optional_ - Object| The auto contexts for each event | | ||
| `trackerSettings.contexts.webPage` <br/>_optional_ - boolean| The webpage context, containing the page view id. (true default) | | ||
| `trackerSettings.contexts.performanceTiming` <br/>_optional_ - boolean| Add performance timing information | | ||
| `trackerSettings.contexts.clientHints` <br/>_optional_ - Object| Add Client Hint information (Snowplow JS 2.15.0+) | | ||
| `trackerSettings.contexts.clientHints.includeHighEntropy` <br/>_optional_ - boolean| Capture High Entropy Client Hints (Snowplow JS 2.15.0+) | | ||
| `trackerSettings.contexts.gaCookies` <br/>_optional_ - boolean| Add gaCookie information | | ||
@@ -516,3 +522,3 @@ | `trackerSettings.contexts.geolocation` <br/>_optional_ - boolean| Add browser geolocation information | | ||
name: 'snowplow', | ||
scriptSrc: '//*.cloudfront.net/2.14.0/sp.js', | ||
scriptSrc: '//*.cloudfront.net/2.15.0/sp.js', | ||
collectorUrl: 'collector.mysite.com', | ||
@@ -645,3 +651,3 @@ trackerSettings: { | ||
name: 'snowplow', | ||
scriptSrc: '//*.cloudfront.net/2.14.0/sp.js', | ||
scriptSrc: '//*.cloudfront.net/2.15.0/sp.js', | ||
collectorUrl: 'collector.mysite.com', | ||
@@ -648,0 +654,0 @@ trackerSettings: { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
134407
2059
755