There is no runtime error or warning but there is also no measurement being reported. I do not understand what is wrong with this simple piece of code (most of it is just the default Firebase setup):
App.js
export default function App({ Component, pageProps }) {
useEffect(() => {
////////////////////////////////////firebase//////////////////////////////////////////
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "---",
authDomain: "hypnotic-trees-328016.firebaseapp.com",
projectId: "hypnotic-trees-328016",
storageBucket: "hypnotic-trees-328016.appspot.com",
messagingSenderId: "761017450319",
appId: "1:761017450319:web:5664ca82592d283e8c0f3a",
measurementId: "G-MW7B6FFSV8"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
///////////////////////////////////end_firebase/////////////////////////////////////////////////
}, [])
return (<>
<Component className="App" {...pageProps} /></>)
}
In Create React App, doing const analytics=getAnalytics(app) is sufficient to make it work.