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

Reduce duplication in session ending logic #74

Merged
merged 4 commits into from
Nov 17, 2023

Conversation

fractalwrench
Copy link
Contributor

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.

@fractalwrench fractalwrench requested a review from a team as a code owner November 15, 2023 14:12
Base automatically changed from extract-session-props to master November 15, 2023 14:12
Copy link

codecov bot commented Nov 15, 2023

Codecov Report

Merging #74 (4cdfd20) into master (503dde0) will increase coverage by 0.00%.
The diff coverage is 94.17%.

Additional details and impacted files

Impacted file tree graph

@@           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     
Files Coverage Δ
...ndroid/embracesdk/session/EmbraceSessionService.kt 82.05% <82.35%> (-0.71%) ⬇️
...brace/android/embracesdk/session/SessionHandler.kt 89.02% <96.51%> (+1.30%) ⬆️

}

stopPeriodicSessionCaching()

if (!configService.dataCaptureEventBehavior.isMessageTypeEnabled(MessageType.SESSION)) {
Copy link
Collaborator

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.

Copy link
Contributor Author

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

Copy link
Collaborator

@bidetofevil bidetofevil left a 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....

Copy link
Collaborator

@bidetofevil bidetofevil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Looks good!

@fractalwrench fractalwrench merged commit bfa6161 into master Nov 17, 2023
4 checks passed
@fractalwrench fractalwrench deleted the refine-session-end-logic branch November 17, 2023 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants