Skip to content

Commit 68c5d9f

Browse files
committed
Combined and modularised init.js and snowplow.js.
Created new file init.js requiring the resulting module.
1 parent 85ebdad commit 68c5d9f

7 files changed

Lines changed: 140 additions & 170 deletions

File tree

Gruntfile.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ module.exports = function(grunt) {
6565
'banner': '<%= banner %>'
6666
},
6767
src: ['src/js/banner.js',
68-
'src/js/init.js',
69-
'src/js/lib/cookie.js',
70-
'src/js/lib/context.js',
71-
'src/js/snowplow.js',
72-
'src/js/constructor.js'],
68+
'src/js/init.js'],
7369

7470
dest: 'dist/snowplow.js'
7571
}
@@ -86,7 +82,8 @@ module.exports = function(grunt) {
8682
'src/js/lib/context.js:detectors',
8783
'src/js/lib/jstz.js:jstz',
8884
'src/js/lib/sha1.js:sha1',
89-
'src/js/tracker.js:tracker'
85+
'src/js/tracker.js:tracker',
86+
'src/js/snowplow.js:snowplow'
9087
]
9188
},
9289
files: {

examples/web/sync.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<!-- Snowplow starts plowing -->
2121
<script type="text/javascript">
2222
//var spSrc = ('https:' == document.location.protocol ? 'https' : 'http') + '://d1fc8wv8zag5ca.cloudfront.net/0.13.0/sp.js';
23-
var spSrc = '../../dist/snowplow.js'; // For testing
23+
var spSrc = '../../dist/bundle.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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
"grunt-invalidate-cloudfront": "~0.1.4",
1111
"grunt-s3": "~0.2.0-alpha.3",
1212
"murmurhash": "0.0.2",
13-
"sha1": "~1.1.0",
1413
"browserify": "~3.28.1",
1514
"grunt-browserify": "~1.3.0",
1615
"jstimezonedetect": "~1.0.5",
17-
"JSON": "~1.0.0"
16+
"JSON": "~1.0.0",
17+
"Base64": "~0.2.0"
1818
},
1919
"contributors": [
2020
"Alex Dean",

src/js/constructor.js

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/js/init.js

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -32,55 +32,8 @@
3232
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333
*/
3434

35-
/**
36-
* SnowPlow namespace.
37-
* Add classes and functions in this namespace.
38-
*/
39-
40-
var SnowPlow = SnowPlow || function() {
41-
var windowAlias = window;
42-
43-
// SnowPlow Asynchronous Queue
44-
windowAlias._snaq = windowAlias._snaq || [];
45-
return {
46-
47-
/* Tracker identifier with version */
48-
version: 'js-0.14.0', // Update banner.js too
49-
50-
/* Contains three variables that are shared with tracker.js and must be passed by reference */
51-
mutSnowplowState: {
52-
expireDateTime: null,
53-
54-
/* DOM Ready */
55-
hasLoaded: false,
56-
registeredOnLoadHandlers: []
57-
},
58-
59-
/* Alias frequently used globals for added minification */
60-
documentAlias: document,
61-
windowAlias: windowAlias,
62-
navigatorAlias: navigator,
63-
screenAlias: screen,
64-
65-
/* Encode */
66-
encodeWrapper: windowAlias.encodeURIComponent,
67-
68-
/* Decode */
69-
decodeWrapper: windowAlias.decodeURIComponent,
70-
71-
/* decodeUrl */
72-
decodeUrl: unescape,
73-
74-
/* Asynchronous tracker */
75-
asyncTracker: null
76-
}
77-
}();
78-
79-
// Load all our modules (at least until we fully modularize & remove grunt-concat)
35+
// SnowPlow Asynchronous Queue
36+
window._snaq = window._snaq || [];
8037

81-
var identifiers = require('identifiers');
82-
var payload = require('payload');
83-
var json2 = require('JSON');
84-
var cookie = require('cookie');
85-
var detectors = require('detectors');
86-
var tracker = require('tracker');
38+
var snowplow = require('snowplow');
39+
window.SnowPlow = window.SnowPlow || snowplow.build();

0 commit comments

Comments
 (0)