-
Notifications
You must be signed in to change notification settings - Fork 64
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
Fix wrong screen entity info assigned for screen end event and in case events are tracked right before screen view (close #673) #674
Conversation
247367c
to
c9b814a
Compare
b514871
to
41f2a05
Compare
…e events are tracked in parallel (close #673)
41f2a05
to
6370f29
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@@ -333,8 +328,9 @@ class Tracker( | |||
override fun apply(data: Map<String, Any>) { | |||
if (screenViewAutotracking) { | |||
val event = data["event"] as? ScreenView? | |||
event?.let { event -> | |||
getScreenState()?.let { state -> | |||
if (event != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you change this bit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It had a slightly different behaviour which I think was unintended – the ?: track(event)
part could be executed even in case the previous let
block was evaluated but returned null
. I think this if-else better reflects what should happen and is a bit more clear.
|
||
Assert.assertEquals(2, numberOfScreenViews) | ||
val numberOfScreenViews = eventSink.trackedEvents.filter { it.schema == TrackerConstants.SCHEMA_SCREEN_VIEW } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: strange name for a list, I was expecting an int
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, fixed now.
Assert.assertEquals(10.0, screenSummary?.get("foreground_sec")) | ||
Assert.assertEquals(0.0, screenSummary?.get("background_sec")) | ||
|
||
// should have the screen name of the first screen view | ||
val screenEndScreen = screenEnd?.entities?.find { it.map["schema"] == TrackerConstants.SCHEMA_SCREEN } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've read the word "screen" so much it doesn't look like a real word anymore
Issue #673
Due to a bug in how the screen state is updated in the tracker, the screen end event is assigned the wrong information – instead of referring to the previous screen name and ID, it contains information of the subsequent screen.
This bug is not only limited to screen end events but may also appear in case an event is tracked right before a screen view event – the event will be assigned the next screen view instead of the one used when it was tracked.