Skip to content

✨ [PANA-8797] Allow session replay to clear its string table - #4988

Merged
sethfowler-datadog merged 1 commit into
mainfrom
seth.fowler/PANA-8797-support-string-table-clearing
Aug 27, 2026
Merged

✨ [PANA-8797] Allow session replay to clear its string table#4988
sethfowler-datadog merged 1 commit into
mainfrom
seth.fowler/PANA-8797-support-string-table-clearing

Conversation

@sethfowler-datadog

Copy link
Copy Markdown
Contributor

Motivation

Session replay recordings extract strings into a string table, and #4983 annotated each entry with the role its string plays on the page so that the backend can mask sensitive content after the fact. Ideally, we could perform that masking based only on the role-annotated string table, but today that would be insufficient, because the string table isn't the only place sensitive strings could appear. The problem is that when the string table reaches its size limit, we stop adding strings to it and start representing them directly inside the replay operations as literal arguments.

To eliminate this problem, we should handle string table overflow in a different way: we should simply clear the string table when it gets too large.

Changes

When the string table reaches its soft maximum size, ChangeEncoder now clears it. After encoding each change, it compares the table's size against the soft max, and clears the table as soon as the limit is reached. The new ClearStrings operation expresses the fact that the string table was cleared in the recording, so that the recorder's encoder and the player's decoder continue to agree on the meaning of string table references.

With this change in place, strings are always transmitted through the string table, and the code that turned them into literals is gone:

  • changeEncoder.ts: the size check and the clear. Clearing the table ends the current run: the changes buffered so far are encoded ahead of the ClearStrings, and the changes that follow start from an empty table. resolvePendingStrings() no longer falls back to a literal.
  • changeEncoder.ts also gained a new module-private RunChangeEncoder helper. This helper owns everything that happens within a run, leaving ChangeEncoder to own only cross-run state. RunChangeEncoder is single-use, which made it possible to eliminate ChangeEncoder's reset logic.
  • changeDecoder.ts / stringTable.ts: the decoder infrastructure (which is only used in tests) now implements ClearStrings, replacing the throwing placeholder from the schema PR. ChangeDecoder also now rejects a string literal in change data (though there's an opt-out for testing purposes). This makes the whole unit and e2e suite enforce that the SDK never puts a string anywhere but the string table.

Checklist

  • Tested locally
  • Tested on staging (I'll push it immediately after pushing the PR.)
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file.

@sethfowler-datadog
sethfowler-datadog requested review from a team as code owners August 26, 2026 16:17
@sethfowler-datadog

Copy link
Copy Markdown
Contributor Author

/to-staging

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Aug 26, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-08-26 16:18:49 UTC ℹ️ Start processing command /to-staging


2026-08-26 16:18:54 UTC ℹ️ Branch Integration: starting soon, merge expected in approximately 16m (p90)

Commit 99116a401c will soon be integrated into staging-35.


2026-08-26 16:36:51 UTC ℹ️ Branch Integration: this commit was successfully integrated

Commit 99116a401c has been merged into staging-35 in merge commit 173ef8474a.

If you need to revert this integration, you can use the following command: /code revert-integration -b staging-35

gh-worker-dd-mergequeue-cf854d Bot added a commit that referenced this pull request Aug 26, 2026
… into staging-35

Integrated commit sha: 99116a4

Co-authored-by: sethfowler-datadog <seth.fowler@datadoghq.com>

@Tizi42 Tizi42 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.

Looks good!

@sethfowler-datadog
sethfowler-datadog force-pushed the seth.fowler/PANA-8797-update-schema-for-string-table-clearing-operation branch from e1b901f to 1619951 Compare August 27, 2026 14:41
Base automatically changed from seth.fowler/PANA-8797-update-schema-for-string-table-clearing-operation to main August 27, 2026 15:02
@sethfowler-datadog
sethfowler-datadog force-pushed the seth.fowler/PANA-8797-support-string-table-clearing branch from 99116a4 to 4323472 Compare August 27, 2026 15:03
@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 181.63 KiB 181.63 KiB 0 B 0.00%
Rum Profiler 8.43 KiB 8.43 KiB 0 B 0.00%
Rum Recorder 25.13 KiB 25.30 KiB +168 B +0.65%
Logs 57.93 KiB 57.93 KiB 0 B 0.00%
Rum Salesforce N/A 139.69 KiB N/A N/A N/A
Rum Slim 139.68 KiB 139.68 KiB 0 B 0.00%
Worker 22.96 KiB 22.96 KiB 0 B 0.00%
Rum Shopify N/A 205.99 KiB N/A N/A N/A
Rum-shopify Profiler N/A 8.43 KiB N/A N/A N/A
Rum-shopify Recorder N/A 3.72 KiB N/A N/A N/A

@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Aug 27, 2026

Copy link
Copy Markdown

Pipelines  Tests

⚠️ Warnings

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 1 Pipeline job failed

DataDog/browser-sdk | build-bundle — 🔄 Retry may pass, looks flaky

View more details · View in GitLab

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 94.74%
Overall Coverage: 77.02% (+0.07%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 4323472 | Docs | View more details | Give us feedback!

@sethfowler-datadog
sethfowler-datadog merged commit d721fc9 into main Aug 27, 2026
29 of 31 checks passed
@sethfowler-datadog
sethfowler-datadog deleted the seth.fowler/PANA-8797-support-string-table-clearing branch August 27, 2026 15:18
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants