Skip to content

RUM-7924: Fix Session Replay is not resumed after the session has expired before#2611

Merged
ambushwork merged 1 commit into
developfrom
yl/replay-investigation
Apr 25, 2025
Merged

RUM-7924: Fix Session Replay is not resumed after the session has expired before#2611
ambushwork merged 1 commit into
developfrom
yl/replay-investigation

Conversation

@ambushwork

@ambushwork ambushwork commented Apr 23, 2025

Copy link
Copy Markdown
Member

What does this PR do?

This is a bug fix based on a support ticket saying they don't see session replay for some of their sessions, after investigating there some key points which lead to the issue.

  • All the sessions missing replay are created after the expiration of previous sessions
  • Client set backgroundTrackingEnabled to false in RumConfiguration
  • Client have sampleRate 100% and never call start/stop recording manually.

After looking into code, it turns out that the expiration of the session will make keepSession false, and stop recording in SessionReplayFeature, when keepSession becomes true due to new user interactions, session replay will not be able to resume.

This PR fixes this case and add a unit test to protect against this corner case. To achieve that, there are some import flag changes in SessionReplayFeature:

  • shouldRecord flag now becomes a definitive state if the recording should be started or stopped, meaning that it will be decided by the other flags (userOption, keepSessions, isSampled), it should not be changed directly outside modifyShouldRecordState function
  • userOption flag is added to indicate the current user decision about recording, it uses startRecordingImmediately as default value, and can be set to true if user calls manuallyStartRecording and can be set to false if user calls manuallyStopRecording.

now in SessionReplayFeature the state flow becomes:

image

Motivation

RUM-7924

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@ambushwork
ambushwork force-pushed the yl/replay-investigation branch 2 times, most recently from c827219 to 409d5c2 Compare April 24, 2025 10:05
@codecov-commenter

codecov-commenter commented Apr 24, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.00%. Comparing base (c5b619f) to head (d9fcc99).
⚠️ Report is 817 commits behind head on develop.

Files with missing lines Patch % Lines
...oid/sessionreplay/internal/SessionReplayFeature.kt 90.48% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2611      +/-   ##
===========================================
+ Coverage    69.97%   70.00%   +0.03%     
===========================================
  Files          820      820              
  Lines        30554    30562       +8     
  Branches      5130     5130              
===========================================
+ Hits         21379    21393      +14     
+ Misses        7747     7741       -6     
  Partials      1428     1428              
Files with missing lines Coverage Δ
...oid/sessionreplay/internal/SessionReplayFeature.kt 98.81% <90.48%> (+0.68%) ⬆️

... and 33 files with indirect coverage changes

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

@ambushwork
ambushwork force-pushed the yl/replay-investigation branch from 409d5c2 to 30eca9a Compare April 24, 2025 10:38
@ambushwork
ambushwork marked this pull request as ready for review April 24, 2025 11:37
@ambushwork
ambushwork requested review from a team as code owners April 24, 2025 11:37
jonathanmos
jonathanmos previously approved these changes Apr 24, 2025
@ambushwork
ambushwork force-pushed the yl/replay-investigation branch from 2e6514d to d9fcc99 Compare April 24, 2025 15:26
@ambushwork
ambushwork merged commit ef654e8 into develop Apr 25, 2025
@ambushwork
ambushwork deleted the yl/replay-investigation branch April 25, 2025 06:53
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.

4 participants