Skip to content

fix: stamp the shell's session and user on records a fragment forwards - #31

Open
fateeand wants to merge 4 commits into
mainfrom
30-broadcast-host-fragment-records-can-carry-a-missing-expired-or-signed-out-session-and-user
Open

fateeand wants to merge 4 commits into
mainfrom
30-broadcast-host-fragment-records-can-carry-a-missing-expired-or-signed-out-session-and-user

Conversation

@fateeand

@fateeand fateeand commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

A fragment's scenario, BI and log records no longer go out with a missing, expired or signed-out session and user. The shell's broadcast host stamps its own current session and user on what a fragment forwards. A fragment's own copy can lag behind: the shell's RUM client starting after the fragment asked, a session expiring, or a sign-out in the shell.

Key Changes

  • Stamping (UwtTelemetryBroadcastHost):
    • forwarded scenario, step and BI records, and forwarded log records, get the host's current sessionId and userId;
    • a scenario record's sessionElapsed is measured again when its session changed;
    • an id the host doesn't have stays undefined, as in the library's own records ('' counts as no user);
    • other event types are recorded as the fragment sent them;
    • a record whose ids already match is passed through unchanged.
  • Docs: DESIGN.md's "Identity across realms" and sessionElapsed sections describe the stamping and its one limit: while the shell's RUM client hasn't started, the host has no session to stamp.

Impact on consumers

  • No API change. Nothing to change in shells or fragments.
  • Fragment records' ids: a forwarded record now names the shell's session and user at the moment the host receives it, matching its RUM batch and a record written in the shell at that moment. Fewer fragment records arrive with no session, an expired one, or a user who has signed out.

Closes #30

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Coverage report

St.❔
Category Percentage Covered / Total
🟢 Statements
97.15% (+0.03% 🔼)
1295/1333
🟢 Branches
95.36% (+0.09% 🔼)
720/755
🟢 Functions
96.97% (+0.02% 🔼)
320/330
🟢 Lines
97.51% (+0.03% 🔼)
1252/1284

Test suite run success

746 tests passing in 24 suites.

Report generated by 🧪jest coverage report action from f4be6d5

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

An active moderate issue remains because empty user IDs are not normalized to undefined, causing forwarded records to retain an incorrect user attribution.

1 open issue
What changed in this PR

This pull request updates the broadcast host to stamp fragment-forwarded telemetry with the shell’s current session and user, refresh scenario timing when sessions change, and document the behavior across realms.

Changes:

  • Stamps forwarded scenario, step, BI, and log records with the host identity.
  • Recalculates sessionElapsed when a forwarded scenario changes sessions.
  • Adds regression coverage and updates the design documentation.
  • Requires changes to normalize an empty host user ID as signed out.
File Summary
projects/​ngx-ui-watchtower/​src/​lib/​sinks/​uwt-broadcast/​uwt-broadcast-host.service.ts Implements host identity stamping and session timing correction. A moderate issue remains: empty user IDs are not omitted.
projects/​ngx-ui-watchtower/​src/​lib/​sinks/​uwt-broadcast/​uwt-broadcast.spec.ts Tests late session initialization, stale identities, custom events, and forwarded logs.
projects/​ngx-ui-watchtower/​DESIGN.md Documents identity correction across realms and updated sessionElapsed behavior.

Review effort: Lite

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

An active moderate finding shows the broadcast fast path can preserve explicit undefined identity properties, violating the new absent-not-undefined contract.

1 open issue
1 resolved since last review

Review effort: Lite

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is warranted because the new scenario-step classification and stamping branch lacks dedicated test coverage for stale session and user identifiers when lifecycle events are enabled.

No open issues 🎉

1 resolved since last review

Review effort: Lite

…-a-missing-expired-or-signed-out-session-and-user
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.

Broadcast host: fragment records can carry a missing, expired or signed-out session and user

2 participants