-
Notifications
You must be signed in to change notification settings - Fork 11
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
Component to map lifecycle events to the activity open events #1320
Conversation
855057f
to
9806c9a
Compare
17ed531
to
c426aab
Compare
947eed8
to
0e1d93e
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1320 +/- ##
==========================================
+ Coverage 85.26% 85.33% +0.07%
==========================================
Files 461 462 +1
Lines 10606 10658 +52
Branches 1586 1590 +4
==========================================
+ Hits 9043 9095 +52
Misses 848 848
Partials 715 715
|
c426aab
to
d3bf543
Compare
0e1d93e
to
044d183
Compare
d3bf543
to
32a8aa5
Compare
044d183
to
c6a07c0
Compare
32a8aa5
to
2e485ed
Compare
c6a07c0
to
8294561
Compare
2e485ed
to
7bde79a
Compare
8294561
to
2afc05f
Compare
7bde79a
to
89c30d0
Compare
2afc05f
to
ab9cfd9
Compare
fad7ab9
to
af6f85a
Compare
ab9cfd9
to
3180666
Compare
af6f85a
to
e41a207
Compare
56cda4a
to
7f8d105
Compare
d220405
to
1d16c73
Compare
7f8d105
to
fa84446
Compare
1d16c73
to
5b4cbfe
Compare
fa84446
to
1c45d99
Compare
5b4cbfe
to
52b31dc
Compare
...main/kotlin/io/embrace/android/embracesdk/internal/ClockTickingActivityLifecycleCallbacks.kt
Show resolved
Hide resolved
override fun onActivityCreated(activity: Activity, bundle: Bundle?) { | ||
if (!versionChecker.firePrePostEvents()) { | ||
create(activity) | ||
} | ||
} | ||
|
||
override fun onActivityPostCreated(activity: Activity, savedInstanceState: Bundle?) { | ||
createEnd(activity) | ||
} |
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 is there a version check for activityCreated but not activityPostCreated? (This function and others are only available in API 29)
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.
So this is the reason why I did the changes further down the stack to separate the implementation between OS versions - this won't be called in pre-29 lifecycles, and having it called implies it's 29+.
Yeah. Not great. Which is why this was refactored out in #1683 lol
createEnd(activity) | ||
start(activity) |
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 find the naming of these functions tricky to follow. I think readability would be improved by naming them onActivityStarted
or something similar. Alternatively there might be scope for representing the potential states with an enum/sealed class hierarchy and routing events through one function?
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.
So these get moved around in this PR
While the names haven't change, not mixing up two implementations in one make them a little more clear.
And this was a half-hearted effort to decouple the UILoad events from the activity lifecycle events - these stages SHOULD be generic so we can support different view loading lifecycles (e.g. compose), so I've made it possible to genericize it without actually doing all the work right now (because it's not needed).
For stacking an merging reasons, I'd like to merge this as is, and we can look at #1683 to see if there's a better way of naming these things, or maybe even doing the genericization there?
} | ||
|
||
override fun onActivityPrePaused(activity: Activity) { | ||
abandonTrace(activity) |
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 is the trace abandoned?
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.
This is in case the activity didn't go through its entirely lifecycle before being backgrounded. If the trace was recorded, it's a no-op - if it hasn't, it will be marked as failed.
timestampMs = startTimeMs + PRE_DURATION | ||
), | ||
createEvent( | ||
stage = "createEnd", |
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.
Are these values sent to the backend? I have similar feedback to the naming in UiLoadEventEmitter
that this feels tricky to understand & I wouldn't like to communicate those names when debugging something on a call with a customer
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.
Nope. These are effective points where we create or end child spans. We can look at improving the naming in #1683 for these generic stages, even if the child spans they create map (right now) only to activity lifecycle stages.
1c45d99
to
356af39
Compare
52b31dc
to
54431ea
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
356af39
to
eacfa2d
Compare
d320798
to
d13a3e9
Compare
d13a3e9
to
f6ca940
Compare
f6ca940
to
b27c99c
Compare
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Files |
Merge activity
|
Goal
Listen to activity lifecycle callback events and map them to
UiLoadEvents
. With this, activities can go through its lifecycle and the relevant data will be tracked byUiLoadTraceEmitter
so it can log traces when it receives a terminal event.Note: the activity render event is NOT part of the Activity lifecycle, so the mapping isn't complete
Testing
Unit tests added to map the lifecycle events to the UI load events