firebase.analytics is not a function

[REQUIRED] Describe your environment

  • Operating System version: Windows 10 1803
  • Browser version: chrome Version 77.0.3865.90 (Official Build) (64-bit)
  • Firebase SDK version: 7.0.0
  • Firebase Product: analytics

[REQUIRED] Describe the problem

Steps to reproduce:

trying to use firebase (google) analytics for webapps as described here

Relevant Code:

Tried to repro on stackblitz but it doesn’t seem to work with firebase 7.0.0

import * as firebase from "firebase";
firebase.initializeApp({...});
const analytics = firebase.analytics();

1 possible answer(s) on “firebase.analytics is not a function

  1. Thanks for reporting it! I made a quick fix and linked the PR here.
    As a workaround (also the best practice), please import Firebase SDKs individually:

    import * as firebase from 'firebase/app';
    import 'firebase/analytics';
    import 'firebase/auth'
    ...