1
votes

I've tried to follow everything from the docs.

https://firebase.google.com/docs/analytics/get-started?platform=web

This is how I'm initializing my firebase app on my client code:

import firebase from 'firebase/app';
import 'firebase/auth';
import 'firebase/firestore';
import 'firebase/functions';
import 'firebase/storage';

// .env file in root folder
const config = {
  apiKey: process.env.FIREBASE_APP_API_KEY,
  authDomain: process.env.FIREBASE_APP_AUTH_DOMAIN,
  databaseURL: process.env.FIREBASE_APP_DATABASE_URL,
  projectId: process.env.FIREBASE_APP_PROJECT_ID,
  storageBucket: process.env.FIREBASE_APP_STORAGE_BUCKET,
  messagingSenderId: process.env.FIREBASE_APP_MESSAGING_SENDER_ID,
  appId: process.env.FIREBASE_APP_ID,
  measurementId: process.env.FIREBASE_MEASUREMENT_ID
};

firebase.initializeApp(config);

Do I need to call firebase.analytics(); ?

So far I'm only running in my localhost. I have not deployed yet to Firebase Hosting.

Should I be able to see myself as a user on the Analytics Console?

How does it work? Do I need to log something to see the users accessing my web app?

So far, nothing shows up.

enter image description here

enter image description here

UPDATE

I just found out that I need to import firebase analytics, like

import 'firebase/analytics';

But I still didn't get if I need to cal firebase.analytics();. Does anybody know that?

1

1 Answers

2
votes

Do I need to call firebase.analytics();?

Without a call to firebase.analytics() to initialize the analytics module, no events will be logged. So if you want to use Firebase analytics in your app, you'll indeed need to call firebase.analytics() when the app starts.