ember-metrics
Advanced tools
Comparing version 0.8.1 to 0.9.0
@@ -31,3 +31,3 @@ import Ember from 'ember'; | ||
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window, | ||
document,'script','//connect.facebook.net/en_US/fbevents.js'); | ||
document,'script','https://connect.facebook.net/en_US/fbevents.js'); | ||
/* jshint ignore:end */ | ||
@@ -34,0 +34,0 @@ |
@@ -24,3 +24,4 @@ import Ember from 'ember'; | ||
const config = copy(get(this, 'config')); | ||
const { id } = config; | ||
const { id, sendHitTask, trace } = config; | ||
let { debug } = config; | ||
@@ -31,5 +32,10 @@ assert(`[ember-metrics] You must pass a valid \`id\` to the ${this.toString()} adapter`, id); | ||
if (debug) { delete config.debug; } | ||
if (sendHitTask) { delete config.sendHitTask; } | ||
if (trace) { delete config.trace; } | ||
const hasOptions = isPresent(Object.keys(config)); | ||
if (canUseDOM) { | ||
/* jshint ignore:start */ | ||
@@ -39,5 +45,9 @@ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | ||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | ||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); | ||
})(window,document,'script',`https://www.google-analytics.com/analytics${debug ? '_debug' : ''}.js`,'ga'); | ||
/* jshint ignore:end */ | ||
if (trace === true) { | ||
window.ga_debug = { trace: true }; | ||
} | ||
if (hasOptions) { | ||
@@ -48,2 +58,7 @@ window.ga('create', id, config); | ||
} | ||
if (sendHitTask === false) { | ||
window.ga('set', 'sendHitTask', null); | ||
} | ||
} | ||
@@ -64,2 +79,3 @@ }, | ||
const sendEvent = { hitType: 'event' }; | ||
const eventKeys = ['category', 'action', 'label', 'value']; | ||
let gaEvent = {}; | ||
@@ -73,4 +89,8 @@ | ||
for (let key in compactedOptions) { | ||
const capitalizedKey = capitalize(key); | ||
gaEvent[`event${capitalizedKey}`] = compactedOptions[key]; | ||
if (eventKeys.includes(key)) { | ||
const capitalizedKey = capitalize(key); | ||
gaEvent[`event${capitalizedKey}`] = compactedOptions[key]; | ||
} else { | ||
gaEvent[key] = compactedOptions[key]; | ||
} | ||
} | ||
@@ -77,0 +97,0 @@ |
@@ -40,3 +40,3 @@ import Ember from 'ember'; | ||
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= | ||
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); | ||
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); | ||
})(window,document,'script',get(this, 'dataLayer'),id); | ||
@@ -43,0 +43,0 @@ /* jshint ignore:end */ |
@@ -34,3 +34,3 @@ import Ember from 'ember'; | ||
for(h=0;h<k.length;h++)e(d,k[h]);a._i.push([b,c,f])};a.__SV=1.2;b=e.createElement("script");b.type="text/javascript";b.async=!0;b.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";c=e.getElementsByTagName("script")[0];c.parentNode.insertBefore(b,c)}})(document,window.mixpanel||[]); | ||
mixpanel.init(token); | ||
mixpanel.init(token,{"api_host":"https://api.mixpanel.com","secure_cookie":true}); | ||
/* jshint ignore:end */ | ||
@@ -37,0 +37,0 @@ } |
11
index.js
@@ -48,6 +48,13 @@ /* jshint node: true */ | ||
included: function(app) { | ||
included: function(app, parentAddon) { | ||
this._super.included.apply(this, arguments); | ||
var config = this.app.project.config(app.env) || {}; | ||
var target = parentAddon || app; | ||
// allow addon to be nested - see: https://github.com/ember-cli/ember-cli/issues/3718 | ||
if (target.app) { | ||
target = target.app; | ||
} | ||
var config = target.project.config(target.env) || {}; | ||
var addonConfig = config[this.name] || {}; | ||
@@ -54,0 +61,0 @@ var discovered = ['base']; |
{ | ||
"name": "ember-metrics", | ||
"version": "0.8.1", | ||
"version": "0.9.0", | ||
"description": "Send data to multiple analytics integrations without re-implementing new API", | ||
@@ -5,0 +5,0 @@ "directories": { |
@@ -73,3 +73,9 @@ # ember-metrics | ||
config: { | ||
id: 'UA-XXXX-Y' | ||
id: 'UA-XXXX-Y', | ||
// Use `analytics_debug.js` in development | ||
debug: environment === 'development', | ||
// Use verbose tracing of GA events | ||
trace: environment === 'development', | ||
// Ensure development env hits aren't sent to GA | ||
sendHitTask: environment !== 'development' | ||
} | ||
@@ -76,0 +82,0 @@ }, |
44055
865
390