Skip to content

Commit

Permalink
Merge branch 'feature/2.5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
fblundun committed Jul 27, 2015
2 parents b46adf7 + 033a672 commit e16a037
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Version 2.5.1 (2015-07-27)
--------------------------
Fixed prerender detection (#391)
Made page title tracking dynamic (#392)
Added warning about using a file URL to example pages (#397)

Version 2.5.0 (2015-07-22)
--------------------------
Generated a unique session ID for each new session (#347)
Expand Down
7 changes: 4 additions & 3 deletions examples/web/async-large.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -232,7 +232,8 @@
<body>
<h1>Large_asynchronous_examples_for_snowplow.js</h1>
<h2>This shows how two users can simultaneously use Snowplow on the same page without any clash</h2>
<p>Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is not commented out, all tracking will be prevented.</p>
<p>Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is enabled, all tracking will be prevented.</p>
<p>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..</p>
<p>Press the buttons below to trigger individual tracking events:<br>
<button type="button" onclick="playMix()">Play a mix</button><br>
<button type="button" onclick="addProduct()">Add a product</button><br>
Expand Down
5 changes: 3 additions & 2 deletions examples/web/async-medium.html
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -172,13 +172,14 @@
<body>
<h1>Medium_asynchronous_examples_for_snowplow.js</h1>
<p>Two tracker namespaces are instantiated on this page.</p>
<p>Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is enabled, all tracking will be prevented.</p>
<p>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..</p>
<p>Press the buttons below to trigger individual tracking events:<br>
<button type="button" onclick="playMix()">Play a mix</button><br>
<button type="button" onclick="addProduct()">Add a product</button><br>
<button type="button" onclick="viewProduct()">View a product</button><br>
<button type="button" onclick="addEcommerceTransaction()">Add an ecommerce transaction</button>
</p>
<p>Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is not commented out, all tracking will be prevented.</p>
<a href=http://en.wikipedia.org/wiki/Main_Page id=legal class="link out">Both trackers will track this link</a>
<br>
<a href=http://en.wikipedia.org/wiki/Main_Page id=semilegal class="class inbound">Only the cf tracker will track this link</a>
Expand Down
7 changes: 5 additions & 2 deletions examples/web/async-small.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -149,13 +149,16 @@

<body>
<h1>Small_asynchronous_examples_for_snowplow.js</h1>

<p>Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is enabled, all tracking will be prevented.</p>
<p>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..</p>

<p>Press the buttons below to trigger individual tracking events:<br>
<button type="button" onclick="playMix()">Play a mix</button><br>
<button type="button" onclick="addProduct()">Add a product</button><br>
<button type="button" onclick="viewProduct()">View a product</button><br>
<button type="button" onclick="addEcommerceTransaction()">Add an ecommerce transaction</button>
</p>
<p>Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is not commented out, all tracking will be prevented.</p>
<a href=http://en.wikipedia.org/wiki/Main_Page id=legal target="_blank" class="link out">Link</a>
<br>
<a href=http://en.wikipedia.org/wiki/Main_Page id=illegal class="class barred">Ignored link</a>
Expand Down
4 changes: 3 additions & 1 deletion examples/web/sync.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<!-- Snowplow starts plowing -->
<script type="text/javascript">
var spSrc = ('https:' == document.location.protocol ? 'https' : 'http') + '://d1fc8wv8zag5ca.cloudfront.net/2.5.0/sp.js';
var spSrc = ('https:' == document.location.protocol ? 'https' : 'http') + '://d1fc8wv8zag5ca.cloudfront.net/2.5.1/sp.js';
document.write(unescape("%3Cscript src='" + spSrc + "' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
Expand Down Expand Up @@ -62,6 +62,8 @@

<body>
<h1>Synchronous examples for snowplow.js</h1>
<p>Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is enabled, all tracking will be prevented.</p>
<p>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..</p>
<p>Press the buttons below to trigger individual tracking events:<br>
<button type="button" onclick="playMix()">Play a mix</button><br>
<button type="button" onclick="addProduct()">Add a product</button><br>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
33 changes: 23 additions & 10 deletions src/js/tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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);
Expand All @@ -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),
Expand Down Expand Up @@ -994,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;
Expand Down Expand Up @@ -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;
},

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/detectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit e16a037

Please sign in to comment.