Skip to content

RUMM-2231 Fix the session management rules#948

Merged
xgouchet merged 2 commits into
developfrom
xgouchet/RUMM-2231/fix_session_rules
Jun 20, 2022
Merged

RUMM-2231 Fix the session management rules#948
xgouchet merged 2 commits into
developfrom
xgouchet/RUMM-2231/fix_session_rules

Conversation

@xgouchet

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR improves the way we track session, and ensure the logic follows the expectation from our billing guidelines

We separate the RumSessionScope into two classes:

  • RumSessionScope which manages the session lifecycle (extending the life of a session, renewing or reseting a session)
  • RumViewManagerScope which handles the different views and creates Background/AppLaunch views when necessary

@xgouchet
xgouchet requested a review from a team as a code owner June 14, 2022 16:15
@xgouchet xgouchet added the size-huge This PR is huge sized label Jun 14, 2022
@codecov-commenter

codecov-commenter commented Jun 14, 2022

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.91358% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.25%. Comparing base (3b1c057) to head (d88d2cd).
⚠️ Report is 4066 commits behind head on develop.

Files with missing lines Patch % Lines
...droid/rum/internal/domain/scope/RumSessionScope.kt 94.00% 1 Missing and 2 partials ⚠️
...d/rum/internal/domain/scope/RumViewManagerScope.kt 98.15% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #948      +/-   ##
===========================================
+ Coverage    83.20%   83.25%   +0.05%     
===========================================
  Files          267      268       +1     
  Lines         9214     9251      +37     
  Branches      1484     1490       +6     
===========================================
+ Hits          7666     7701      +35     
  Misses        1143     1143              
- Partials       405      407       +2     
Files with missing lines Coverage Δ
.../datadog/android/rum/internal/domain/RumContext.kt 90.00% <100.00%> (+1.11%) ⬆️
.../android/rum/internal/monitor/DatadogRumMonitor.kt 95.15% <100.00%> (+0.03%) ⬆️
...d/rum/internal/domain/scope/RumViewManagerScope.kt 98.15% <98.15%> (ø)
...droid/rum/internal/domain/scope/RumSessionScope.kt 91.30% <94.00%> (-3.06%) ⬇️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +91 to +107
//
// if (event is RumRawEvent.StartView) {
// val viewScope = RumViewScope.fromEvent(
// this,
// event,
// firstPartyHostDetector,
// cpuVitalMonitor,
// memoryVitalMonitor,
// frameRateVitalMonitor,
// timeProvider,
// rumEventSourceProvider
// )
// onViewDisplayed(event, viewScope, actualWriter)
// childrenScopes.add(viewScope)
// } else if (childrenScopes.count { it.isActive() } == 0) {
// handleOrphanEvent(event, actualWriter)
// }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

probably some leftover?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

type = RumViewScope.RumViewType.APPLICATION_LAUNCH
)
}
/*

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is a leftover as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep sorry

Comment on lines 45 to 47
private var resetSessionTime: Long? = null

internal var applicationDisplayed: Boolean = false

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

seems these 2 are not used anymore in this class

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Indeed

lastUserInteractionNs.set(nanoTime)
} else {
if (isExpired) {
sessionState = State.EXPIRED

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it means we kind of reduce the value of the background tracking? Because for background events it won't be any interactions, so any new session created as a result of the background event (say network call) will expire quickly and events coming later won't be sent.

@xgouchet
xgouchet requested a review from 0xnm June 15, 2022 15:05
childScope.handleEvent(event, actualWriter)

//
// if (event is RumRawEvent.StartView) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this still needed ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

}
/*

internal fun onViewDisplayed(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

left over ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

@xgouchet
xgouchet force-pushed the xgouchet/RUMM-2231/fix_session_rules branch from 2e1919d to 9bde0eb Compare June 16, 2022 15:39
@xgouchet
xgouchet requested a review from mariusc83 June 16, 2022 15:39
@xgouchet
xgouchet force-pushed the xgouchet/RUMM-2231/fix_session_rules branch from 65fe7f8 to fce3952 Compare June 17, 2022 12:46
@xgouchet
xgouchet force-pushed the xgouchet/RUMM-2231/fix_session_rules branch from fce3952 to d88d2cd Compare June 20, 2022 07:46
@xgouchet
xgouchet merged commit 999d786 into develop Jun 20, 2022
@xgouchet
xgouchet deleted the xgouchet/RUMM-2231/fix_session_rules branch June 20, 2022 08:36
@xgouchet xgouchet added this to the 1.14.0 milestone Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size-huge This PR is huge sized

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants