Skip to content

Commit c61951e

Browse files
committed
Merge branch 'release/2.9.0'
2 parents 3241605 + 5b38828 commit c61951e

File tree

18 files changed

+5017
-126
lines changed

18 files changed

+5017
-126
lines changed

.travis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ install:
66
- npm install -g grunt-cli
77

88
- cd core
9-
- npm install --dev
9+
- npm install --only=dev --quiet
1010
- grunt ts
1111
- grunt dtsGenerator
1212
- cd ..
1313

14+
- npm install --no-optional
1415
- npm install ./core --save # Must be cleaned from package.json before deploy
15-
- npm install --dev
16+
- npm dedupe
17+
- npm shrinkwrap --also=dev
1618
- wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
1719
- unzip ./ngrok-stable-linux-amd64.zip
1820
before_script:
@@ -23,11 +25,13 @@ script:
2325
- grunt travis
2426
deploy:
2527
- provider: script
28+
skip_cleanup: true
2629
script: ./.travis/deploy.py
2730
on:
2831
condition: '"$(.travis/is_core_release_tag.sh $TRAVIS_TAG)" == "" && $? == 0'
2932
tags: true
3033
- provider: script
34+
skip_cleanup: true
3135
script: ./.travis/deploy.py
3236
on:
3337
condition: '"$(.travis/is_tracker_release_tag.sh $TRAVIS_TAG)" == "" && $? == 0'

CHANGELOG

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
Version 2.9.0 (2018-02-27)
2+
--------------------------
3+
Add ability to change field content before sending form tracking (#465)
4+
Add a method to start a new session (#515)
5+
Make newDocumentTitle variable local (#580)
6+
Enforce that geolocation.timestamp is an integer (#602)
7+
Remove respectOptOutCookie from the Tracker function comments (#605)
8+
Add jsDelivr hits badge (#611)
9+
Add identifyUser as alias for setUserId (#621)
10+
Add trackConsentGranted method (#623)
11+
Add trackConsentWithdrawn method (#624)
12+
Bump semver to 4.3.2 (#625)
13+
LocalStorage domain user ID is not persisted properly (#627)
14+
Core: add trackConsentGranted method (#629)
15+
Core: add trackConsentWithdrawn method (#630)
16+
Update OS X test targets for Saucelabs (#632)
17+
Install dependencies and update shrinkwrap before deployment (#633)
18+
119
Version 2.8.2 (2017-08-21)
220
--------------------------
321
Fix opt-out cookie check (#604)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![Code Climate][codeclimate-image]][codeclimate]
66
[![Built with Grunt][grunt-image]][grunt]
77
[![License][license-image]][bsd]
8+
[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/gh/snowplow/snowplow-javascript-tracker/badge?style=rounded)](https://www.jsdelivr.com/package/gh/snowplow/snowplow-javascript-tracker)
89

910
## Overview
1011

core/lib/core.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,84 @@ export function trackerCore(base64: boolean, callback?: (PayloadData) => void) {
878878
pageResults: pageResults
879879
})
880880
}, context, tstamp);
881+
},
882+
883+
/**
884+
* Track a consent withdrawn event
885+
*
886+
* @param {boolean} all - Indicates user withdraws consent for all documents.
887+
* @param {number} [id] - ID number associated with document.
888+
* @param {number} [version] - Version number of document.
889+
* @param {string} [name] - Name of document.
890+
* @param {string} [description] - Description of document.
891+
* @param {Array<SelfDescribingJson>} [context] - Context relating to the event.
892+
* @param {Timestamp} [tstamp] - TrackerTimestamp of the event.
893+
* @return Payload
894+
*/
895+
trackConsentWithdrawn: function(
896+
all: boolean,
897+
id?: number,
898+
version?: number,
899+
name?: string,
900+
description?: string,
901+
context?: Array<SelfDescribingJson>,
902+
tstamp?: Timestamp): PayloadData {
903+
904+
let documentJson = {
905+
schema: 'iglu:com.snowplowanalytics.snowplow/consent_document/jsonschema/1-0-0',
906+
data: removeEmptyProperties({
907+
id: id,
908+
version: version,
909+
name: name,
910+
description: description
911+
})
912+
};
913+
914+
return trackSelfDescribingEvent({
915+
schema: 'iglu:com.snowplowanalytics.snowplow/consent_withdrawn/jsonschema/1-0-0',
916+
data: removeEmptyProperties({
917+
all: all
918+
})
919+
}, documentJson.data && context ? context.concat([documentJson]) : context, tstamp);
920+
},
921+
922+
/**
923+
* Track a consent granted event
924+
*
925+
* @param {number} id - ID number associated with document.
926+
* @param {number} version - Version number of document.
927+
* @param {string} [name] - Name of document.
928+
* @param {string} [description] - Description of document.
929+
* @param {string} [expiry] - Date-time when consent expires.
930+
* @param {Array<SelfDescribingJson>} [context] - Context relating to the event.
931+
* @param {Timestamp} [tstamp] - TrackerTimestamp of the event.
932+
* @return Payload
933+
*/
934+
trackConsentGranted: function(
935+
id: number,
936+
version: number,
937+
name?: string,
938+
description?: string,
939+
expiry?: string,
940+
context?: Array<SelfDescribingJson>,
941+
tstamp?: Timestamp): PayloadData {
942+
943+
let documentJson = {
944+
schema: 'iglu:com.snowplowanalytics.snowplow/consent_document/jsonschema/1-0-0',
945+
data: removeEmptyProperties({
946+
id: id,
947+
version: version,
948+
name: name,
949+
description: description,
950+
})
951+
};
952+
953+
return trackSelfDescribingEvent({
954+
schema: 'iglu:com.snowplowanalytics.snowplow/consent_granted/jsonschema/1-0-0',
955+
data: removeEmptyProperties({
956+
expiry: expiry,
957+
})
958+
}, context ? context.concat([documentJson]) : [documentJson], tstamp);
881959
}
882960
};
883961
}

core/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "snowplow-tracker-core",
3-
"version": "0.5.0",
3+
"version": "0.6.0",
44
"devDependencies": {
55
"grunt": "0.4.5",
66
"intern": "3.3.2",
@@ -10,6 +10,9 @@
1010
"@types/es6-shim": "0.31.34",
1111
"@types/uuid": "^2.0.29"
1212
},
13+
"dependencies": {
14+
"uuid": "2.0.3"
15+
},
1316
"contributors": [
1417
"Alex Dean",
1518
"Simon Andersson",
@@ -28,8 +31,5 @@
2831
"events",
2932
"open source"
3033
],
31-
"license": "Apache-2.0",
32-
"dependencies": {
33-
"uuid": "2.0.3"
34-
}
34+
"license": "Apache-2.0"
3535
}

core/tests/unit/core.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,78 @@ define([
491491
compare(tracker.trackSiteSearch(terms, filters, totalResults, pageResults), expected);
492492
},
493493

494+
"Track a consent withdrawn event": function () {
495+
var all = false;
496+
var id = 1234;
497+
var version = 2;
498+
var name = "consent_form";
499+
var description = "user withdraws consent for form";
500+
var tstamp = 1000000000000;
501+
var inputContext = [{
502+
schema: 'iglu:com.snowplowanalytics.snowplow/consent_document/jsonschema/1-0-0',
503+
data: {
504+
id: id,
505+
version: version,
506+
name: name,
507+
description: description
508+
}
509+
}];
510+
var inputJson = {
511+
schema: 'iglu:com.snowplowanalytics.snowplow/consent_withdrawn/jsonschema/1-0-0',
512+
data: {
513+
all: all
514+
}
515+
};
516+
var expected = {
517+
e: 'ue',
518+
ue_pr: JSON.stringify({
519+
schema: unstructEventSchema,
520+
data: inputJson
521+
}),
522+
co: JSON.stringify({
523+
schema: 'iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-0',
524+
data: inputContext
525+
})
526+
};
527+
compare(tracker.trackConsentWithdrawn(all, id, version, name, description, [], tstamp), expected);
528+
},
529+
530+
"Track a consent granted event": function () {
531+
var id = 1234;
532+
var version = 2;
533+
var name = "consent_form";
534+
var description = "user grants consent for form";
535+
var tstamp = 1000000000000;
536+
var expiry = "01 January, 1970 00:00:00 Universal Time (UTC)";
537+
var inputContext = [{
538+
schema: 'iglu:com.snowplowanalytics.snowplow/consent_document/jsonschema/1-0-0',
539+
data: {
540+
id: id,
541+
version: version,
542+
name: name,
543+
description: description
544+
}
545+
}];
546+
var inputJson = {
547+
schema: 'iglu:com.snowplowanalytics.snowplow/consent_granted/jsonschema/1-0-0',
548+
data: {
549+
expiry: expiry
550+
}
551+
};
552+
var expected = {
553+
e: 'ue',
554+
ue_pr: JSON.stringify({
555+
schema: unstructEventSchema,
556+
data: inputJson
557+
}),
558+
co: JSON.stringify({
559+
schema: 'iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-0',
560+
data: inputContext
561+
})
562+
};
563+
compare(tracker.trackConsentGranted(id, version, name, description, expiry, [], tstamp), expected);
564+
},
565+
494566
"Track a page view with custom context": function () {
495567
var url = 'http://www.example.com';
496568
var page = 'title page';

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.8.2/sp.js","adTracker"));
41+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.9.0/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.8.2/sp.js","adTracker"));
113+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.9.0/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.8.2/sp.js","adTracker"));
144+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.9.0/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.8.2/sp.js","snowplow_1"));
26+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.9.0/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.8.2/sp.js","snowplow_2"));
86+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.9.0/sp.js","snowplow_2"));
8787

8888
window.snowplow_2('newTracker', 'cf', 'd3rkrsqld9gmqf.cloudfront.net', { // Initialise a tracker
8989
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.8.2/sp.js","new_name_here"));
27+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.9.0/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.8.2/sp.js","snowplow"));
26+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d1fc8wv8zag5ca.cloudfront.net/2.9.0/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.8.2/sp.js';
22+
var spSrc = ('https:' == document.location.protocol ? 'https' : 'http') + '://d1fc8wv8zag5ca.cloudfront.net/2.9.0/sp.js';
2323
document.write(unescape("%3Cscript src='" + spSrc + "' type='text/javascript'%3E%3C/script%3E"));
2424
</script>
2525
<script type="text/javascript">

0 commit comments

Comments
 (0)