-
Notifications
You must be signed in to change notification settings - Fork 7
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
Reduce duplication in session ending logic #74
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #74 +/- ##
=======================================
Coverage 76.02% 76.02%
=======================================
Files 313 313
Lines 10095 10079 -16
Branches 1455 1457 +2
=======================================
- Hits 7675 7663 -12
+ Misses 1832 1827 -5
- Partials 588 589 +1
|
embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/session/SessionHandler.kt
Show resolved
Hide resolved
embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/session/SessionHandler.kt
Show resolved
Hide resolved
embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/session/SessionHandler.kt
Outdated
Show resolved
Hide resolved
embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/session/SessionHandler.kt
Show resolved
Hide resolved
} | ||
|
||
stopPeriodicSessionCaching() | ||
|
||
if (!configService.dataCaptureEventBehavior.isMessageTypeEnabled(MessageType.SESSION)) { |
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 are we bailing under this condition (and line 303 as well)? Shouldn't the caller just not call into this if that was the case? It feels weird for this code to have logic to check those conditions.
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 does feel a bit weird but the caller would have to check ~5 places, whereas the current code only checks 2 places. I'd propose changing this in a future PR
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.
Logic looks good. Most of my comments is about naming and flow and would make this code more readable. The name used and the number of variations depending on the combination of parameters can probably be simplified to reduce complexity, which there is a lot of here already....
7212135
to
e614fbd
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.
Awesome. Looks good!
e614fbd
to
4cdfd20
Compare
Goal
The existing implementation of
SessionHandler
duplicates business logic on how sessions should be ended. This changeset reduces that duplication & creates an explicit enum type that models the different way a session can end.@bidetofevil would appreciate an in-depth review on this one, as it feels like there is a lot of complexity here.
Testing
Relied on existing unit test coverage in
SessionHandlerTest
.