angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

firebase analytics does not log anything after upgrade to v7

Open metalllus opened this issue 3 years ago • 4 comments
trafficstars

After upgrade to v7 I have nothing logged in Firebase analytics.

Version info

Angular: 13.0.0

Firebase: 9.4.1

AngularFire: 7.2.0

In app.module I have this in imports: provideFirebaseApp(() => initializeApp(environment.firebaseConfig)), provideFirestore(() => getFirestore()), provideStorage(() => getStorage()), provideFunctions(() => { const functions = getFunctions(); functions.region = "europe-west1"; return functions; }), providePerformance(() => getPerformance()), provideMessaging(() => getMessaging()), provideAnalytics(() => getAnalytics()), provideAuth(() => getAuth()),

(I do have measurementId in firebaseConfig) Am I missing some extra step to get firebase analytics initialized in V7 to automatically start logging activity?

Expected behavior

I need events logged in Firebase analytics

Actual behavior

Nothing gets logged.

metalllus avatar Dec 04 '21 00:12 metalllus

This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Dec 04 '21 00:12 google-oss-bot

Did you import all these methods ?

Also, the new v7 API has some changes. For analytics:

this.analytics.logEvent(eventName, eventParams); // v6.1.5 or compat
logEvent(this.analytics, eventName, eventParams);  //v.7

So, your app needs to be adapted a bit according to the situation.

johanchouquet avatar Dec 08 '21 15:12 johanchouquet

@johanchouquet As for the imports I have this at the beginning of app.module.ts import { getAnalytics, provideAnalytics } from "@angular/fire/analytics"; import { initializeApp, provideFirebaseApp } from "@angular/fire/app"; import { getAuth, provideAuth } from "@angular/fire/auth"; import { getFirestore, provideFirestore } from "@angular/fire/firestore"; import { getFunctions, provideFunctions } from "@angular/fire/functions"; import { getMessaging, provideMessaging } from "@angular/fire/messaging"; import { getPerformance, providePerformance } from "@angular/fire/performance"; import { getStorage, provideStorage } from "@angular/fire/storage";

In V6 I didn't have to use logEvent method to get the standard events logged. It was necessary only to log custom events. In V7, is it necessary to use logEvent method manually to log even the basic pageView events so that I get user activity displayed on the Firebase Analytics Dashboard?

metalllus avatar Dec 08 '21 23:12 metalllus

The only way to get the auto logging of basic events working for now seems to be using the methods form JS firebase SDK.

const app = initializeApp(environment.firebaseConfig) to initialize the app; const analytics = getAnalytics(app) to start google analytics;

When done this way, the basic event logging works fine. But it would be great if the same would be the case when analytics is initialized with angularfire as above which is not the case at this point.

metalllus avatar Dec 17 '21 13:12 metalllus