Firebase Analytics: DebugView double events sometimes

Viewed 260

Basically I have a simple code that sends multiple events:

        for (i in 1..2) {
            val bundle = Bundle().apply {
                putInt("step", i)
                putString("key", "value")
            }

            mFirebaseAnalytics.logEvent("test_event", bundle)
        }

Despite the fact that events are logged separately, sometimes they are displayed doubled (or combined) in DebugView, so it looks like this

But sometimes events are shown separately (as normal).

Any ideas why this happen? Logcat shows the events are being sent separately.

P.S. The real case scenario when I noticed this behavior is tracking the viewed products in the list (RecyclerView), when the user quickly scrolls the list and the events are doubled in the DebugView.

1 Answers

Seems Firebase hasn't addressed this issue cause I'm having it as well. I was able to work around the issue in two different ways.

  1. Add a delay at the bottom of the for loop between each item. NOT PREFERRED

for (i in 1..2) {
  val bundle = Bundle().apply {
    putInt("step", i)
    putString("key", "value")
  }

  mFirebaseAnalytics.logEvent("test_event", bundle)
  // Add minor sleep, wait, setTimeout.
}

  1. Call another event at the end of the for loop so it splits your "test_event" calls.

for (i in 1..2) {
  val bundle = Bundle().apply {
    putInt("step", i)
    putString("key", "value")
  }
  mFirebaseAnalytics.logEvent("test_event", bundle)

  val bundle2 = Bundle().apply {
    putString("EventCategory", "relevant category")            
    putString("EventAction", "relevant action")
    putString("EventLabel", "relevant label")
  }
  mFirebaseAnalytics.logEvent("all_events", bundle)
}

FYI these code snippets don't run without error. I just copied the questioners code since I'm not sure what language he's using.

Related