firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.83k stars 891 forks source link

firebase web does not appear in the realtime dashboard #7928

Closed KOSSOKO closed 8 months ago

KOSSOKO commented 10 months ago

I use firebase in my Android App and my web app. Same project for both. I have two configurations, one for Android and one for Web.

When i open my Android App, automatically events are triggered and I can see the user in the realtime overview. Mobile is always 100%.

image

In my web i have a file called firebase.js with this code

  // Import the functions you need from the SDKs you need
  import { initializeApp } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js";
  import { getAnalytics, logEvent } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-analytics.js";
  // TODO: Add SDKs for Firebase products that you want to use
  // https://firebase.google.com/docs/web/setup#available-libraries

  // Your web app's Firebase configuration
  // For Firebase JS SDK v7.20.0 and later, measurementId is optional
  const firebaseConfig = {
    apiKey: "AIzaXXXXXXXXXXXXXXXXXXXCWdu6fMbeqU",
    authDomain: "XXXXXXXXXXXXXXXXXXXfirebaseapp.com",
    projectId: "gXXXXXXXXXXXXXXXXXXXXore",
    storageBucket: "XXXXXXXXXXXXXXXXXXXXXXXappspot.com",
    messagingSenderId: "XXXXXXXXXXXXXXXXXXXX",
    appId: "XXXXXXXXXXXXXXXXXXX24659b36c5f51b63",
    measurementId: "G-XXXXXXXXXXXXXXXXXXXXXXX"
  };

  // Initialize Firebase
  const app = initializeApp(firebaseConfig);
  const analytics = getAnalytics(app);

  logEvent(analytics ,'test_event_from_game', { name: 'hiiiiiiiiiii'});

  console.log(app);
  console.log(analytics);

and I included it in my index.html

<script src="./firebase.js" type="module"> </script>

For what reasons the Android only is working in realtime ?

jhuleatt commented 9 months ago

Hi @KOSSOKO, this repository is for the firebaseui Authentication library. I'm going to move this issue to the Firebase JS SDK repository, where someone with more knowledge of the Analytics SDK can help.

google-oss-bot commented 9 months ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

hsubox76 commented 9 months ago

This seems to be working fine for me. Here's my full setup. I have a local directory with two files:

index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script src="./index.js" type="module"></script>
</body>
</html>

index.js (identical to your code above, shortened for brevity)

  import { initializeApp } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js";
  import { getAnalytics, logEvent } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-analytics.js";

  const firebaseConfig = {
    // config
  };

  const app = initializeApp(firebaseConfig);
  const analytics = getAnalytics(app);

  logEvent(analytics ,'test_event_from_game', { name: 'hiiiiiiiiiii'});

  console.log(app);
  console.log(analytics);

I put those in the same dir, and then ran http-server locally and went to that site. I see the event sent in my dev tools network tab:

Screenshot 2024-01-16 at 11 16 40 AM

In the console I see the event (there's 3 because I ran this 3 times)

Screenshot 2024-01-16 at 11 16 53 AM

Are you seeing the event being sent in your network tab? It should be a request to a url with the endpoint collect as you can see in the first screenshot. If not, do you have any kind of ad blockers or private browsing mode enabled?

KOSSOKO commented 9 months ago

Very strange. Even the firebase team did not succeed to explain why the data is not in my dashboard. Also, you have the desktop appeared...I never got desktop. Firebase team said that it is about threshhold, but your data have been detected. What is also strange is the fact that during debug i saw the data sent.

I'm really confused.

hsubox76 commented 9 months ago

I'm not sure I really understand your comments. By the "firebase team" do you mean Firebase support? Are you talking to the Firebase support team separately? Do you see the "collect" request sent from the network tab?

I suspect this isn't an issue with Firebase specifically (which just wraps calls to Google Analytics) but with Google Analytics.

The best way to test if this is Firebase problem or a Google Analytics problem is to create a test page that does not use Firebase, but makes a call to Google Analytics directly using gtag.js: https://developers.google.com/tag-platform/gtagjs/install (Under the hood, Firebase Analytics just calls gtag.js).

Check your network traffic (in the dev tools network tab) and then also check the Google Analytics dashboard (not the Firebase dashboard) to see if the event was received. If you're still having the same problem, there is some issue with Google Analytics and/or your browser environment, and not with the Firebase wrapper, and you'll have to try to contact the Google Analytics team for support.

KOSSOKO commented 9 months ago

Hello @hsubox76, I created few days ago a ticket for the support because data were not sent to bigquery too. The ticket is closed now.

This is what I have in debug.

and i have also the collect:

https://region1.analytics.google.com/g/collect?v=2&tid=G-25L48DR5H1&gtm=45je41a0v9115978792&_p=1705507221640&_dbg=1&gcd=11l1l1l1l1&dma_cps=sypham&dma=1&_fid=eGSP3o3BNMMU2slBi212WG&cid=566941529.1705506934&ul=fr-fr&sr=414x896&uaa=&uab=&uafvl=&uamb=0&uam=&uap=&uapv=&uaw=0&are=1&pae=1&_s=1&sid=1705506934&sct=1&seg=1&dl=https%3A%2F%2Fd333wz42ngbii5.cloudfront.net%2F1%2Fhtml5-data%2Fhtml5%2Fhtml5-1695526988621%2Fbuild%2FBuild%2Findex.html&dt=Knife%20Master&en=page_view&_ee=1&ep.origin=firebase&_et=1&tfd=980

image

KOSSOKO commented 8 months ago

Hello @hsubox76 we created a new project with Angular, imported the configuration and test. We have same situation. We can see logs in Chrome, but nothing appears in the firebase console. We are all confused.

hsubox76 commented 8 months ago

Thanks for doing that, just to confirm, is the new project using gtag.js and not using Firebase? If so, it seems the problem is outside of the Firebase SDK, and is an issue with either Google Analytics or your device/browser, or some combination of these. Are you able to contact Google Analytics for support?

Let me know if I misunderstood and the new project still uses Firebase.

google-oss-bot commented 8 months ago

Hey @KOSSOKO. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 8 months ago

Since there haven't been any recent updates here, I am going to close this issue.

@KOSSOKO if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.