7

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!

27leaves
  • 191
  • 1
  • 11

1 Answers1

0

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

Update 2023-05-23:
More generic question "do we need to await async calls?" is answered here Does an async function always need to be called with await?

Anton
  • 1,432
  • 13
  • 17
  • 1
    This doesn't really answer the question. Specifically, is there a decrease in reliability if we don't await for the log event? – cbreezier Jan 22 '21 at 06:18
  • I guess the more generic question is "do we need to await async calls?". It is answered here https://stackoverflow.com/questions/59953976/does-an-async-function-always-need-to-be-called-with-await. – Anton Jan 22 '21 at 23:15
  • Personally, I experienced a situation where using the logs gathered in this way it seemed that an event was actually reported to Firebase, but I didn't see it in the DebugView. It seems that sometimes events can appear there with a little delay – Maksymilian Wojczuk Jan 29 '21 at 18:20