Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to turn on/off specific Google analytics adapter #136

Conversation

PoslinskiNet
Copy link

Task/Issues resolved:

TODO

  • specs (doesn't have enough time right now, if anyone wants to help with that it would be great)

How to use:

// it can be used via serivce object from router / controller or component

// to activate adapter with enableOnStart: false flag
this.get('metrics').activateAdapter('GoogleAnalytics'); 

// to deactivate adapter with enableOnStart: true (default) flag
this.get('metrics').deactivateAdapter('GoogleAnalytics');

If you like to have multiple Google Analytics adapter, just add one that inherits from the default one:

// app/metrics-adapters/google-analytics-application.js
import GoogleAnalyticsAdapter from 'ember-metrics/metrics-adapters/google-analytics';

export default GoogleAnalyticsAdapter.extend();

Settings:

// config/environments.js
module.exports = function(environment) {
  var ENV = {
    ...
    metricsAdapters: [
      {
        // custom addapter name, of our second Google analytics adapter.
        name: 'GoogleAnalyticsApplication',
        environments: ['all'],
        config: {
          // new optional flag - enableOnStart true as default (it doesn't overwrite the default package behaviour
          enableOnStart: false,
          id: 'XX-XXXXX-X'
        }
      },
     ...
}

assert.equal(get(service, '_adapters.GoogleAnalytics.config.id'), 'UA-XXXX-Y', 'it does not override the GoogleAnalytics adapter');
assert.equal(get(service, '_adapters.Mixpanel.config.token'), '0f76c037-4d76-4fce-8a0f-a9a8f89d1453', 'it does not override the Mixpanel adapter');
// assert.equal(get(service, '_adapters.Mixpanel.config.token'), '0f76c037-4d76-4fce-8a0f-a9a8f89d1453', 'it does not override the Mixpanel adapter');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@PoslinskiNet PoslinskiNet force-pushed the feature-metrics-enabled-on-start branch 5 times, most recently from 773a742 to ff80b53 Compare May 19, 2017 15:51
@PoslinskiNet PoslinskiNet force-pushed the feature-metrics-enabled-on-start branch from ff80b53 to 5347c46 Compare May 19, 2017 15:53
@jherdman jherdman closed this Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants