Skip to content

Commit 8ce9a04

Browse files
committed
Merge branch 'feature/2.2.1'
2 parents eb09f56 + 42a2b62 commit 8ce9a04

File tree

11 files changed

+43
-18
lines changed

11 files changed

+43
-18
lines changed

CHANGELOG

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Version 2.2.1 (2015-01-28)
2+
--------------------------
3+
Fixed QuotaExceededError bug with localStorage in Safari (#308)
4+
Stopped sending empty PerformanceTiming context (#306)
5+
Prevented PerformanceTiming context being sent multiple times (#309)
6+
Stopped automatically setting Cloudfront URL in synchronous tracker, thanks @vassilevsky! (#311)
7+
Fixed lodash-cli version at 2.4.2 (#314)
8+
Prevented accidental publication of snowplow-tracker to npm (#300)
9+
Added missing tid ticket to CHANGELOG under 2.1.0 (#302)
10+
111
Version 2.2.0 (2014-12-15)
212
--------------------------
313
Made trackerDictionary object available in onload callbacks, thanks @murphybob! (#294)
@@ -30,6 +40,7 @@ Renamed /dist to /deploy (#216)
3040
Moved context querystring to end of JS-generated beacons (#204)
3141
Added guard to wait until outbound queue is empty before unloading (#202)
3242
Added event_id generation (#190)
43+
Stopped sending tid (#218)
3344
Added content field to link click events (#187)
3445
Replaced "Getting started" with Vagrant-using "Contributing quickstart" (#169)
3546
Added async-large.html (#162)

examples/ads/async.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ <h1>Asynchronous ad tracking examples for snowplow.js</h1>
3838
;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
3939
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
4040
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
41-
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.2.0/sp.js","adTracker"));
41+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.2.1/sp.js","adTracker"));
4242

4343
window.adTracker('newTracker', rnd, 'd3rkrsqld9gmqf.cloudfront.net', {
4444
'encodeBase64': false
@@ -110,7 +110,7 @@ <h1>Asynchronous ad tracking examples for snowplow.js</h1>
110110
;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
111111
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
112112
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
113-
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.2.0/sp.js","adTracker"));
113+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.2.1/sp.js","adTracker"));
114114

115115
window.adTracker('newTracker', rnd, 'd3rkrsqld9gmqf.cloudfront.net', {
116116
'encodeBase64': false
@@ -141,7 +141,7 @@ <h1>Asynchronous ad tracking examples for snowplow.js</h1>
141141
;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
142142
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
143143
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
144-
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.2.0/sp.js","adTracker"));
144+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.2.1/sp.js","adTracker"));
145145

146146
window.adTracker('newTracker', rnd, 'd3rkrsqld9gmqf.cloudfront.net', {
147147
'encodeBase64': false

examples/web/async-large.html

Lines changed: 2 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.2.0/sp.js","snowplow_1"));
26+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.2.1/sp.js","snowplow_1"));
2727

2828
window.snowplow_1('newTracker', 'cf', 'd3rkrsqld9gmqf.cloudfront.net', { // Initialise a tracker
2929
encodeBase64: false, // Default is true
@@ -70,7 +70,7 @@
7070
;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
7171
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
7272
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
73-
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","../../deploy/snowplow.js","snowplow_2"));
73+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.2.1/sp.js","snowplow_2"));
7474

7575
window.snowplow_2('newTracker', 'cf', 'd3rkrsqld9gmqf.cloudfront.net', { // Initialise a tracker
7676
encodeBase64: false, // Default is true

examples/web/async-medium.html

Lines changed: 1 addition & 1 deletion
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.2.0/sp.js","new_name_here"));
27+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.2.1/sp.js","new_name_here"));
2828

2929
window.new_name_here('newTracker', 'cf', 'd3rkrsqld9gmqf.cloudfront.net', {
3030
encodeBase64: false,

examples/web/async-small.html

Lines changed: 1 addition & 1 deletion
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.2.0/sp.js","snowplow"));
26+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.2.1/sp.js","snowplow"));
2727

2828
window.snowplow('newTracker', 'cf', 'd3rkrsqld9gmqf.cloudfront.net', { // Initialise a tracker
2929
encodeBase64: false, // Default is true

examples/web/sync.html

Lines changed: 1 addition & 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.0.2/sp.js';
22+
var spSrc = ('https:' == document.location.protocol ? 'https' : 'http') + '://d1fc8wv8zag5ca.cloudfront.net/2.2.1/sp.js';
2323
document.write(unescape("%3Cscript src='" + spSrc + "' type='text/javascript'%3E%3C/script%3E"));
2424
</script>
2525
<script type="text/javascript">

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "snowplow-tracker",
3-
"version": "2.2.0",
3+
"version": "2.2.1",
44
"devDependencies": {
55
"JSON": "~1.0.0",
66
"browser-cookie-lite": "~0.3.1",
@@ -14,6 +14,7 @@
1414
"grunt-yui-compressor": "git://github.com/fblundun/grunt-yui-compressor.git#feature/issue-8",
1515
"intern": "~1.5.0",
1616
"jstimezonedetect": "~1.0.5",
17+
"lodash-cli": "^2.4.2",
1718
"murmurhash": "0.0.2",
1819
"semver": "~2.2.1",
1920
"sha1": "git://github.com/pvorb/node-sha1.git#v1.0.0",
@@ -37,5 +38,6 @@
3738
"events",
3839
"open source"
3940
],
40-
"license": "Simplified BSD"
41+
"license": "Simplified BSD",
42+
"private": true
4143
}

src/js/out_queue.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
var
3838
json2 = require('JSON'),
3939
lodash = require('./lib_managed/lodash'),
40-
localStorageAccessible = require('./lib/detectors').localStorageAccessible(),
40+
localStorageAccessible = require('./lib/detectors').localStorageAccessible,
4141
object = typeof exports !== 'undefined' ? exports : this; // For eventual node.js environment support
4242

4343
/**
@@ -57,7 +57,7 @@
5757
configCollectorUrl,
5858
outQueue;
5959

60-
if (localStorageAccessible && useLocalStorage) {
60+
if (localStorageAccessible() && useLocalStorage) {
6161
// Catch any JSON parse errors that might be thrown
6262
try {
6363
outQueue = json2.parse(localStorage.getItem(queueName));
@@ -80,7 +80,7 @@
8080
function enqueueRequest (request, url) {
8181
outQueue.push(request);
8282
configCollectorUrl = url;
83-
if (localStorageAccessible && useLocalStorage) {
83+
if (localStorageAccessible() && useLocalStorage) {
8484
localStorage.setItem(queueName, json2.stringify(outQueue));
8585
}
8686

@@ -117,7 +117,7 @@
117117

118118
image.onload = function () {
119119
outQueue.shift();
120-
if (localStorageAccessible && useLocalStorage) {
120+
if (localStorageAccessible() && useLocalStorage) {
121121
localStorage.setItem(queueName, json2.stringify(outQueue));
122122
}
123123
executeQueue();

src/js/snowplow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227
*/
228228
getTrackerUrl: function (rawUrl) {
229229
var t = new tracker.Tracker(functionName, '', version, mutSnowplowState, {});
230-
t.setCollectorCf(rawUrl);
230+
t.setCollectorUrl(rawUrl);
231231
return t;
232232
},
233233

src/js/tracker.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,16 @@
586586
if (performanceTracking) {
587587
var performance = windowAlias.performance || windowAlias.mozPerformance || windowAlias.msPerformance || windowAlias.webkitPerformance;
588588
if (performance) {
589-
var performanceTiming = lodash.clone(performance.timing);
589+
590+
// On Safari, the fields we are interested in are on the prototype chain of
591+
// performance.timing so we cannot copy them using lodash.clone
592+
var performanceTiming = {};
593+
for (var field in performance.timing) {
594+
// Don't copy the toJSON method
595+
if (!lodash.isFunction(performance.timing[field])) {
596+
performanceTiming[field] = performance.timing[field];
597+
}
598+
}
590599

591600
// Old Chrome versions add an unwanted requestEnd field
592601
delete performanceTiming.requestEnd;
@@ -596,7 +605,10 @@
596605
performanceTiming.chromeFirstPaint = Math.round(window.chrome.loadTimes().firstPaintTime * 1000);
597606
}
598607

599-
context = context || [];
608+
// Avoid individual tracker instances mutating the shared context array
609+
// See https://github.com/snowplow/snowplow-javascript-tracker/issues/309
610+
context = context ? lodash.clone(context) : [];
611+
600612
context.push({
601613
schema: 'iglu:org.w3/PerformanceTiming/jsonschema/1-0-0',
602614
data: performanceTiming

0 commit comments

Comments
 (0)