Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

firebase.analytics is not a function

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?

like image 823
Baranaba Avatar asked Aug 11 '20 14:08

Baranaba


Video Answer


1 Answers

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

like image 93
Alejo Dev Avatar answered Sep 19 '22 20:09

Alejo Dev