Repository navigation
Conversation
Contributor
Coverage report
Show new covered files 🐣
Show files with reduced coverage 🔻
Test suite run success741 tests passing in 24 suites. Report generated by 🧪jest coverage report action from f348d04 |
There was a problem hiding this comment.
🟡 Changes recommended
The RUM sink can record a session start despite suppressSessionStartEvent, contradicting the documented behavior.
1 open issue
What changed in this PR
Adds optional sessionElapsed timing to scenario records by persisting RUM session start times across reloads and fragments while preserving the existing elapsed field.
Changes:
- Adds resilient
localStorage-backed session-start tracking and exportsuwtMarkSessionStart. - Populates
sessionElapsedfrom the record’s session ID. - Integrates session detection into the RUM sink and adds tests and documentation.
- One moderate issue remains: the initial cookie-detection fallback does not honor
suppressSessionStartEvent.
| File | Description |
|---|---|
projects/ngx-ui-watchtower/src/public-api.ts |
Exposes the custom session-start marker API. |
projects/ngx-ui-watchtower/src/lib/utils/uwt-session-start.util/uwt-session-start.util.ts |
Stores recent session starts and calculates elapsed time. |
projects/ngx-ui-watchtower/src/lib/utils/uwt-session-start.util/uwt-session-start.util.spec.ts |
Tests storage, retention, invalid data, and blocked storage. |
projects/ngx-ui-watchtower/src/lib/sinks/uwt-broadcast/uwt-broadcast.spec.ts |
Verifies fragment records use the shell session timeline. |
projects/ngx-ui-watchtower/src/lib/scenario/uwt-scenario/uwt-scenario.ts |
Adds sessionElapsed during record creation and renames duration state. |
projects/ngx-ui-watchtower/src/lib/scenario/uwt-scenario/uwt-scenario.spec.ts |
Tests known and unknown session timing behavior. |
projects/ngx-ui-watchtower/src/lib/models/uwt-scenario.models/uwt-scenario.models.ts |
Defines and documents the optional record field. |
projects/ngx-ui-watchtower/rum/src/lib/uwt-rum-telemetry.sink/uwt-rum-telemetry.sink.ts |
Detects RUM session starts and persists their timestamps. |
projects/ngx-ui-watchtower/rum/src/lib/uwt-rum-telemetry.sink/uwt-rum-telemetry.sink.spec.ts |
Tests RUM session-start detection and cookie behavior. |
projects/ngx-ui-watchtower/DESIGN.md |
Documents session timeline semantics and storage behavior. |
Review effort: Lite
…nce-the-rum-session-started
…nce-the-rum-session-started
…nce-the-rum-session-started
fateeand
deleted the
19-scenario-records-add-sessionelapsed-ms-since-the-rum-session-started
branch
October 29, 2026 15:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Overview
Scenario records get an optional
sessionElapsedfield: milliseconds since the RUM session started, which survives reloads. The RUM client keeps no start time, so the RUM sink records it and the scenario reads it back.Key Changes
UwtRumTelemetrySink):session_startevent and records the moment, which covers a session starting after 30 idle minutes or on sign-out;cwr_s, orcwr_s_<id>withunique) appear and records that moment instead. It only checks that the cookie exists, never its contents;sessionLengthSecondsof 0 would cause.uwt-session-start.util): onelocalStorageentry,ngx-ui-watchtower.sessionStarts, holding the five most recent session ids with their start times. Five, because tabs can drift onto different sessions. It never throws: blocked storage, corrupt values and non-finite times are all handled.UwtScenario):toRecord()looks up the record's ownsessionIdand setssessionElapsed, or leaves it out.localStorage(a Web Fragments iframe is same-origin and unsandboxed), so fragment and shell records sit on the same timeline.uwtMarkSessionStart(sessionId), so a custom destination that owns its sessions can record starts too. The reader stays internal.When the field is absent
The field is left out rather than guessed when:
suppressSessionStartEventis on, cookies are off, orlocalStorageis blocked;pagesToExclude, or before this version was running;Impact on consumers
elapsedkeeps its meaning.Closes #19