From 9eae9d0f3d74d85ad2b9d00c09c724bafe720350 Mon Sep 17 00:00:00 2001 From: mhadam Date: Tue, 29 Jan 2019 18:26:23 -0500 Subject: [PATCH 1/6] Remove chromeFirstPaint from PerformanceTiming context (close #635) --- src/js/tracker.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/js/tracker.js b/src/js/tracker.js index e8b96feb8..21fc1f603 100755 --- a/src/js/tracker.js +++ b/src/js/tracker.js @@ -1004,11 +1004,6 @@ // Old Chrome versions add an unwanted requestEnd field delete performanceTiming.requestEnd; - // Add the Chrome firstPaintTime to the performance if it exists - if (windowAlias.chrome && windowAlias.chrome.loadTimes && typeof windowAlias.chrome.loadTimes().firstPaintTime === 'number') { - performanceTiming.chromeFirstPaint = Math.round(windowAlias.chrome.loadTimes().firstPaintTime * 1000); - } - return { schema: 'iglu:org.w3/PerformanceTiming/jsonschema/1-0-0', data: performanceTiming From 54b9c211e2e11c2c5ec7dd4b345575a03f224165 Mon Sep 17 00:00:00 2001 From: mhadam Date: Tue, 29 Jan 2019 19:07:04 -0500 Subject: [PATCH 2/6] Add flag for disabling stm event parameter (close #705) --- src/js/out_queue.js | 15 +++++++++++---- src/js/tracker.js | 43 +++++++++++++++++++++++++------------------ 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/js/out_queue.js b/src/js/out_queue.js index d780f8d1d..6acdd391c 100644 --- a/src/js/out_queue.js +++ b/src/js/out_queue.js @@ -51,14 +51,16 @@ * @param object mutSnowplowState Gives the pageUnloadGuard a reference to the outbound queue * so it can unload the page when all queues are empty * @param boolean useLocalStorage Whether to use localStorage at all - * @param string eventMethod if null will use 'beacon' otherwise can be set to 'post', 'get', or 'beacon' to force. + * @param string eventMethod if null will use 'beacon' otherwise can be set to 'post', 'get', or 'beacon' to force. + * @param string postPath The path where events are to be posted * @param int bufferSize How many events to batch in localStorage before sending them all. * Only applies when sending POST requests and when localStorage is available. * @param int maxPostBytes Maximum combined size in bytes of the event JSONs in a POST request - * @param string postPath The path where events are to be posted + * @param boolean useStm Whether to add timestamp to events + * * @return object OutQueueManager instance */ - object.OutQueueManager = function (functionName, namespace, mutSnowplowState, useLocalStorage, eventMethod, postPath, bufferSize, maxPostBytes) { + object.OutQueueManager = function (functionName, namespace, mutSnowplowState, useLocalStorage, eventMethod, postPath, bufferSize, maxPostBytes, useStm) { var queueName, executingQueue = false, configCollectorUrl, @@ -316,7 +318,12 @@ executingQueue = false; }; - image.src = configCollectorUrl + nextRequest.replace('?', '?stm=' + new Date().getTime() + '&'); + // note: this currently on applies to GET requests + if (useStm) { + image.src = configCollectorUrl + nextRequest.replace('?', '?stm=' + new Date().getTime() + '&'); + } else { + image.src = configCollectorUrl + nextRequest; + } } } diff --git a/src/js/tracker.js b/src/js/tracker.js index 21fc1f603..3ab6bb092 100755 --- a/src/js/tracker.js +++ b/src/js/tracker.js @@ -79,29 +79,35 @@ * 15. eventMethod, 'beacon' * 16. post, false *DEPRECATED use eventMethod instead* * 17. postPath, null - * 18. bufferSize, 1 - * 19. crossDomainLinker, false - * 20. maxPostBytes, 40000 - * 21. discoverRootDomain, false - * 22. cookieLifetime, 63072000 - * 23. stateStorageStrategy, 'cookieAndLocalStorage' + * 18. useStm, true + * 19. bufferSize, 1 + * 20. crossDomainLinker, false + * 21. maxPostBytes, 40000 + * 22. discoverRootDomain, false + * 23. cookieLifetime, 63072000 + * 24. stateStorageStrategy, 'cookieAndLocalStorage' */ object.Tracker = function Tracker(functionName, namespace, version, mutSnowplowState, argmap) { /************************************************************ * Private members ************************************************************/ - - var argmap = argmap || {}; - - //use POST if that property is present on the argmap - if(argmap.hasOwnProperty('post')) { - argmap.eventMethod = argmap.post === true ? 'post' : 'get'; - } else { - argmap.eventMethod = argmap.eventMethod || 'beacon' - } - - var + + var argmap = argmap || {}; + + //use POST if that property is present on the argmap + if(argmap.hasOwnProperty('post')) { + argmap.eventMethod = argmap.post === true ? 'post' : 'get'; + } else { + argmap.eventMethod = argmap.eventMethod || 'beacon' + } + + // attach stm to GET requests by default + if(!argmap.hasOwnProperty('useStm')) { + argmap.useStm = true; + } + + var // Tracker core core = coreConstructor(true, function(payload) { addBrowserData(payload); @@ -309,7 +315,8 @@ argmap.eventMethod, configPostPath, argmap.bufferSize, - argmap.maxPostBytes || 40000), + argmap.maxPostBytes || 40000, + argmap.useStm), // Flag to prevent the geolocation context being added multiple times geolocationContextAdded = false, From 44ff9faabd4a710abf2cc7e47d21f554ce0ff850 Mon Sep 17 00:00:00 2001 From: mhadam Date: Thu, 31 Jan 2019 17:05:17 -0500 Subject: [PATCH 3/6] Catch Beacon safelist exception for Chrome (close #706) --- src/js/out_queue.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/js/out_queue.js b/src/js/out_queue.js index 6acdd391c..e1f021427 100644 --- a/src/js/out_queue.js +++ b/src/js/out_queue.js @@ -296,7 +296,13 @@ if (useBeacon) { const headers = { type: 'application/json' }; const blob = new Blob([encloseInPayloadDataEnvelope(attachStmToEvent(batch))], headers); - beaconStatus = navigator.sendBeacon(configCollectorUrl, blob); + try { + beaconStatus = navigator.sendBeacon(configCollectorUrl, blob); + } + catch(error) { + beaconStatus = false; + } + } if (!useBeacon || !beaconStatus) { xhr.send(encloseInPayloadDataEnvelope(attachStmToEvent(batch))); From defda78dd365eb5780ff4ae15cc45cd3cbcb6a4a Mon Sep 17 00:00:00 2001 From: mhadam Date: Fri, 1 Feb 2019 11:57:21 -0500 Subject: [PATCH 4/6] Prepared for release --- .gitignore | 2 + CHANGELOG | 8 +- examples/ads/async.html | 6 +- examples/web/async-large.html | 4 +- examples/web/async-medium.html | 2 +- examples/web/async-small.html | 2 +- examples/web/sync.html | 2 +- npm-shrinkwrap.json | 1322 +++++++++++++++++++++++++------- package.json | 2 +- 9 files changed, 1081 insertions(+), 269 deletions(-) diff --git a/.gitignore b/.gitignore index e204a2c1f..24f381f0e 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,5 @@ aws.json VERSION src/js/lib_managed + +.idea/ diff --git a/CHANGELOG b/CHANGELOG index 6d0d7962a..fd60d5564 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,11 @@ +Version 2.10.1 (2019-02-01) +--------------------------- +Catch Beacon safelist exception for Chrome (#706) +Add flag for disabling stm event parameter (#705) +Remove chromeFirstPaint from PerformanceTiming context (#635) + Version 2.10.0 (2019-01-17) --------------------------- +--------------------------- Transpile helpers.js and detectors.js (#693) Allow dynamic context callbacks for link and form tracking (#585) Fix default configOptOutCookie value (#672) diff --git a/examples/ads/async.html b/examples/ads/async.html index 643d3cf0d..3aa1e1b90 100644 --- a/examples/ads/async.html +++ b/examples/ads/async.html @@ -38,7 +38,7 @@

Asynchronous ad tracking examples for snowplow.js

;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[]; p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments) };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1; - n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.10.0/sp.js","adTracker")); + n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.10.1/sp.js","adTracker")); window.adTracker('newTracker', rnd, 'd3rkrsqld9gmqf.cloudfront.net', { 'encodeBase64': false @@ -110,7 +110,7 @@

Asynchronous ad tracking examples for snowplow.js

;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[]; p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments) };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1; - n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.10.0/sp.js","adTracker")); + n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.10.1/sp.js","adTracker")); window.adTracker('newTracker', rnd, 'd3rkrsqld9gmqf.cloudfront.net', { 'encodeBase64': false @@ -141,7 +141,7 @@

Asynchronous ad tracking examples for snowplow.js

;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[]; p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments) };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1; - n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.10.0/sp.js","adTracker")); + n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.10.1/sp.js","adTracker")); window.adTracker('newTracker', rnd, 'd3rkrsqld9gmqf.cloudfront.net', { 'encodeBase64': false diff --git a/examples/web/async-large.html b/examples/web/async-large.html index 6bcbb2149..245579145 100644 --- a/examples/web/async-large.html +++ b/examples/web/async-large.html @@ -23,7 +23,7 @@ ;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[]; p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments) };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1; - n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.10.0/sp.js","snowplow_1")); + n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.10.1/sp.js","snowplow_1")); window.snowplow_1('newTracker', 'cf', 'd3rkrsqld9gmqf.cloudfront.net', { // Initialise a tracker encodeBase64: false, // Default is true @@ -83,7 +83,7 @@ ;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[]; p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments) };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1; - n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.10.0/sp.js","snowplow_2")); + n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.10.1/sp.js","snowplow_2")); window.snowplow_2('newTracker', 'cf', 'd3rkrsqld9gmqf.cloudfront.net', { // Initialise a tracker encodeBase64: false, // Default is true diff --git a/examples/web/async-medium.html b/examples/web/async-medium.html index 2a320eb5b..41f0a8a7b 100644 --- a/examples/web/async-medium.html +++ b/examples/web/async-medium.html @@ -24,7 +24,7 @@ ;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[]; p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments) };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1; - n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.10.0/sp.js","new_name_here")); + n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.10.1/sp.js","new_name_here")); window.new_name_here('newTracker', 'cf', 'd3rkrsqld9gmqf.cloudfront.net', { encodeBase64: false, diff --git a/examples/web/async-small.html b/examples/web/async-small.html index 5770d4316..7095a2d1d 100644 --- a/examples/web/async-small.html +++ b/examples/web/async-small.html @@ -23,7 +23,7 @@ ;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[]; p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments) };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1; - n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.10.0/sp.js","snowplow")); + n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.10.1/sp.js","snowplow")); window.snowplow('newTracker', 'cf', 'd3rkrsqld9gmqf.cloudfront.net', { // Initialise a tracker encodeBase64: false, // Default is true diff --git a/examples/web/sync.html b/examples/web/sync.html index 7a43cd53c..e4bca3cff 100644 --- a/examples/web/sync.html +++ b/examples/web/sync.html @@ -19,7 +19,7 @@