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

Allow consumer to disable tracking by default #264

Open
jelhan opened this issue Oct 21, 2020 · 3 comments
Open

Allow consumer to disable tracking by default #264

jelhan opened this issue Oct 21, 2020 · 3 comments

Comments

@jelhan
Copy link
Contributor

jelhan commented Oct 21, 2020

Ember Metrics allows to globally enabled and disable tracking through enabled property of the metrics service. This is helpful to comply with European privacy rules. It allows a site to disable tracking until the user explicitly confirmed to tracking. Sadly the value of that property is hardcoded as true. This forces consumers that want to disable tracking by default into two hacks:

  1. Implement a custom metrics service in application namespace, which extends from the one provided by this addon and overrides enabled property.
  2. Set enabled to false early in application boot e.g. using an instance initializer or beforeModel hook of application route.

It would be better if ember metrics allows to control the default value of that property through a configuration option.

@jelhan
Copy link
Contributor Author

jelhan commented Oct 28, 2020

After some iterations on the implementation of a cookie notice in my application I'm not that sure anymore if overwriting service:metrics is such a bad idea. It seems as if the value for enabled must be determined at run-time depending. It may be false if the user has not accepted the cookies yet or explicitly denied them. It may be true if the user has accepted cookies earlier. So a static configuration option won't help much. I was ending up with something like this:

import MetricsService from 'ember-metrics/services/metrics';
import { inject as service } from '@ember/service';

export default class CustomizedMetricsService extends MetricsService {
  @service cookieConsent;

  enabled = this.cookieConsent.isAccepted;
}

Actually it doesn't look that bad in my opinion. So maybe it's just a matter of documenting this approach?

@yonmey
Copy link

yonmey commented Dec 28, 2020

The cookie consent services allow the user to agree/disagree a list of consents or vendors. If I understand correct, the enabled field will enable all of them. Is there a way to enable the metric services individually?

@jelhan
Copy link
Contributor Author

jelhan commented Jan 27, 2021

The cookie consent services allow the user to agree/disagree a list of consents or vendors. If I understand correct, the enabled field will enable all of them. Is there a way to enable the metric services individually?

This depends on the implementation of cookieConsent service. Instead of having one isAccepted property you could have a isMetricsAccepted property.

The cookieConsent service is independent from this addon. I just wanted to show that extending the metrics service may be the most flexible approach to control this setting.

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

No branches or pull requests

2 participants