Flutter web Firebase analytics TypeError: dart.global.firebase.analytics is not a function

1,917

The problem was with my browser. I am using brave browser it was blocking google analytics script. that's why i was facing this error.

Share:
1,917
Amarjot Singh
Author by

Amarjot Singh

I am Backend Developer with 2 years of experience in Python and Django. I have experince in Javascript, Vue Js & Flutter also.

Updated on December 23, 2022

Comments

  • Amarjot Singh
    Amarjot Singh over 1 year

    I am trying to use firebase analytics in flutter web and getting the following error:

    TypeError: dart.global.firebase.analytics is not a function
    at Object.analytics$ [as analytics] (http://localhost:5000/packages/firebase/src/top_level.dart.lib.js:110:102)
    at new firebase_analytics_web.FirebaseAnalyticsWeb.new (http://localhost:5000/packages/firebase_analytics_web/firebase_analytics_web.dart.lib.js:56:64)
    at Function.registerWith 
    

    index.html file script part is as following :

    <body>
        <script src="https://www.gstatic.com/firebasejs/7.14.3/firebase-app.js"></script>
        <script src="https://www.gstatic.com/firebasejs/7.14.3/firebase-analytics.js"></script>
        <script src="https://www.gstatic.com/firebasejs/7.14.3/firebase-auth.js"></script>
        
        <script>
          var firebaseConfig = {
            apiKey: "*",
            authDomain: "*",
            databaseURL: "*",
            projectId: "*",
            storageBucket: "*",
            messagingSenderId: "*",
            appId: "*",
            measurementId: "*"
          };
        
          
          firebase.initializeApp(firebaseConfig);
          firebase.analytics();
        </script>
        <script src="main.dart.js" type="application/javascript"></script>
    
      </body>
    

    pubspec :

    firebase_analytics: ^5.0.16
    

    flutter version is 1.20.0 beta

  • Brad Cypert
    Brad Cypert over 3 years
    Unfortunately, there's a lot of cases that block Firebase analytics (ublock being a super common one). Even more unfortunate is that firebase analytics failing to load is rarely graceful. It often results in a blank page for me.
  • Mrudul Addipalli
    Mrudul Addipalli over 2 years
    Hi @Brad, did you find any solution for it?