-
Notifications
You must be signed in to change notification settings - Fork 128
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
✨ [RUM-3837] Force replay recording on sampled out sessions #2684
base: main
Are you sure you want to change the base?
✨ [RUM-3837] Force replay recording on sampled out sessions #2684
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2684 +/- ##
==========================================
+ Coverage 93.26% 93.28% +0.01%
==========================================
Files 241 241
Lines 7028 7057 +29
Branches 1553 1569 +16
==========================================
+ Hits 6555 6583 +28
- Misses 473 474 +1 ☔ View full report in Codecov by Sentry. |
3e48bbc
to
59d7883
Compare
Bundles Sizes Evolution
🚀 CPU Performance
|
562e9c6
to
7b93d67
Compare
recorderApi.start(options) | ||
addTelemetryUsage({ feature: 'start-session-replay-recording' }) |
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.
💬 suggestion: what about collecting the usage of this new option? 🙂
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.
Definitely 👌
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'll add this in a followup PR, since I need to update rum-event-format
@@ -179,6 +181,16 @@ export function startSessionStore<TrackingType extends string>( | |||
renewObservable.notify() | |||
} | |||
|
|||
function updateSessionInStore(updatedState: Partial<SessionState>) { |
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.
💬 suggestion: could we had a test to ensure that this store update is well propagated to other tabs/store?
@@ -28,6 +29,7 @@ export const enum RumTrackingType { | |||
NOT_TRACKED = '0', | |||
TRACKED_WITH_SESSION_REPLAY = '1', | |||
TRACKED_WITHOUT_SESSION_REPLAY = '2', | |||
TRACKED_WITH_FORCED_REPLAY = '3', |
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.
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.
Yeah, sure. I forgot about it 😅
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.
Done ✔️
@@ -102,13 +106,15 @@ function hasValidRumSession(trackingType?: string): trackingType is RumTrackingT | |||
return ( | |||
trackingType === RumTrackingType.NOT_TRACKED || | |||
trackingType === RumTrackingType.TRACKED_WITH_SESSION_REPLAY || | |||
trackingType === RumTrackingType.TRACKED_WITHOUT_SESSION_REPLAY | |||
trackingType === RumTrackingType.TRACKED_WITHOUT_SESSION_REPLAY || |
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.
💬 suggestion: could we add this new type in the related tests?
It would be nice to ensure somewhere that sessionReplayAllowed
is false for the forced state as it is used to compute sampled_for_replay
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 just a typeguard IIRC, sessionReplayAllowed
compares the tracking type, and is set to true only if the state is TRACKED_WITH_SESSION_REPLAY
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 added a new attribute in the session object that reflect either the session was originally sampled for replay or not, to avoid any confusing (and to fix a small bug I found)
Done ✔️
@@ -84,6 +86,7 @@ export function startSessionManager<TrackingType extends string>( | |||
renewObservable, | |||
expireObservable, | |||
expire: sessionStore.expire, | |||
updateSessionInStore: sessionStore.updateSessionInStore, |
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.
🔨 warning: FMU, updateSessionInStore()
does not update the session entry in sessionContextHistory
. It means that findTrackedSession()
will still return return TRACKED_WITHOUT_SESSION_REPLAY.
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'll check this aspect, I didn't run into any issue while testing though 🤔
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.
From my test when using startSessionReplayRecording({force: true})
on sampled out session, it triggers the expireObservable
. Then I have to interact with the page to trigger the renewObservable
.
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 addressed through the synchronisation mechanism discussed
ed48e1b
to
985f6e8
Compare
Update
192cc6a
to
f6e6a40
Compare
}) | ||
sessionManager.updateSession({ [FIRST_PRODUCT_KEY]: FakeTrackingType.OTHER_TRACKING }) | ||
|
||
expect(sessionManager.findActiveSession()!.id).toBeDefined() |
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.
💬 suggestion:
expect(sessionManager.findActiveSession()!.id).toBeDefined() | |
expectSessionIdToBeDefined() |
const sessionManager = startSessionManagerWithDefaults({ | ||
allowedTrackingTransition: FakeTrackingType.OTHER_TRACKING, | ||
}) | ||
sessionManager.updateSession({ [FIRST_PRODUCT_KEY]: FakeTrackingType.DISALLOWED_TRACKING }) |
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.
💬 suggestion:
sessionManager.updateSession({ [FIRST_PRODUCT_KEY]: FakeTrackingType.DISALLOWED_TRACKING }) | |
expectSessionToBeExpired() |
const a = didSessionIdChange || untoleratedTrackingChange | ||
return a |
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.
💬 suggestion:
const a = didSessionIdChange || untoleratedTrackingChange | |
return a | |
return didSessionIdChange || untoleratedTrackingChange |
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.
seems like this is not an expected change for this PR, is it?
Motivation
Allow session replay recording on sampled out sessions
Changes
On the RUM's public API, session replay recording can be forced even if the session is sampled out for replay. This is achieved by passing
{ force: true }
toDD_RUM.startSessionReplayRecording
function.When this method is called with
force
option, we need to keep recording until the session ends. To achieve that:Testing
I have gone over the contributing documentation.