I am trying to add analytics to an already existing web app. I initialize Firebase Analytics as described here.
const firebase = require('firebase');
firebase.initializeApp(config);
firebase.analytics();
I get this error TypeError: firebase.analytics is not a function
What could the problem be?
You have to import 'firebase/analytics' for side effects:
const firebase = require('firebase/app')
require('firebase/analytics')
firebase.initializeApp(config);
firebase.analytics();
That worked for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With