Can You Use Firebase Analytics With Expo React Native Web App? - firebase

I have been reading all through the documentation and through all of the other StackOverflow posts and am still not entirely sure if a react native expo app can have firebase analytics included or not.
I am not sure if I am supposed to use:
import * as Analytics from 'expo-firebase-analytics';
or
import analytics from "#react-native-firebase/analytics";
or if I am supposed to use googleServicesFile but I am using a web app so I don't have the file to download to add to the .pilist
I read this post and it doesn't look like it is possible: Is there any way to integrate firebase analytics into an expo react-native app without detaching?
but I also am reading through the expo documentation and it looks like it is possible: https://docs.expo.io/versions/latest/sdk/firebase-analytics/#expo-client-limitations--configuration
I am either getting errors thrown or no response when I write the events. So needless to say I am super confused. Any help would be appreciated.

Related

firestore is not working with React Native Expo

I installed firebase with react native expo using expo add firebase, then
I created a file (firebase.tsx) and added the Firebase configuration and initialized the app like in this screenshot with correct values].
I have added the google-services.json and
GoogleService-info.plist to the root of my expo project like the documentation say and i am importing firebase in my api service like this import Firebase from './../../../firebase'.
In my register function I call the firebase create user function
const response = await Firebase.auth().createUserWithEmailAndPassword(values.email.value, values.password.value)
The response is never returned, and if I use . then nothing happens either.
If I log firebase.auth I get an object with my API key and app name, etc. so Firebase is installed, but whenever I call the database for sign in or to access a collection nothing happens.
This is my package.json.
This is my app.json.
I added bundleIdentifier and googleServicesFile to iOS and package and googleServicesFile for Android.
currently Firebase seems not to be working in expo if you are using the android configuration. I have tried the web configuration and it has worked for me. Here is the youtube tutorial for it. Watch from 38:20 to set up.

React Native Crashlytics Firebase

We are using firebase crashlytics in react native. But the problem is when the android app crashed, crashlytics give us android native code report. Not the react native code. That is obvious since it is already compiled to native code. But the thing is we are not able to map issues into react native code. Is there any mechanism to do this automatically or manually with the minimum human involvement?
Crash Analytics won't give you detailed report in javascript. Rather it would define the screen where it crashed and the devices/OS etc. You will have to figure the crash yourself. It will give you the crash report like :
com.facebook.soloader.SoLoader.doLoadLibraryBySoName (SoLoader.java)
com.facebook.soloader.SoLoader.assertInitialized (SoLoader.java)
com.facebook.soloader.SoLoader.assertInitialized (SoLoader.java)
com.facebook.soloader.SoLoader.assertInitialized (SoLoader.java)
com.facebook.react.bridge.ReactBridge.staticInit (ReactBridge.java)
com.facebook.react.bridge.NativeMap. (NativeMap.java)
com.facebook.react.jscexecutor.JSCExecutorFactory.create
(JSCExecutorFactory.java)
com.facebook.react.ReactInstanceManager$5.run
(ReactInstanceManager.java)
*You need to have a basic native knowledge or you can google these errors and know the root cause. Also, FYI Sentry can of great help to you as it records javascript error also. Also, A/c firebase latest version 6+ now records JS errors also*

how to implement mixpannel analytics in react native

i have to implement mixpannel analytics in one of my app.
i checked out Mixpannel officail site and react-native-mixpannel
but i'm struggling how to get started with it.
How to use it from scratch and what things i need for it like firebase
or not ?
Please suggest me some article or something else from where i can implement mixpannel anaylits to my react native app
Thanks
First of all did you use react-native init AwesomeProject or expo new?
With the first one you have access to the native code for iOS and Android.
For expo you have only the JavaScript files and you can't use this SDK.

Implementing Firebase Crashlytics in React native application - Android

I want to add Firebase Crashlytics to my React native project. I had a look online and some of the links suggested using Crashlytics with Fabric,
When I looked at Fabric and at somepoint it was mentioned that it was only available till 2020 and recommended to use Firebase Crashlytics. I am a bit confused.
Can any one suggest any link/guide to implement Firebase Crashlytics in my React native project.
Thanks
R
Its kind of simple.
First you need to add firebase to your project use the following link to link react-native-firebase .
https://rnfirebase.io/docs/v5.x.x/installation/initial-setup
Then use there doc to add firebase crash analytics into your code
https://rnfirebase.io/docs/v5.x.x/crashlytics/reference/crashlytics
for example:
import firebase from 'react-native-firebase'
componentDidMount(){
firebase.crashlytics().log('Test Message!');
firebase.crashlytics().recordError(37,"Test Error");
}
Add firebase to your project followed by crashlytics sdk. You might need to put the keys in your android and ios projects. Thts it.
Also have a look at sentry- its more suitable for JS based apps as it shows the line nos and the code which caused the crash. Crashlytics on the other hand as i remember shows only native crashes.

Firebase client on ReactNative

When using Firebase on ReactNative, it will show such error message:
can't find variable process
However, if I require firebase/lib/firebase-web.js manually, it will show:
can't find variable document
How can I resolve this?
I just went through the same issue while trying to use sockets.io in my react native app so hopefully I can help.
The reason that you cannot use firebase's node module is because there hasn't been a polyfill created yet for websockets support (which firebase is dependent on) in react native.
If you take a look at issue #619 in react native's repo you'll find the current discussion on creating a websockets api polyfill.
The way that we solved it is by using Jason's modified version of the sockets library and creating our own repo around just that file. Then we added the line below to our package.json dependencies.
"react-sockets": "crewapp/react-native-sockets-io"
The reason that Jason's version of the sockets.io client file works is because react-native is added as a user agent. You can find the code that makes this change at the top of the file:
window.navigator = {
userAgent: "react-native"
}
Once you've gone through these steps you should be able to require sockets.io / firebase as normal.
Just figuring it our. Pavan's answer is helpful, but it is not quite true when using with Firebase.
For firebase, please follow the steps:
Download the firebase-debug.js from wsExample. Or you can just install wsExample by npm and require the firebase-debug.js inside it.
Use badfortrains's forked React-Native:
"react-native": "git://github.com/badfortrains/react-native#WebSocket"
New the Firebase like this:
var firebase = require("../../firebase-debug.js");
var rootRef = new Firebase(Const.FB_ROOT);
Things should just work now!
I had issues with socket.io on React Native too, solution was to get notifications about new data and if data is big enough - get it by simple RESTfull request. in my case data was small enough to be sent all within notifications API.
I was using GCM service to send notification to phone from nodejs server. BTW, it uses less battery then socket connection and works great :)

Resources