-
Notifications
You must be signed in to change notification settings - Fork 928
Firebase Analytics (Web) does not work in Non-browser Envs #2243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I found a few problems with this issue:
|
It's a limitation on gtag.js which Firebase Analytics depends on and uses cookies to manage sessions and users. Electron has So unfortunately it means Firebase Analytics is not going to work in Electron. |
I see. Then I will have to continue relying on the "classic" Google Analytics with Measurement Protocol. Hopefully, Google Analytics web+apps will support that as a data source at some point. It's a pity because a user-based analytics makes more sense for an Electron app (like for mobile apps) than the current session-based analytics. |
@Feiyang1 Do you have any links or leads on more information regarding this? As of now, we can't use Firebase Analytics in either the the main process (as Firebase node sdk doesn't support Analytics) or in the renderer, due to this. Great shame. |
Nope
…________________________________
From: Nikolaj Selvik <[email protected]>
Sent: Saturday, February 8, 2020 10:55:45 AM
To: firebase/firebase-js-sdk <[email protected]>
Cc: Sharma, Rahul <[email protected]>; Manual <[email protected]>
Subject: Re: [firebase/firebase-js-sdk] Firebase Analytics (Web) does not work on Electron (#2243)
@Feiyang1<https://protect-us.mimecast.com/s/XQXaCQW2m6iQrPvfPqo0G> Do you have any links or leads on more information regarding this? As of now, we can't use Firebase Analytics in either the the main process (as Firebase node sdk doesn't support Analytics) or in the renderer, due to this. Great shame.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<https://protect-us.mimecast.com/s/ElKHCR60nPh6BW4cP6tg4>, or unsubscribe<https://protect-us.mimecast.com/s/iyKVCVOkr7TJ9yqtJjvEM>.
|
Hi, to clear up any confusion, Firebase Analytics is a wrapper around the gtag.js library. Any expansion of its capabilities depend on Basically, any ability to do this is contingent on changes that would need to be made in a separate library that we do not maintain. |
Thanks for this information.
I will try contacting them
…________________________________
From: Christina Holland <[email protected]>
Sent: Wednesday, February 12, 2020 3:27:04 AM
To: firebase/firebase-js-sdk <[email protected]>
Cc: Sharma, Rahul <[email protected]>; Manual <[email protected]>
Subject: Re: [firebase/firebase-js-sdk] Firebase Analytics (Web) does not work on Electron (#2243)
Hi, to clear up any confusion, Firebase Analytics is a wrapper around the gtag.js library<https://protect-us.mimecast.com/s/fxVgCYEnxytY6rJu0xNYZ>. Any expansion of its capabilities depend on gtag.js adding those capabilities. I don't know of any plans right now to support use of gtag.js in non-browser environments, but as it is a separate team, I don't want to speak for them.
Basically, any ability to do this is contingent on changes that would need to be made in a separate library that we do not maintain.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<https://protect-us.mimecast.com/s/bUR7C1wnqGSgEVDcpRce2>, or unsubscribe<https://protect-us.mimecast.com/s/5IaUC2kor7trEMJs2D13U>.
|
What about Measurement Protocol? |
I would like to chime in, I used heap by making the file protocol a standard scheme, this allowed heap to treat electron file:/// based ui as a webpage. Without this heap would not create cookies and hence wont work
Firebase analytics had a simialr issue where it would not start even. By doing the above it makes the cookies and does some requests to load and start but never fully start
If the problem is a simple check for browser agent then, this should be enhancable
…________________________________
From: Marco Ancona <[email protected]>
Sent: Wednesday, February 12, 2020 5:40:18 AM
To: firebase/firebase-js-sdk <[email protected]>
Cc: Sharma, Rahul <[email protected]>; Manual <[email protected]>
Subject: Re: [firebase/firebase-js-sdk] Firebase Analytics (Web) does not work on Electron (#2243)
What about Measurement Protocol?
If Firebase Analytics is based on the same underlying data of the classic Google Analytics, what prevents simply sending raw hit data?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<https://protect-us.mimecast.com/s/WlKwCn5oXgswmZxfJKtpc>, or unsubscribe<https://protect-us.mimecast.com/s/yBOFCo20Kjh9vV8SV31dC>.
|
@marcoancona My understanding is that Firebase/App+Web GA properties uses v2 of the GPM, which is undocumented and thus potentially subject to changes or it simply never being made available for use as an open protocol. I think there is a definite lack of clarity surrounding the technical details of the Google/Firebase analytics offerings as of right now that should be adressed. References: https://www.thyngster.com/technical-overview-of-new-appweb-properties/ |
Are the Firebase Analytics for C++, iOS, Android and Unity also just wrappers of the gtag.js library? I would have reckoned they used the v2 GPM protocol referenced in my above comment directly. |
has this been resolved by “Using Firebase in Electron: Tips and Tricks” by Christina Holland https://link.medium.com/7JbbcIhXm4 ? |
No, as mentioned in the third paragraph of that article, Firebase is not officially supported for use in Electron. That is a guide with some tips for making as much of it work as possible. For questions about potential use of Measurement Protocol, see this comment in another issue:
The user who opened that issue also links to some code they wrote to supply their desired functionality using the unsupported Measurement Protocol API, if you also want to try that route, given the tradeoff of it being unsupported and liable to change. Finally, to clear up any confusion, the mobile SDKs do not use gtag.js or Measurement Protocol, but platform-specific APIs for interacting with Analytics. |
Based on this answer, it seems you can make Google Analytic work on non-browser environment: https://stackoverflow.com/questions/3591847/google-analytics-from-a-file-url/47251006#47251006 Would it be possible to configure Firebase Analytic the same way? Even better, would it be possible to have Firebase Analytic doing it itself?
This would be awesome! And if it is not possible to use Firebase Analytic SDK in Cordova, is there any issue with using the GTag Library? Considering that my "Firebase Analytic" is linked with my "Google Analytic", what are the functional differences between using FA and GA? Would it impact Firebase Remote Config for example (particularly its ability to use Analytic criteria for the conditions)? Thanks! |
I had solved the problem of using GA4 in electron using expressJS and loading the URL of that to the created window. Now, I want help to persist user session regarding this: I have tried to use https://firebase.google.com/docs/auth/admin/manage-cookies and implemented required things at Firebase Functions. But still, the user session is not persistent. |
Hi I have impleted the electron-firebase npm & configurations in my electron app .. While deploying the rules to firebase , it is asking the Cloud functions Admin role ... But I have already assigned the role to the corresponding service account |
I read a couple of issues related to Electron while I was trying to use the firestore realtime updates within my Electron desktop app. After more than 3 hours I concluded that Firestore realtime updates are incompatible with an Electron Browser window (the renderer process). I am able to use a one-time document or collection fetch, but the realtime updates using |
For us - the analytics are working in the "dev mode" but not in packaged mode. We implemented Mixpanel instead of FB Analytics but would be great to unify our apps under one platform. I found out this library https://github.com/expo/electron-cookies but it looks like it's very outdated and I am not able to run it. |
@petrvecera What I am doing is I started a local web server using express.js, then having main window to load index.html from http://localhost:xxx/index.html, then Firebase Analytics works. const server = app.listen(info.port, '127.0.0.1', () => {
// the actual port local server is listening on
info.port = (server?.address() as AddressInfo)?.port;
// create main window and load contents from local server
electronApp.whenReady().then(() => restoreOrCreateWindow());
resolve();
});
// serve static files for renderer process
const path = join(__dirname, '../../renderer/dist');
app.use(express.static(path));
// load index.html to main window
const pageUrl = new URL(`http://localhost:${serverInfo.port}/index.html`).toString();
await browserWindow.loadURL(pageUrl); |
Universal Analytics will soon be turned off, but there is still no way to use the Firebase/GA4 module in Node.js... |
Where do you see that? When will Universal Analytics not work anymore? |
@haoxi911 Do you mind to provide a full example on this? I am new to Electron app. Thank you. |
@will-aira Here is the code I am using. Basically, it starts a local express.js server, so that you could have BrowserWindow loading As you may know, by default, Electron would load the UI via a local path (e.g. C:\xxx\index.html), and it seems the import { BrowserWindow, app as electronApp } from 'electron';
import { join } from 'path';
import type { Application } from 'express';
import type { AddressInfo } from 'net';
const express = require('express');
let myPort = 0; // variable to save the port.
const app: Application = express();
const server = app.listen(0, '127.0.0.1', () => {
// the actual port has been assigned
myPort = (server?.address() as AddressInfo)?.port;
// create main window and load contents from local server
electronApp.whenReady().then(async () => {
const browserWindow = new BrowserWindow({
width: 1000,
height: 696,
webPreferences: {
preload: join(__dirname, '../../preload/dist/index.js'), // path to your preload script
},
});
browserWindow.on('ready-to-show', () => {
browserWindow.show();
});
const pageUrl = new URL(`http://localhost:${myPort}/index.html`).toString();
try {
await browserWindow.loadURL(pageUrl);
} catch (error) {
// error handling here
}
});
}).on('error', (e) => {
// error handling here
});
// this is for serving the renderer layer via HTTP
const path = join(__dirname, '../../renderer/dist');
app.use(express.static(path)); |
@haoxi911 thank you, I will give it a try. |
Describe the problem
Steps to reproduce:
On Electron, Analytics seems to load correctly but no events, sessions or users are logged.
Relevant Code:
Include Firebase using the
script
tag (as importing the module from NPM fails due to gRPC).While Firebase seems to load, and a new
googletagmanager
gets installed on the page, not analytics events seem to reach Firebase dashboard.The text was updated successfully, but these errors were encountered: