0.0.7 • Published 9 years ago

@ampatspell/ember-cli-analytics v0.0.7

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
9 years ago

ember-cli-analytics

Basic Google Analytics ember-cli addon.

Install

$ npm install @ampatspell/ember-cli-analytics

Configure

Subclass analytics service:

// app/services/analytics.js
import { Service } from 'analytics';
import ENV from '../config/environment';

const app = {
  name: ENV.APP.name,
  version: ENV.APP.version
};

const trackingId = ENV.APP.trackingId;

export default Service.extend({

  trackingId: trackingId,
  trackErrors: true,  // track also errors (sets Ember.onerror)
  app: app,           // only for tracking errors

});

Add router mixin:

// app/router.js
import Ember from 'ember';
import { AnalyticsTransitionRouterMixin } from 'analytics';

var Router = Ember.Router.extend(AnalyticsTransitionRouterMixin, {
});

Add Tracking ID to your production environment configuration and setup content security policy:

// config/environment.js

ENV.contentSecurityPolicy: {
  // ...
  'script-src': "'self' www.google-analytics.com",
  'img-src': "'self' www.google-analytics.com"
},

if(environment === 'production') {
  ENV.APP.trackingId = 'UA-0000000-00';
}

If you also want track exceptions (Google Analytics is almost useless for this), set trackErrors:true in service subclass and:

// app/route/application.js
import Ember from 'ember';

export default Route.extend(StandaloneRedirectMixin, {

  actions: {
    error: function(error) {
      Ember.onerror(error); // also route errors
      return true;
    }
  }

});
0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago