From 24c52594fa5216005b04bcc96bbe4e970cbe6743 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Mon, 31 Aug 2015 12:30:12 -0400 Subject: [PATCH 1/3] Prioritize local adapters over bundled adapters Closes #21 --- addon/services/metrics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/services/metrics.js b/addon/services/metrics.js index 4da239f1..b5247768 100644 --- a/addon/services/metrics.js +++ b/addon/services/metrics.js @@ -97,7 +97,7 @@ export default Service.extend({ const dasherizedAdapterName = dasherize(adapterName); const availableAdapter = container.lookupFactory(`ember-metrics@metrics-adapter:${dasherizedAdapterName}`); const localAdapter = container.lookupFactory(`metrics-adapter:${dasherizedAdapterName}`); - const adapter = availableAdapter ? availableAdapter : localAdapter; + const adapter = localAdapter ? localAdapter : availableAdapter; return adapter; }, From f792839ee03084a773da0be7f1efeff362b54e13 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Mon, 31 Aug 2015 12:38:46 -0400 Subject: [PATCH 2/3] Update README with example for global page tracking --- README.md | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 920cc689..a3eb4d2d 100644 --- a/README.md +++ b/README.md @@ -25,22 +25,33 @@ ember install:addon ember-metrics ## Usage -In order to use the addon, you must first [configure](#configuration) it, then inject it into any Object registered in the container that you wish to track. For example, you can call a `trackPage` event across all your analytics services like so: +In order to use the addon, you must first [configure](#configuration) it, then inject it into any Object registered in the container that you wish to track. For example, you can call a `trackPage` event across all your analytics services whenever you transition into a route, like so: ```js +// app/router.js import Ember from 'ember'; +import config from './config/environment'; -export default Ember.Route.extend({ - metrics: Ember.inject.service(), - - activate() { - const metrics = get(this, 'metrics'); +const Router = Ember.Router.extend({ + location: config.locationType, + metrics: inject.service(), - metrics.trackPage({ - title: 'My Awesome App' + didTransition() { + this._super(...arguments); + this._trackPage(); + }, + + _trackPage() { + Ember.run.scheduleOnce('afterRender', this, () => { + const page = document.location.href; + const title = Ember.getWithDefault(this, 'routeName', 'unknown'); + + Ember.get(this, 'metrics').trackPage({ page, title }); }); } }); + +export default Router.map(/* ... */); ``` If you wish to only call a single service, just specify it's name as the first argument: From bed1f2875d5acb960f38e32fb745c8fe788778b7 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Mon, 31 Aug 2015 12:44:34 -0400 Subject: [PATCH 3/3] Version bump to 0.1.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bc698cbf..3eaa6f25 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-metrics", - "version": "0.1.3", + "version": "0.1.4", "description": "Send data to multiple analytics integrations without re-implementing new API", "directories": { "doc": "doc",