Skip to content

Commit 65b15a1

Browse files
committed
Merge branch 'feature/0.14.0'
2 parents 6923936 + 7e7f0a3 commit 65b15a1

17 files changed

+662
-515
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ results
1717

1818
npm-debug.log
1919
node_modules
20+
21+
# creds for Grunt
22+
aws*.json

CHANGELOG

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
Version 0.14.0 (2014-02-12)
2+
---------------------------
3+
Bumped version to 0.14.0
4+
Removed all DEBUG blocks from codebase (#65)
5+
Renamed requestStringBuilder to payloadBuilder and moved it into its own file, payload.js (#55)
6+
Introduced gzipped sp.js library (#48)
7+
Updated grunt and intern dependencies (#54)
8+
Replaced snowpak.sh with Grunt and grunt-yui-compressor (#53)
9+
Added setUserIdFromReferrer and setUserIdFromLocation (#57)
10+
Added ability to pass a referrer to Snowplow from an IFRAME (#1)
11+
Tested setDoNotTrack and renamed it to respectDoNotTrack (#28)
12+
Moved detect...() functions into new file context.js (#37)
13+
Moved cookie-related functionality into new file cookie.js (#77)
14+
Removed getLegacyCookieName as no longer needed for migrating cookie IDs (#50)
15+
Switched deployment to use Grunt (#58)
16+
Added setUserIdFromCookie (#78)
17+
118
Version 0.13.1 (2014-01-28)
219
---------------------------
320
Fixed bug where non-String values are not being added to our payload (#71)

Gruntfile.js

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/*
2+
* JavaScript tracker for Snowplow: Gruntfile.js
3+
*
4+
* Significant portions copyright 2010 Anthon Pang. Remainder copyright
5+
* 2012-2014 Snowplow Analytics Ltd. All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are
9+
* met:
10+
*
11+
* * Redistributions of source code must retain the above copyright
12+
* notice, this list of conditions and the following disclaimer.
13+
*
14+
* * Redistributions in binary form must reproduce the above copyright
15+
* notice, this list of conditions and the following disclaimer in the
16+
* documentation and/or other materials provided with the distribution.
17+
*
18+
* * Neither the name of Anthon Pang nor Snowplow Analytics Ltd nor the
19+
* names of their contributors may be used to endorse or promote products
20+
* derived from this software without specific prior written permission.
21+
*
22+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33+
*/
34+
35+
var semver = require('semver');
36+
37+
/*global module:false*/
38+
module.exports = function(grunt) {
39+
40+
var pkg = grunt.file.readJSON('package.json');
41+
var semVer = semver.parse(pkg.version);
42+
pkg.pinnedVersion = semVer.major;
43+
44+
grunt.initConfig({
45+
46+
pkg: pkg,
47+
48+
aws: grunt.file.readJSON('aws.json'),
49+
50+
concat: {
51+
dist: {
52+
options: {
53+
'report': 'gzip'
54+
},
55+
src: ['src/js/banner.js',
56+
'src/js/lib/json.js',
57+
'src/js/lib/jstz.js',
58+
'src/js/init.js',
59+
'src/js/helpers.js',
60+
'src/js/cookie.js',
61+
'src/js/context.js',
62+
'src/js/lib/sha1.js',
63+
'src/js/lib/murmur.js',
64+
'src/js/lib/base64.js',
65+
'src/js/payload.js',
66+
'src/js/tracker.js',
67+
'src/js/snowplow.js',
68+
'src/js/constructor.js'],
69+
70+
dest: 'dist/snowplow.js'
71+
}
72+
},
73+
74+
min: {
75+
dist: {
76+
options: {
77+
linebreak: 1000,
78+
report: 'gzip'
79+
},
80+
files: [
81+
{
82+
src: 'dist/snowplow.js',
83+
dest: 'dist/sp.js'
84+
}
85+
]
86+
}
87+
},
88+
89+
s3: {
90+
options: {
91+
key: '<%= aws.key %>',
92+
secret: '<%= aws.secret %>',
93+
bucket: '<%= aws.bucket %>',
94+
access: 'public-read',
95+
gzip: true
96+
},
97+
not_pinned: {
98+
upload: [
99+
{
100+
src: 'dist/sp.js',
101+
dest: '<%= pkg.version %>/sp.js'
102+
}
103+
]
104+
},
105+
pinned: {
106+
upload: [
107+
{
108+
src: 'dist/sp.js',
109+
dest: '<%= pkg.pinnedVersion %>/sp.js'
110+
}
111+
]
112+
},
113+
},
114+
115+
invalidate_cloudfront: {
116+
options: {
117+
key: '<%= aws.key %>',
118+
secret: '<%= aws.secret %>',
119+
distribution: '<%= aws.distribution %>'
120+
},
121+
not_pinned: {
122+
files: [
123+
{
124+
src: ['<%= pkg.version %>/sp.js'],
125+
dest: ''
126+
}
127+
]
128+
},
129+
pinned: {
130+
files: [
131+
{
132+
src: ['<%= pkg.pinnedVersion %>/sp.js'],
133+
dest: ''
134+
}
135+
]
136+
}
137+
}
138+
});
139+
140+
grunt.loadNpmTasks('grunt-contrib-concat');
141+
grunt.loadNpmTasks('grunt-yui-compressor');
142+
grunt.loadNpmTasks('grunt-s3');
143+
grunt.loadNpmTasks('grunt-invalidate-cloudfront');
144+
145+
grunt.registerTask('default', ['concat', 'min']);
146+
grunt.registerTask('publish', ['concat', 'min', 's3:not_pinned', 'invalidate_cloudfront:not_pinned']);
147+
grunt.registerTask('publish-pinned', ['concat', 'min', 's3', 'invalidate_cloudfront']);
148+
149+
}

aws.sample.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"key": "ADD HERE",
3+
"secret": "ADD HERE",
4+
"bucket": "ADD HERE",
5+
"distribution": "ADD HERE"
6+
}

examples/web/async.html

+9-5
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,20 @@
1818
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
1919

2020
<!-- Snowplow starts plowing -->
21-
<script type="text/javascript">
21+
<script type="text/javascript">
2222
var _snaq = _snaq || [];
2323

2424
_snaq.push(['setCollectorCf', 'd3rkrsqld9gmqf']); // Update to your CloudFront distribution subdomain
2525
_snaq.push(['setAppId', 'CFe23a']); // Site ID can be anything you want. Set it if you're tracking more than one site in this account
2626
_snaq.push(['setUserId', 'alex 123']); // Business-defined user ID
27-
// Deprecated _snaq.push(['attachUserId', false]); // Don't attach &uid=xxx to the querystring
27+
//_snaq.push(['setUserIdFromLocation', 'id']); // To test this, reload the page with ?id=xxx
28+
//_snaq.push(['setUserIdFromCookie', '_sp_id.4209']) // Test this using Firefox because Chrome doesn't allow local cookies.
2829
_snaq.push(['setCustomUrl', '/overridden-url/']); // Override the page URL
2930
_snaq.push(['enableActivityTracking', 10, 10]); // Ping every 10 seconds after 10 seconds
3031
_snaq.push(['enableLinkTracking']);
31-
_snaq.push(['setPlatform', 'mob']);
32+
_snaq.push(['setPlatform', 'mob']);
3233
_snaq.push(['encodeBase64', false]); // Default is true
34+
_snaq.push(['respectDoNotTrack', true]); // Prevent all tracking if browser's Do Not Track feature is enabled
3335
// _snaq.push(['trackPageView', 'Async Test']); // Track the page view with custom title
3436
_snaq.push(['trackPageView', , { // Auto-set page title; add page context
3537
page: {
@@ -44,15 +46,16 @@
4446

4547
(function() {
4648
var sp = document.createElement('script'); sp.type = 'text/javascript'; sp.async = true; sp.defer = true;
47-
sp.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://d1fc8wv8zag5ca.cloudfront.net/0.13.1/sp.js';
48-
// sp.src = '../../dist/snowplow.js'; // For testing
49+
//sp.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://d1fc8wv8zag5ca.cloudfront.net/0.13.0/sp.js';
50+
sp.src = '../../dist/snowplow.js'; // For testing
4951
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(sp, s);
5052
})();
5153
</script>
5254
<!-- Snowplow stops plowing -->
5355

5456
<!-- Example events -->
5557
<script type="text/javascript">
58+
5659
function playMix() {
5760
alert("Playing a DJ mix");
5861
_snaq.push(['trackStructEvent', 'Mixes', 'Play', 'MRC/fabric-0503-mix', '', '0.0']);
@@ -133,6 +136,7 @@ <h1>Asynchronous_examples_for_snowplow.js</h1>
133136
<button type="button" onclick="viewProduct()">View a product</button><br>
134137
<button type="button" onclick="addEcommerceTransaction()">Add an ecommerce transaction</button>
135138
</p>
139+
<p>Warning: if your browser's Do Not Track feature is enabled and respectDoNotTrack is not commented out, all tracking will be prevented.</p>
136140
</body>
137141

138142
</html>

examples/web/sync.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
<!-- Snowplow starts plowing -->
2121
<script type="text/javascript">
22-
var spSrc = ('https:' == document.location.protocol ? 'https' : 'http') + '://d1fc8wv8zag5ca.cloudfront.net/0.13.1/sp.js';
23-
// var spSrc = '../../dist/snowplow.js'; // For testing
22+
//var spSrc = ('https:' == document.location.protocol ? 'https' : 'http') + '://d1fc8wv8zag5ca.cloudfront.net/0.13.0/sp.js';
23+
var spSrc = '../../dist/snowplow.js'; // For testing
2424
document.write(unescape("%3Cscript src='" + spSrc + "' type='text/javascript'%3E%3C/script%3E"));
2525
</script>
2626
<script type="text/javascript">

package.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
{
22
"name": "snowplow-tracker",
3-
"version": "0.13.1",
3+
"version": "0.14.0",
44
"devDependencies": {
5-
"grunt": "~0.4.1",
6-
"intern": "~1.2.1"
5+
"grunt": "~0.4.2",
6+
"intern": "~1.3.1",
7+
"semver": "~2.2.1",
8+
"grunt-contrib-concat": "~0.3.0",
9+
"grunt-yui-compressor": "git://github.com/fblundun/grunt-yui-compressor.git#feature/issue-8",
10+
"grunt-invalidate-cloudfront": "~0.1.4",
11+
"grunt-s3": "~0.2.0-alpha.3"
712
},
813
"repository": {
914
"type": "git",

scripts/snowpak.sh

-97
This file was deleted.

src/dependencies.txt

-11
This file was deleted.

src/js/banner.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* Snowplow - The world's most powerful web analytics platform
33
*
44
* @description JavaScript tracker for Snowplow
5-
* @version 0.13.1
6-
* @author Alex Dean, Simon Andersson, Anthon Pang
5+
* @version 0.14.0
6+
* @author Alex Dean, Simon Andersson, Anthon Pang, Fred Blundun
77
* @copyright Anthon Pang, Snowplow Analytics Ltd
88
* @license Simplified BSD
99
*/

0 commit comments

Comments
 (0)