From 41a4f16e90158add3869dcdfd3a9ef5905a02d60 Mon Sep 17 00:00:00 2001 From: Fred Blundun Date: Thu, 23 Jul 2015 09:03:17 +0100 Subject: [PATCH 1/7] Bumped version to 2.5.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 91ec7831f..8fecb96d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "snowplow-tracker", - "version": "2.5.0", + "version": "2.5.1", "devDependencies": { "JSON": "~1.0.0", "browser-cookie-lite": "~0.3.1", From 6dfcf3888cb2e1879ed1f20ed08510fe4ac56716 Mon Sep 17 00:00:00 2001 From: Fred Blundun Date: Thu, 23 Jul 2015 09:03:42 +0100 Subject: [PATCH 2/7] Updated detectors test for 2.5.1 --- tests/functional/detectors.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/detectors.js b/tests/functional/detectors.js index e2c58022a..298e73bc8 100644 --- a/tests/functional/detectors.js +++ b/tests/functional/detectors.js @@ -56,8 +56,8 @@ define([ 3528351619, // Chrome 32.0 Mac OS X 2180938465, // Chrome 32.0 Windows NT 3829122699, // Chrome 32.0 Linux - 513142108, // Safari 7.0 Mac - 2651260973 // Safari 6.0.5 Mac + 2694331068, // Safari 7.0 Mac + 2336697549 // Safari 6.0.5 Mac ]; registerSuite({ From ab130207df97e8940e6b2c5477c632bc405f1a79 Mon Sep 17 00:00:00 2001 From: Fred Blundun Date: Thu, 23 Jul 2015 16:26:02 +0100 Subject: [PATCH 3/7] Made page title tracking dynamic (fixes #392) --- src/js/tracker.js | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/js/tracker.js b/src/js/tracker.js index 35a054bff..b991d902d 100644 --- a/src/js/tracker.js +++ b/src/js/tracker.js @@ -126,7 +126,10 @@ configCustomUrl, // Document title - configTitle = documentAlias.title, + lastDocumentTitle = documentAlias.title, + + // Custom title + lastConfigTitle, // Maximum delay to wait for web bug image to be fetched (in milliseconds) configTrackerPause = argmap.hasOwnProperty('pageUnloadTimer') ? argmap.pageUnloadTimer : 500, @@ -854,11 +857,15 @@ */ function logPageView(customTitle, context, contextCallback) { - // Fixup page title. We'll pass this to logPagePing too. - var pageTitle = helpers.fixupTitle(customTitle || configTitle); - refreshUrl(); + // So we know what document.title was at the time of trackPageView + lastDocumentTitle = documentAlias.title; + lastConfigTitle = customTitle; + + // Fixup page title + var pageTitle = helpers.fixupTitle(lastConfigTitle || lastDocumentTitle); + // Log page view core.trackPageView( purify(configCustomUrl || locationHrefAlias), @@ -900,7 +907,7 @@ if ((lastActivityTime + configHeartBeatTimer) > now.getTime()) { // Send ping if minimum visit time has elapsed if (configMinimumVisitTime < now.getTime()) { - logPagePing(pageTitle, finalizeContexts(context, contextCallback)); // Grab the min/max globals + logPagePing(finalizeContexts(context, contextCallback)); // Grab the min/max globals } } }, configHeartBeatTimer); @@ -913,14 +920,18 @@ * Not part of the public API - only called from * logPageView() above. * - * @param string pageTitle The page title to attach to this page ping * @param object context Custom context relating to the event */ - function logPagePing(pageTitle, context) { + function logPagePing(context) { refreshUrl(); + newDocumentTitle = documentAlias.title; + if (newDocumentTitle !== lastDocumentTitle) { + lastDocumentTitle = newDocumentTitle; + lastConfigTitle = null; + } core.trackPagePing( purify(configCustomUrl || locationHrefAlias), - pageTitle, + helpers.fixupTitle(lastConfigTitle || lastDocumentTitle), purify(customReferrer || configReferrerUrl), cleanOffset(minXOffset), cleanOffset(maxXOffset), @@ -1111,7 +1122,9 @@ * @param string title */ setDocumentTitle: function (title) { - configTitle = title; + // So we know what document.title was at the time of trackPageView + lastDocumentTitle = documentAlias.title; + lastConfigTitle = title; }, /** From 272ef30b270c700320ff8f66b4da148e276e9107 Mon Sep 17 00:00:00 2001 From: Fred Blundun Date: Thu, 23 Jul 2015 09:53:43 +0100 Subject: [PATCH 4/7] Fixed prerender detection (fixes #391) --- src/js/tracker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/tracker.js b/src/js/tracker.js index b991d902d..6ab492d55 100644 --- a/src/js/tracker.js +++ b/src/js/tracker.js @@ -1005,7 +1005,7 @@ prefix = prefixes[i]; // does this browser support the page visibility API? - if (Object.prototype.hasOwnProperty.call(documentAlias, prefixPropertyName(prefix, 'hidden'))) { + if (documentAlias[prefixPropertyName(prefix, 'hidden')]) { // if pre-rendered, then defer callback until page visibility changes if (documentAlias[prefixPropertyName(prefix, 'visibilityState')] === 'prerender') { isPreRendered = true; From 3092ac1910f4e21704264dc96ff4608f91e91aba Mon Sep 17 00:00:00 2001 From: Fred Blundun Date: Thu, 23 Jul 2015 13:19:36 +0100 Subject: [PATCH 5/7] Added warning about using a file URL to example pages (closes #397) --- examples/web/async-large.html | 3 ++- examples/web/async-medium.html | 3 ++- examples/web/async-small.html | 5 ++++- examples/web/sync.html | 2 ++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/examples/web/async-large.html b/examples/web/async-large.html index 26da51301..19aee6357 100644 --- a/examples/web/async-large.html +++ b/examples/web/async-large.html @@ -232,7 +232,8 @@

Large_asynchronous_examples_for_snowplow.js

This shows how two users can simultaneously use Snowplow on the same page without any clash

-

Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is not commented out, all tracking will be prevented.

+

Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is enabled, all tracking will be prevented.

+

If you are viewing the page using a file URL, you must edit the script URL in the Snowplow tag to include an http scheme. Otherwise a file scheme will be inferred and the page will attempt to load sp.js from the local filesystem..

Press the buttons below to trigger individual tracking events:


diff --git a/examples/web/async-medium.html b/examples/web/async-medium.html index d6368d6d9..b73838da6 100644 --- a/examples/web/async-medium.html +++ b/examples/web/async-medium.html @@ -172,13 +172,14 @@

Medium_asynchronous_examples_for_snowplow.js

Two tracker namespaces are instantiated on this page.

+

Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is enabled, all tracking will be prevented.

+

If you are viewing the page using a file URL, you must edit the script URL in the Snowplow tag to include an http scheme. Otherwise a file scheme will be inferred and the page will attempt to load sp.js from the local filesystem..

Press the buttons below to trigger individual tracking events:



-

Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is not commented out, all tracking will be prevented.

Both trackers will track this link
Only the cf tracker will track this link diff --git a/examples/web/async-small.html b/examples/web/async-small.html index fb148c8db..2feab2127 100644 --- a/examples/web/async-small.html +++ b/examples/web/async-small.html @@ -149,13 +149,16 @@

Small_asynchronous_examples_for_snowplow.js

+ +

Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is enabled, all tracking will be prevented.

+

If you are viewing the page using a file URL, you must edit the script URL in the Snowplow tag to include an http scheme. Otherwise a file scheme will be inferred and the page will attempt to load sp.js from the local filesystem..

+

Press the buttons below to trigger individual tracking events:



-

Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is not commented out, all tracking will be prevented.

Link
Ignored link diff --git a/examples/web/sync.html b/examples/web/sync.html index 2364d55a8..21b7f3914 100644 --- a/examples/web/sync.html +++ b/examples/web/sync.html @@ -62,6 +62,8 @@

Synchronous examples for snowplow.js

+

Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is enabled, all tracking will be prevented.

+

If you are viewing the page using a file URL, you must edit the script URL in the Snowplow tag to include an http scheme. Otherwise a file scheme will be inferred and the page will attempt to load sp.js from the local filesystem..

Press the buttons below to trigger individual tracking events:


From b1bf7da2a6c15e0e5db847c02a78d026196bfc3c Mon Sep 17 00:00:00 2001 From: Fred Blundun Date: Thu, 23 Jul 2015 16:48:46 +0100 Subject: [PATCH 6/7] Updated examples to use version 2.5.1 --- examples/web/async-large.html | 4 ++-- examples/web/async-medium.html | 2 +- examples/web/async-small.html | 2 +- examples/web/sync.html | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/web/async-large.html b/examples/web/async-large.html index 19aee6357..1d2e73468 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.5.0/sp.js","snowplow_1")); + n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.5.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.5.0/sp.js","snowplow_2")); + n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.5.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 b73838da6..3969af580 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.5.0/sp.js","new_name_here")); + n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.5.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 2feab2127..9eaea35a3 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.5.0/sp.js","snowplow")); + n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.5.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 21b7f3914..94d23f7d1 100644 --- a/examples/web/sync.html +++ b/examples/web/sync.html @@ -19,7 +19,7 @@