Flutter Firebase Analytics Events missing - firebase

I am attempting to publish events via FlutterAnalytics but I am experiencing very sporadic behaviour.
Using latest firebase_core and firebase_analytics packages
Using Firebase project on PAYG Blaze plan
Add pushing of events to BigQuery
Using vanilla flutter create project for testing
Downloaded and added google-services.json to android/app and android/app/debug folder
Added firebaseAnalytics.logEvent(name: 'testevent'); in onPressed where counter is incremented
Click button until counter reaches 100
Expect to see 100 events in Firebase Analytics but I see none.
Look in StreamView, after 5 minutes a part of them show up, alongside the automatically collected screen_view etc.
Look in DebugView (after activating adb) they show up instantly.
Look in Events tab, nothing
Look in BigQuery, nothing, not even tables created
They say events don't show up instantly, wait up to 24h, okay:
Wait 24h, no event in Events tab beyond the automatically collected ones
No BigQuery table generated
Wait 48h, no event showing up.
I then proceeded to create several other test firebase projects, with varying degrees of events showing up:
One project has 12 events out of 100 in BigQuery and 100 in Events tab
Another project has no events
Another project has 27 events in Events tab and 12 in BigQuery
Is anybody getting better mileage out of Firebase Analytics ? It cannot be a misconfiguration on my part on a vanilla project as then no events would show up, not this sporadic behaviour across all the projects.

since you are seeing varying levels of events logged, we need to determine if each of the event is sent to the server for processing. this can be checked by enabling the verbose mode.
adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE
adb logcat -v time -s FA FA-SVC
This will help you to verify if the event is logged or not immediately instead of waiting for 24-48 hours for the UI to show that.
If the events are not logged in the verbose mode, then you might want to rephrase your code to send 100 sequential events, if that is required. Another thought is like lots of same events from same user, are so quick and so they are packaged together for processing resulting in various count. ALways do verbose mode to ensure your events are created and sent as you wanted to analyze further.

Related

How to setup web hooks to send message to Slack when Firebase functions crash?

I need to actively receive crash notifications for firebase functions.
Is there any way to set up Slack webhooks to receive a message when Firebase Functions throw an Error, functions crash, or something like that?
I would love to receive issue messages by velocity ie: Firebase Functions crash 50 times a day.
Thank you so much.
First you have to create a log based (counter) metric that will be counting specific error occurencies and second - you create alerting policy with Slack notification channel.
Let's start from finding corresponding logs that appear when the function throws an error. Since I didn't have one that would crash I used logs that indicated that it was started.
Next you have to create a log based metric. Ignore the next screen and go to Monitoring > Alerting. Click on "Create new policy", find your metric and select "Rolling Window" to whatever time period you need. For testing I used 1 minute. Then set "Rollind windows function" to "mean".
Now configure when the alert has to be triggered - I chose over 3 (within 1 minute window).
On the next screen you select notification channel. In case of Slack it has to be configured first in "Notification Channels".
You can save policy the policy now.
After a few minutes I gathered enough data to generate two incidents:
And here's some alerting related documentation that may help you understand how to use them.

How many clients are connected to my firestore?

I am working on a flutter app that fetches 341 documents from the firestore, after 2 days of analysis I found out that my read requests are increasing too much. So I made a chart on the stackdriver metrics explorer from which I get to know that my app is just reading 341 docs a single time, it's the firebase console which is increasing my reads.
Now, comes to what are the questions that are bothering me,
1)How reads are considered when we see data on the console and how can I reduce my read requests? Basically there are 341 docs but it is showing more than 600 reads whenever I refresh my console.
2)As you can see in the picture there are two types of document reads 'LOOKUP' and 'QUERY', what's the exact difference between them?
3)I am getting data from the firestore with a single instance and when I open my app the chart shows 1 active client which is cool but in the next 5 minutes, the number of active clients starts to increase.
Can anybody please explain to me why this is happening?
For the last question, I tried to disable all the service accounts and then again opened my app but got the same thing again.
Firestore.instance.collection("Lectures").snapshots(includeMetadataChanges: true).listen((d){
print(d.metadata.isFromCache);//prints false everytime
print(d.documents.length);// 341
print(d.documentChanges.length);//341
});
This is the snippet I am using. When the app starts it runs only once.
I will try to answer your questions:
How reads are considered when we see data on the console and how can I
reduce my read requests? Basically there are 341 docs but it is
showing more than 600 reads whenever I refresh my console.
Reads are considered depending on your how you query your Firestore database in addition to your access to this database from the console so using of the Firebase console will incur reads and even if you leave the console open to do other stuff, when new changes to database occured these changes will incur reads also, automatically.and any document read from the server is going to be billed. It doesn't matter where the read came from. The console should be included in that.
Check this official documentation under the "Manage data" title you can see there is a note : "Note: Read, write, and delete operations performed in the console count towards your Cloud Firestore usage."
Saying that if you think there is an issue with this, you can contact Firebase support directly to have more detailed answers.
However, If you check the free plan of Firebase you can see that you have 50K free reads per day.
A workaround that I found for this (thanks to Dependar Sethi)
Bookmarking the Usage tab of the Firestore page. (So you basically
'Skip' the Data Tab)
Adding a dummy collection in a certain way that ensures it is the
first collection(alphabetically) which gets loaded by default on
the Firestore page.
you can find his full solution here.
Also, you can optimise your queries however you want to retreive only the data that you want using where() method and pagination with Firebase
As you can see in the picture there are two types of document reads
'LOOKUP' and 'QUERY', what's the exact difference between them?
I guess there are no important difference between them but "QUERY" is getting the actual data(when you call data() method) while "LOOKUP" is getting a reference of these data(without calling data() method).
I am getting data from the firestore with a single instance and when I
open my app the chart shows 1 active client which is cool but in the
next 5 minutes, the number of active clients starts to increase.
For this question, considering the metrics that you are choosing in Stackdriver I can see 3 connected clients. and as per the decription of "connected client" metric:
The number of active connections. Each mobile client will have one connection. Each listener in admin SDK will be one connection. Sampled every 60 seconds. After sampling, data is not visible for up to 240 seconds.
So please check: how many mobiles are connected to this instance and how many listeners do you have in your app. The sum of all of them is the actual number of connected clients that you are seeing in Stackdriver.

Firebase Remote Config A/B testing shows no results after 24 hours

I configured Firebase Remote Config A/B testing for Android, and we did rollout on at least 10K devices.
For some reason, I see "0 users" in my A/B test after more than 24 hours.
Firebase GMS version is: 11.8.0
Should it show A/B participants in real-time or it's ok to see 0 users after 24 hours?
P.S: We are able to get AB test variants on test devices through Firebase Instance Id, it works well.
The simplest experiment which is running has only app package as a target, with no additional filters. And it shows 0 users as well.
Finally, we found an answer!
Maybe somebody will find it helpful:
For now, it happens (no data in Firebase remote config A/B test experiment) if you have an activation event configured for A/B test experiment.
If you have 2 different experiments, both will fail to get results even if you have "activation event" configured only in 1 of them.
Additionally, remote config will not work as well, you'll be able to get only default values.
We already reported to Google about, so they'll fix it at some point I hope.
Another useful info which is really hard to get:
How long is it ok to see "0 Total Users" in experiment I've just
started?
It takes many hours before you can see any data in your experiment. We were able to see results only after 21 hours after experiment start, so if you configured everything well, don't worry and wait for at least 24 hours. It will show 0 "Total Users" for many hours after the start.
Should I use app versionName or versionCode in "Version" field of
experiment setup?
You should use versionName.
Some useful info from support:
Firebase SDK
Make sure your users have the version of your app with the latest SDK.
Since your experiment is with Remote Config
When activateFetched() is called, all events from that point on will be tagged with the experiment. If you have a goal or activation event that happens before activateFetched(), such as automatic events like first_open, session_start, etc., the experiment setup might be wrong.
Are you using an Activation Event?
Make sure to call fetch() and activateFetched() before the activation event occurs.
Experiment ID of the experiments (if support asks you about)
It's the number at the end of the URL while viewing experiment results.
This debugging log could be useful to get what is going on
Also:
The good way to check if your experiment is working now is to set it to a specific version you didn't publish yet and check logs from remote config with the fresh app install(or erase all app data & restart).
It should show different variant every time you reinstall the app, since your Firebase Instance ID changes after app reinstall/app data erase.
If you see variants change - then A/B test is running well.
In your "build.graddle": don't forget to set the same versionName which you set in experiment setup.
In my case, I was receiving results of A/B testing but suddenly, it stopped to appear. It had continued for 7 days and then results appeared. Firebase Support manager said:
what I suspected here is just a delay in showing the result in the
experiments
Additionally, she said that
With that, I would suggest always using the latest SDK version and
enabling Google Analytics data sharing.
In my case, I used I wasn't using the latest SDK version, but Google Analytics was enabled for "Benchmarking", "Technical Support", "Account Specialists" except for "Google products & services". I believe these settings were enabled by default (the screenshot from Google Analytics):

