firebasefirebase-analytics

WebConfig doesn't return measurementId


I am trying to enable firebase analytics in my existing firebase project. The project is a static React website that only uses Firebase hosting.

Following this get start tutorial, I am getting the following error in my console:

Ignored "config" command. Invalid arguments found

Searching how to solve this problem, I found this comment and checked that my webConfig get request is not returning the measurementId. However I couldn't find any info about how to correct it.

//firebase.js
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAnalytics} from "firebase/analytics";

// Your web app's Firebase configuration
const firebaseConfig = {
  apiKey: "{ApiKey}",
  authDomain: "{projectId}.firebaseapp.com",
  projectId: "{projectId}",
  storageBucket: "{projectId}.appspot.com",
  messagingSenderId: "{messagingSenderId}",
  appId: "{appId}",
  measurementId: "{measurementId}",
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);

export const analytics = getAnalytics(app);

WebConfig call (Http 200, Get):

response:

{
  "projectId": "{projectId}",
  "appId": "{appId}",
  "storageBucket": "{projectId}.appspot.com",
  "authDomain": "{projectId}.firebaseapp.com",
  "messagingSenderId":  "{messagingSenderId}"
}

Is there any config that I am missing? what should I do to make it work?


Solution

  • TLDR: Use a new firebase web app.


    I ran into the same problem, I suspect it's because I made a Firebase web app before enabling analytics, so the app might have been stuck at some weird state.

    To fix it I made sure Analytics is enabled, tos accepted etc.. then created a new firebase web app and connected that to my app.