forked from jherdman/ember-cli-trackjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
23 lines (18 loc) · 787 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* jshint node: true */
'use strict';
var defaultAddonConfig = {
url: "//d2zah9y47r7bi2.cloudfront.net/releases/current/tracker.js"
};
module.exports = {
name: 'ember-cli-trackjs',
contentFor: function (type, config) {
var trackOpts = config.trackJs || {};
var trackConfig = trackOpts.config || {};
var addonConfig = trackOpts.addon || defaultAddonConfig;
var trackConfiguration = '<script type="text/javascript" id="trackjs-configuration">window._trackJs = ' + JSON.stringify(trackConfig) + ';</script>';
var trackBoilerPlate = '<script type="text/javascript" id="trackjs-boilerplate" src="' + addonConfig.url + '" crossorigin="anonymous"></script>';
if (type === 'head') {
return [trackConfiguration, trackBoilerPlate].join('\n');
}
}
};