This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Where: | |
* button is the category | |
* click is the action | |
* nav buttons is the label | |
* 4 is the value | |
*/ | |
ga('send', 'event', 'button', 'click', 'nav buttons', 4); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mixpanel.track('Clicked Nav Button', { value: 4 }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_kmq.push(['record', 'Clicked Nav Button', { value: 4 }]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
metrics: inject.service(), | |
activate() { | |
this._trackPage(); | |
}, | |
_trackPage() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// only invokes the `trackPage` method on the `GoogleAnalyticsAdapter` | |
metrics.trackPage('GoogleAnalytics', { title: 'My Awesome App' }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(environment) { | |
var ENV = { | |
metricsAdapters: [ | |
{ name: 'GoogleAnalytics', config: { id: 'UA-XXXX-Y' } }, | |
{ name: 'Mixpanel', config: { token: 'xxx' } } | |
] | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import config from '../config/environment'; | |
export function initialize(_container, application) { | |
const { metricsAdapters = {} } = config; | |
application.register('config:metrics', metricsAdapters, { instantiate: false }); | |
application.inject('service:metrics', 'metricsAdapters', 'config:metrics'); | |
} | |
export default { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Service.extend({ | |
_adapters: {}, | |
init() { | |
const adapters = Ember.getWithDefault(this, 'metricsAdapters', Ember.A([])); | |
this._super(...arguments); | |
this.activateAdapters(adapters); | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_activateAdapter(adapterOption = {}) { | |
const metrics = this; | |
const { name, config } = adapterOption; | |
const Adapter = this._lookupAdapter(name); | |
assert(`[ember-metrics] Could not find metrics adapter ${name}.`, Adapter); | |
return Adapter.create({ metrics, config }); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_lookupAdapter(adapterName = '') { | |
const container = Ember.get(this, 'container'); | |
if (isNone(container)) { | |
return; | |
} | |
const dasherizedAdapterName = dasherize(adapterName); | |
const availableAdapter = container.lookupFactory(`ember-metrics@metrics-adapter:${dasherizedAdapterName}`); | |
const localAdapter = container.lookupFactory(`metrics-adapter:${dasherizedAdapterName}`); |