Firebase analytics is not initialized. make sure initializeFirebase() is called once

Viewed 1143

I have an application in react with ionic, the thing is that I implement firebase in my project and I use push notifications and analytics events, I currently have a problem because I get this error which is thrown too many times, I investigated and I don't see anything regarding this, all firebase functions work for me, but it keeps throwing that error

Firebase analytics is not initialized. make sure initializeFirebase () is called once

I leave here the implementation of the data and everything is fine:

FirebaseAnalytics.initializeFirebase({
    apiKey: `${process.env.REACT_APP_FIREBASE_ANALYTICS_API_KEY}`,
    authDomain: `${process.env.REACT_APP_FIREBASE_ANALYTICS_AUTH_DOMAIN}`,
    databaseURL: `${process.env.REACT_APP_FIREBASE_ANALYTICS_DATABASE_URL}`,
    projectId: `${process.env.REACT_APP_FIREBASE_ANALYTICS_PROJECT_ID}`,
    storageBucket: `${process.env.REACT_APP_FIREBASE_ANALYTICS_STORAGE_BUCKER}`,
    messagingSenderId: `${process.env.REACT_APP_FIREBASE_ANALYTICS_MESSAGING_SENDER_ID}`,
    appId: `${process.env.REACT_APP_FIREBASE_ANALYTICS_APP_ID}`,
    measurementId: `${process.env.REACT_APP_FIREBASE_ANALYTICS_MEASUREMENT_ID}`,
})

I would appreciate any help you can give me.

1 Answers

Writing a more formal answer since my comment seems to have given hint to the OP to find the fix. The error message below is self explanatory.

Firebase analytics is not initialized. make sure initializeFirebase () is called once

The initializeFirebase() method should be called at the time of bootstrapping the application. The above error indicates that something may be wrong in the application flow and that the call to analytics code is happening before initializerFirebase() has been called to initialize the firebase connectivity details.

Please look through this https://firebase.google.com/docs/web/setup#using-module-bundlers for detailed explanation and steps.

Related