Skip to content

Commit e16a037

Browse files
committed
Merge branch 'feature/2.5.1'
2 parents b46adf7 + 033a672 commit e16a037

File tree

8 files changed

+47
-21
lines changed

8 files changed

+47
-21
lines changed

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Version 2.5.1 (2015-07-27)
2+
--------------------------
3+
Fixed prerender detection (#391)
4+
Made page title tracking dynamic (#392)
5+
Added warning about using a file URL to example pages (#397)
6+
17
Version 2.5.0 (2015-07-22)
28
--------------------------
39
Generated a unique session ID for each new session (#347)

examples/web/async-large.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
2424
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
2525
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
26-
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.5.0/sp.js","snowplow_1"));
26+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.5.1/sp.js","snowplow_1"));
2727

2828
window.snowplow_1('newTracker', 'cf', 'd3rkrsqld9gmqf.cloudfront.net', { // Initialise a tracker
2929
encodeBase64: false, // Default is true
@@ -83,7 +83,7 @@
8383
;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
8484
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
8585
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
86-
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.5.0/sp.js","snowplow_2"));
86+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.5.1/sp.js","snowplow_2"));
8787

8888
window.snowplow_2('newTracker', 'cf', 'd3rkrsqld9gmqf.cloudfront.net', { // Initialise a tracker
8989
encodeBase64: false, // Default is true
@@ -232,7 +232,8 @@
232232
<body>
233233
<h1>Large_asynchronous_examples_for_snowplow.js</h1>
234234
<h2>This shows how two users can simultaneously use Snowplow on the same page without any clash</h2>
235-
<p>Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is not commented out, all tracking will be prevented.</p>
235+
<p>Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is enabled, all tracking will be prevented.</p>
236+
<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>
236237
<p>Press the buttons below to trigger individual tracking events:<br>
237238
<button type="button" onclick="playMix()">Play a mix</button><br>
238239
<button type="button" onclick="addProduct()">Add a product</button><br>

examples/web/async-medium.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
2525
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
2626
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
27-
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.5.0/sp.js","new_name_here"));
27+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.5.1/sp.js","new_name_here"));
2828

2929
window.new_name_here('newTracker', 'cf', 'd3rkrsqld9gmqf.cloudfront.net', {
3030
encodeBase64: false,
@@ -172,13 +172,14 @@
172172
<body>
173173
<h1>Medium_asynchronous_examples_for_snowplow.js</h1>
174174
<p>Two tracker namespaces are instantiated on this page.</p>
175+
<p>Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is enabled, all tracking will be prevented.</p>
176+
<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>
175177
<p>Press the buttons below to trigger individual tracking events:<br>
176178
<button type="button" onclick="playMix()">Play a mix</button><br>
177179
<button type="button" onclick="addProduct()">Add a product</button><br>
178180
<button type="button" onclick="viewProduct()">View a product</button><br>
179181
<button type="button" onclick="addEcommerceTransaction()">Add an ecommerce transaction</button>
180182
</p>
181-
<p>Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is not commented out, all tracking will be prevented.</p>
182183
<a href=http://en.wikipedia.org/wiki/Main_Page id=legal class="link out">Both trackers will track this link</a>
183184
<br>
184185
<a href=http://en.wikipedia.org/wiki/Main_Page id=semilegal class="class inbound">Only the cf tracker will track this link</a>

examples/web/async-small.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
2424
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
2525
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
26-
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.5.0/sp.js","snowplow"));
26+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.5.1/sp.js","snowplow"));
2727

2828
window.snowplow('newTracker', 'cf', 'd3rkrsqld9gmqf.cloudfront.net', { // Initialise a tracker
2929
encodeBase64: false, // Default is true
@@ -149,13 +149,16 @@
149149

150150
<body>
151151
<h1>Small_asynchronous_examples_for_snowplow.js</h1>
152+
153+
<p>Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is enabled, all tracking will be prevented.</p>
154+
<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>
155+
152156
<p>Press the buttons below to trigger individual tracking events:<br>
153157
<button type="button" onclick="playMix()">Play a mix</button><br>
154158
<button type="button" onclick="addProduct()">Add a product</button><br>
155159
<button type="button" onclick="viewProduct()">View a product</button><br>
156160
<button type="button" onclick="addEcommerceTransaction()">Add an ecommerce transaction</button>
157161
</p>
158-
<p>Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is not commented out, all tracking will be prevented.</p>
159162
<a href=http://en.wikipedia.org/wiki/Main_Page id=legal target="_blank" class="link out">Link</a>
160163
<br>
161164
<a href=http://en.wikipedia.org/wiki/Main_Page id=illegal class="class barred">Ignored link</a>

examples/web/sync.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

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

6363
<body>
6464
<h1>Synchronous examples for snowplow.js</h1>
65+
<p>Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is enabled, all tracking will be prevented.</p>
66+
<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>
6567
<p>Press the buttons below to trigger individual tracking events:<br>
6668
<button type="button" onclick="playMix()">Play a mix</button><br>
6769
<button type="button" onclick="addProduct()">Add a product</button><br>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "snowplow-tracker",
3-
"version": "2.5.0",
3+
"version": "2.5.1",
44
"devDependencies": {
55
"JSON": "~1.0.0",
66
"browser-cookie-lite": "~0.3.1",

src/js/tracker.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@
126126
configCustomUrl,
127127

128128
// Document title
129-
configTitle = documentAlias.title,
129+
lastDocumentTitle = documentAlias.title,
130+
131+
// Custom title
132+
lastConfigTitle,
130133

131134
// Maximum delay to wait for web bug image to be fetched (in milliseconds)
132135
configTrackerPause = argmap.hasOwnProperty('pageUnloadTimer') ? argmap.pageUnloadTimer : 500,
@@ -854,11 +857,15 @@
854857
*/
855858
function logPageView(customTitle, context, contextCallback) {
856859

857-
// Fixup page title. We'll pass this to logPagePing too.
858-
var pageTitle = helpers.fixupTitle(customTitle || configTitle);
859-
860860
refreshUrl();
861861

862+
// So we know what document.title was at the time of trackPageView
863+
lastDocumentTitle = documentAlias.title;
864+
lastConfigTitle = customTitle;
865+
866+
// Fixup page title
867+
var pageTitle = helpers.fixupTitle(lastConfigTitle || lastDocumentTitle);
868+
862869
// Log page view
863870
core.trackPageView(
864871
purify(configCustomUrl || locationHrefAlias),
@@ -900,7 +907,7 @@
900907
if ((lastActivityTime + configHeartBeatTimer) > now.getTime()) {
901908
// Send ping if minimum visit time has elapsed
902909
if (configMinimumVisitTime < now.getTime()) {
903-
logPagePing(pageTitle, finalizeContexts(context, contextCallback)); // Grab the min/max globals
910+
logPagePing(finalizeContexts(context, contextCallback)); // Grab the min/max globals
904911
}
905912
}
906913
}, configHeartBeatTimer);
@@ -913,14 +920,18 @@
913920
* Not part of the public API - only called from
914921
* logPageView() above.
915922
*
916-
* @param string pageTitle The page title to attach to this page ping
917923
* @param object context Custom context relating to the event
918924
*/
919-
function logPagePing(pageTitle, context) {
925+
function logPagePing(context) {
920926
refreshUrl();
927+
newDocumentTitle = documentAlias.title;
928+
if (newDocumentTitle !== lastDocumentTitle) {
929+
lastDocumentTitle = newDocumentTitle;
930+
lastConfigTitle = null;
931+
}
921932
core.trackPagePing(
922933
purify(configCustomUrl || locationHrefAlias),
923-
pageTitle,
934+
helpers.fixupTitle(lastConfigTitle || lastDocumentTitle),
924935
purify(customReferrer || configReferrerUrl),
925936
cleanOffset(minXOffset),
926937
cleanOffset(maxXOffset),
@@ -994,7 +1005,7 @@
9941005
prefix = prefixes[i];
9951006

9961007
// does this browser support the page visibility API?
997-
if (Object.prototype.hasOwnProperty.call(documentAlias, prefixPropertyName(prefix, 'hidden'))) {
1008+
if (documentAlias[prefixPropertyName(prefix, 'hidden')]) {
9981009
// if pre-rendered, then defer callback until page visibility changes
9991010
if (documentAlias[prefixPropertyName(prefix, 'visibilityState')] === 'prerender') {
10001011
isPreRendered = true;
@@ -1111,7 +1122,9 @@
11111122
* @param string title
11121123
*/
11131124
setDocumentTitle: function (title) {
1114-
configTitle = title;
1125+
// So we know what document.title was at the time of trackPageView
1126+
lastDocumentTitle = documentAlias.title;
1127+
lastConfigTitle = title;
11151128
},
11161129

11171130
/**

tests/functional/detectors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ define([
5656
3528351619, // Chrome 32.0 Mac OS X
5757
2180938465, // Chrome 32.0 Windows NT
5858
3829122699, // Chrome 32.0 Linux
59-
513142108, // Safari 7.0 Mac
60-
2651260973 // Safari 6.0.5 Mac
59+
2694331068, // Safari 7.0 Mac
60+
2336697549 // Safari 6.0.5 Mac
6161
];
6262

6363
registerSuite({

0 commit comments

Comments
 (0)