Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setCurrentScreen in onResume sends screen_view twice #782

Open
lucalooz opened this issue Jan 9, 2019 · 6 comments
Open

setCurrentScreen in onResume sends screen_view twice #782

lucalooz opened this issue Jan 9, 2019 · 6 comments

Comments

@lucalooz
Copy link

lucalooz commented Jan 9, 2019

We are trying to set a custom name or class name to the screen of the screen_view event but the event is sent twice even if we do it inside onResume of the activity.

https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics#setCurrentScreen(android.app.Activity,%20java.lang.String,%20java.lang.String)

@samtstern
Copy link
Contributor

@llooz can you provide some code that reproduces the problem? Is this in an Activity or a Fragment? And does it send twice automatically or do you have to resume the app?

@serenasoldo
Copy link

I'm experiencing the same issue. I call setCurrentScreen in the onResume of an activity and I see in the debug view in my firebase console 2 events: one with the default name and one with the custom name I passed to setCurrentScreen.
This is the exact same behaviour reported for the iOS sdk here: firebase/firebase-ios-sdk#1894

Do you have any insight on how to avoid this? Tracking screen views at the moment is pretty unusable because I can't rely on the numbers I see, due to those duplications.

@raderto
Copy link

raderto commented Aug 5, 2019

Same issue here. It's really not hard to repro at all. Just put a call to setScreenName() in any activity's onResume() and no-where else and you get double events.

Definitely disappointing to expect it to work properly. It only dupes when creating the Activity. IOS bug hasn't moved in almost an entire year so not expecting much any traction at all. It's fixable, but I can see why y'all would punt.

You could probably use WeakReference if setScreenName is called in Activity.onCreate() and if Activity isn't known, hold the reference and resolve it when the onResume() gets called that generates the bad event. This would also help you avoid the other behavior where calling setScreenName in onCreate() doesn't fire anything if the Activity isn't known yet. Then the SDK would work forgivingly without the extra event noise. You also wouldn't have to worry about knowing whether an explicit call to setScreenName is coming, you could just assume if someone tries to set early, resolve it when you get the actual lifecycle event. No need to try to translate intent.

@udaisubramaniam
Copy link

Still facing this issue, is there a fix for this yet?

@niloleartVY
Copy link

Still encountering the same problem.

In fact, a lot of trouble reporting events and parameters using firebase...

@RahulSDeshpande
Copy link

Guys please follow @raderto's comment.
Move your screen_view from onResume() to onCreate().
This will always give you unique & non-redundant screen view events.

Lets close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants