Skip to content
This repository was archived by the owner on Sep 7, 2022. It is now read-only.
This repository was archived by the owner on Sep 7, 2022. It is now read-only.

Can't get Analytics to work #312

Open
@jlubeck

Description

@jlubeck

I added this to my index.html

  <script src="https://www.gstatic.com/firebasejs/7.13.1/firebase-app.js"></script>
  <script src="https://www.gstatic.com/firebasejs/7.13.1/firebase-analytics.js"></script>
  <script>
  // Your web app's Firebase configuration
  var firebaseConfig = {
    apiKey: "XXX",
    authDomain: "XXX.firebaseapp.com",
    databaseURL: "https://XXX.firebaseio.com",
    projectId: "XXX",
    storageBucket: "XXX.appspot.com",
    messagingSenderId: "XXX",
    appId: "XXX",
    measurementId: "G-XXX"
  };
  // Initialize Firebase
  firebase.initializeApp(firebaseConfig);
  firebase.analytics();
  </script>

I then create a class like this one:

import 'package:firebase/firebase.dart' as FB;
import 'dart:js' as js;

class Firebase {
  static void sendPageView(String screenName) {
    print('try to send page');
    final FB.Analytics analytics =
        js.context.hasProperty('firebase') ? FB.analytics() : null;
    if (analytics != null) {
      analytics.setCurrentScreen(screenName);
      print(screenName);
    }
  }
}

When I then run the web app, I see in the console both the 'try to send page' and the screenName at the end. But on my Firebase console I'm not seeing any screen views coming in.

Also on the Chrome console, i only see an initial page_view event going out (I believe it's the automatic page view that gets sent when initializing analytics) but no more events after that one, even though I still see the logs showing the new screen names.

Is there something else that needs to be done?

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions