Is it necessary to use await for analytics().logEvent? - react-native-firebase

Sometimes some of my events do not get logged in the Firebase DebugView and I'm currently trying to find out why.
We decided about leaving out the await for firebase.analytics().logEvent(...), and now I wonder if that could lead to the missing events. In my understanding this should not make a difference in the behavior, because I don't have to wait for the event to be logged.
So my question is: Does it make a difference in reliability of the event logging in the following two cases?
// With await
await firebase.analytics().logEvent('event_name');
// Without await
firebase.analytics().logEvent('event_name');
Thank you!

firebase.analytics().* gives u a promise which you need to handle. Under the hood the methods call the firebase app which optimizes communications to Firebase GA servers. You can enable logs
adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE
and watch them with
adb logcat -v time -s FA FA-SVC

Related

How to edit a deferring message via discord.py on program restart or with requests module?

i have this command:
#bot.tree.command(name="restart", description="Restart the bot")
#app_commands.check(is_owner)
async def restart(interaction: discord.Interaction):
await interaction.response.defer()
os.execl(sys.executable, sys.executable, *sys.argv)
and, as you can see, it restarts the program.
but what I want it to also do, is when it does restart, send a followup message editing the defered message telling the user (me) that the bot has restarted.
Edit:
I have an on_ready event registered that I could do this in, but I don't know exactly how to do it.
I tried looking at interactions.py but couldn't find the send function that is said to be tied to it in the docs.

See continuous logging on command line

I am currently working on a Firebase function. As I am still in the development stage, I have a number of logs in my code to see what's going on.
async function getAddressByIdAsync(address) {
let addr = addressesRef.child(address);
console.log(addr);
return admin.database().ref('Addresses/' + address);
}
The only way I have found to be able to see these logs in real time is though the Firebase console, which is very slow and generally a bad UI experience IMO.
I'm looking for a command line solution that will let me see in real time the logs coming from the Firebase cloud function.
I have tried this command
firebase functions:log
Which appears to return the last twenty or so log entries into my Firebase Functions.
I know Google Cloud has a tail option on the end of that CLI but it doesn't work here.
firebase functions:log tail
Error: Too many arguments. Run firebase help functions:log for usage instructions
Is there a way to get a live running output of the logs from firebase cloud functions?
You can try the local emulator, that way you can first run your functions locally (and log in your terminal), before deploying.
https://firebase.google.com/docs/functions/local-emulator

Manually trigger scheduled or trigger function

Is there any way to manually trigger a scheduled function and/or a Firestore trigger function? I have two scenarios I need to solve:
A cloud function that is listening to a Firestore document (onCreate) didn't fire - it failed on 3 of about 1,000 invocations, so I need to manually trigger it for these 3 documents. Is this possible (to manually trigger this function)?
I have a scheduled function that runs hourly, but threw an error b/c of a map in the Firestore document when the code expected an array. Any way I can manually run the scheduled function once rather than waiting an hour before it runs again?
-- firebase console
-- functions
-- "..." at right side of cron job
-- "view in cloud scheduler"
-- "run now" at right side of function
You can run a firestore scheduled function via the FirebaseTools and running it locally. Starting the shell command eg npm run build && firebase functions:shell will allow you to invoke a Scheduled Function eg:
export const parseGarminHealthAPIActivityQueue = functions.region('europe-west2').runWith({
timeoutSeconds: TIMEOUT_IN_SECONDS,
memory: MEMORY
}).pubsub.schedule('every 10 minutes').onRun(async (context) => {
await parseQueueItems(ServiceNames.GarminHealthAPI);
});
It's not possible to manually trigger a function from the Firebase console. Your best bet is to use the methods shown in the Cloud documentation, which involve using gcloud's call command or the Cloud console's Testing tab. Neither of these are very easy, as you will have to construct the JSON payload to the function manually.
If I may make a suggestion - if your functions are failing due to errors, you should consider enabling retry on your functions, and making sure that your functions only generate errors for situations that should be retried. Depending on manual invocation in the event of a failure will not scale very well - errors should be handled by code as much as possible.

AB testing config applied but firebase console show 0 users

I've configured firebase ab-testing. Everything works fine except there is no impact user on console.
Actually, I can see UI and log show ab-testing is applied.
Moreover, by checking the other StackoverFlow topic, activateFetched also invoked after fetch successfully.
Moreover, I've referenced
Firebase Remote Config A/B testing shows no results after 24 hours
Firebase Remote Config results on initial request
Remote Config A/B Test does not provide results on iOS
But those are no work on my case.
Is there anything miss or any other need to check so that client can response AB testing result to firebase console.
Thanks for your help first.
Code snippet:
[FIRApp configure];
FIRRemoteConfigSettings* configSettings = [[remoteConfig configSettings] initWithDeveloperModeEnabled:YES];
[[FIRRemoteConfig remoteConfig] setConfigSettings:configSettings];
[[FIRRemoteConfig remoteConfig] fetchWithExpirationDuration:duration completionHandler:^(FIRRemoteConfigFetchStatus status, NSError *error) {
if (status == FIRRemoteConfigFetchStatusSuccess) {
BOOL configFound = [[FIRRemoteConfig remoteConfig] activateFetched];
A couple things to check or take note of:
Make sure you're using and have deployed the latest Remote Config SDK. Earlier versions don't work with A/B test experiments.
Be sure to verify your experiment on a test device by following the documentation here
It can take a couple days for data to come in for your experiment.
Please call the functions in the following order:
fetch()
Call activatefetched() in the completion handler of fetch().
Fire activation event. If you need to call activation event immediately after activatefetched(), add a time delay of a few seconds. This is because activatefetched() process asynchronously and hence the function may not execute completely, before the activation event is fired.
Once done, test a running experiment on test device. In the debug logs search with string "exp_X" where 'X' is the experiment Id. You will find the experiment Id in the URL of the experiment. If you find the experiment ID in the debug logs while executing the code on test device, it means the device was covered in experiment.
Also if the experiment setup is correct, the running experiment will show 1 active experiment user in the console.

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