Reputation: 1247
I am trying to use the expo-firebase-analytics
package in the Expo Go app as a first step to making sure I have the set up correct before I see if it is working in standalone apps. However it is not working right now. Events are not being logged on my Firebase analytics console. I am following this installation guide: https://docs.expo.io/versions/latest/sdk/firebase-analytics/
I have run expo install expo-firebase-analytics
. I have also run expo install firebase
. I have set up a Firebase web project and added the config to my app.json
.
{
"expo": {
...
"web": {
"config": {
"apiKey": "AIxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"authDomain": "my-app.firebaseapp.com",
"projectId": "my-app",
"storageBucket": "my-app.appspot.com",
"messagingSenderId": "mySenderId",
"appId": "1:myApp:web:myAppId",
"measurementId": "G-MYMEASUREMENTID"
}
},
}
Here is my App.js file
import React, { useEffect } from "react";
import { Text, View } from "react-native";
import * as Analytics from 'expo-firebase-analytics';
export default function App() {
useEffect(() => {
(async() => {
console.log("App.js useEffect");
await Analytics.logEvent('ScreenLoaded');
})();
}, []);
return <View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}><Text>MAIN SCREEN</Text></View>
}
Can anyone help me understand what I'm missing?
Upvotes: 7
Views: 3901
Reputation: 81
you should switch to using React Native Firebase because expo-firebase-analytics is currently facing numerous issues on both Android and iOS. Even if you manage to resolve all the errors on iOS, expo-firebase-analytics still cannot run on Gradle 8 (Android).
Here is a guide to migrating from expo-firebase-analytics to React Native Firebase. I have applied and tested it, and everything is now working perfectly on both platforms.
Migrating from Expo Firebase (expo-firebase-analytics) to React Native Firebase https://github.com/expo/fyi/blob/main/firebase-migration-guide.md
Then read this document for more details about React Native Firebase: https://rnfirebase.io/#expo
[Firebase] Automatically collected events https://support.google.com/analytics/answer/9234069?hl=en&ref_topic=13367566&sjid=3847978116116908888-AP
Upvotes: 0
Reputation: 1482
For Expo Web, I was trying the analytics debug view in Brave. But it didn't work.
I have installed Google Analytics Debugger in Brave but no luck.
Then I changed the browser from Brave to Chrome and installed Google Analytics Debugger.
Now it's showing the web analytics in Firebase DebugView which is expected.
Upvotes: 0
Reputation: 1247
I figured it out. The set up is correct. What I realized is that you don't actually see the logs in the Firebase console when you use this package within the Expo Go app. Rather, the log appears in your Terminal console to confirm the package is working. However, once you build the standalone app the logs should appear in your Firebase console.
Another potential trip up is in the Expo docs it says to use put your config object in expo.web.config.firebase
in app.json
, but I had to have it in expo.web.config
(as it is written above) and not have a firebase
keyword for it to work.
Upvotes: 3