angular / angularfire

Angular + Firebase = ❤️
https://firebaseopensource.com/projects/angular/angularfire2
MIT License
7.68k stars 2.19k forks source link

DEBUG_MODE trace logs in console even if AnalyticsCollectionEnabled set to false #2593

Closed manon-dm closed 3 years ago

manon-dm commented 4 years ago

Version info

Angular: 9.1.12

Firebase: 7.19.1

AngularFire: 6.0.3-canary.77a9a15

How to reproduce these conditions

Steps to set up and reproduce

Active DEBUG_MODE and see analytics logs in console :

{ provide: DEBUG_MODE, useValue: true }

On click on decline button of consent popin I use : setAnalyticsCollectionEnabled(false), but analytics is still logged in console In GA DebugView, I see no more logs, so analytics is off

constructor(private cookieConsentService: NgcCookieConsentService,
              private analytics: AngularFireAnalytics) {
  }

  ngOnInit() {
    this.statusChangeSubscription = this.cookieConsentService.statusChange$.subscribe(
      (event: NgcStatusChangeEvent) => {
        switch (event.status) {
          case 'allow':
            this.analytics.setAnalyticsCollectionEnabled(true);
            break;
          case 'deny':
            this.analytics.setAnalyticsCollectionEnabled(false);
            break;
          default:
            break;
        }
      });
  }
Splaktar commented 4 years ago

I'm surprised that you see any events with @angular/fire@6.0.2 due to https://github.com/angular/angularfire/issues/2505. You may want to try to new canary that fixes that: 6.0.3-canary.77a9a15.

manon-dm commented 4 years ago

Thanks to communicate that fix, DebugView working now setAnalyticsCollectionEnabled(false)working -> I can see no logs in DebugView

The issue is that DEBUG_MODE still logs analytics in console even if AnalyticsCollectionEnabled is set to false

jamesdaniels commented 4 years ago

Ah good catch, I'll make sure that our code respects that setting rather than lean on the SDK for not sending the "logged event" to the server.

jamesdaniels commented 3 years ago

Should be addressed in 6.1.0-rc.3