Firebase create new audience not responding

Hello I am creating a new Audience in Firebase console for a game (already released on store with roughly 17k DAU). However, the tool keep becoming not responding. I checked it seems to be a problem with Firebase's JS. More details below:
Error in Chrome developer debug:
[Violation] Added non-passive event listener to a scroll-blocking 'touchmove' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
Screenshot: Firebase Javascript error
I tried changing the date range to 7 days, yesterday, today. Same error.
Is there a way to workaround this issue? Thank you

How much time does it take for firebase analytics first report?

We wanted to try out the new analytics capabilities provided by firebase and followed all the steps in the getting started guide.
We've run the app, logged a lot of events, and it's been a few hours, yet there is no data on the dashboard - We just see a banner saying "Your analytics data will appear here soon"
How much time does it take to get our first reports, events, etc.?
It takes a few hours. I would say it takes like 4 hours or something like that, based on current experiments.
Firebase says that it can take up to 24h hours, but the docs say that the dashboard updates "a few times every day".
And if you send the Firebase events to BigQuery, they create a new dataset there everyday, but it seems that the "old" events are not sent immediately, maybe that takes a few hours too, don't know yet.
If you want to test other features, or see if Firebase is working for your app, you can force a crash, and see it in the Crash panel, cause this works almost real time.
Or you can send a notification to all users, this should work too, and it is faster than waiting for 4h or more to see if it is working really.
Remember to add the dependencies if you are going to try this:
compile 'com.google.firebase:firebase-crash:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.0'
From the moment an event is logged it might take up to an hour for the event to be uploaded to Firebase Analytics server. First open is normally uploaded within 15 seconds after the app starts but the exact time depends on many factors. You can enable debug logging to verify the events are logged and uploaded.
On Android:
adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE
adb logcat -v time -s FA FA-SVC
On iOS:
In Xcode, select Product > Scheme > Edit scheme...
Select Run from the left menu.
Select the Arguments tab.
In the Arguments Passed On Launch section, add -FIRAnalyticsDebugEnabled.
Once the data is uploaded it takes about 3 hours for it to appear in the dashboard.
The export to BugQuery runs once a day so you need 24 hours to see the data after the events were uploaded.
Why it just so happens I wrote a blog post on exactly this topic!
You should check it out for all the details, but the tl;dr is "a few hours", unless you're exporting your data to BigQuery.
An Android device sends Firebase Analytics data every X hours but you can use the following ADB command to immediately upload analytics data when registering an event:
adb shell setprop debug.firebase.analytics.app your.package.name
To check if data is being sent, you can check the logs:
adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE
adb logcat -v time -s FA FA-SVC
Once uploaded, the data is processed on Firebase servers, and this can take up to 24 hours until you can see the data in the Firebase console.
Firebase Analytics Event Update time on Firebase Console.
When an event is logged, It might take up to an hour for the event to be uploaded to Firebase Analytics server and to reflect on Firebase console.
You can enable debug logging to verify the events are logged and uploaded using the Android studio's terminal
- Make sure you are not connected to more than one device/emulator
adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE
adb logcat -v time -s FA FA-SVC
If it is for debugging you can use this Firebase guide to see the logs almost right away:
https://firebase.google.com/docs/analytics/debugview#ios
Make sure you disable any ad blockers you're using with your browser or whitelist the Firebase console website. If you don't do this, you'll see blank dashboards.

Resources