Adesh Kumar
Adesh Kumar

Reputation: 960

I am seeing following error while trying to add firebase analytics

I have linked firebase analytics to the firebase project recently but I am getting the following error in my console and nothing is visible in the firebase analytics Dashboard even.

[2022-04-11T06:07:13.736Z]  @firebase/analytics: The measurement ID in the local 
Firebase config (G-XXXXXXXXX) does not match the measurement ID fetched from the 
server (undefined). To ensure analytics events are always sent to the correct Analytics 
property, update the measurement ID field in the local config or remove it from the 
local config.

This is how I am adding analytics

const firebaseConfig = {
    apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    authDomain: "*****************",
    projectId: "********",
    storageBucket: "*********",
    messagingSenderId: "********",
    appId: "*******************************",
    measurementId: "G-XXXXXXXXX"
  };

const app = firebase.initializeApp(firebaseConfig)
const auth = getAuth(app)
const db = getFirestore(app)
firebase.analytics()
const analytics = getAnalytics(app);
console.log(analytics)

Can anyone help what exactly I am missing? Any help is appreciated.

Upvotes: 3

Views: 2419

Answers (1)

Adesh Kumar
Adesh Kumar

Reputation: 960

If anyone sees this error, then in my case issue was I have implemented firebase analytics after creating the project not while creating. SO it took 24 hours to reflect. And after 24 hours everything was working.

Upvotes: 5

Related Questions