Skip to content

ADR-0077: Session replay, its own yes, masked in the browser and checked at the relay

Status: Accepted Date: 2026-10-23 Deciders: Alex Nodeland

For the replay half of phase 6 of lattice RFC-0008 (#361), on ADR-0076's copy to Umami and stackr ADR-0050's profile. It is built and off. It stays off in every release until the owner signs off its privacy review.

Context

  • Replay is the riskiest thing portalr could collect. A recording of a page can hold anything on it, and a mask that misses one word has leaked it. So no one wall is trusted: the browser masks, the relay checks again, and Umami's website keeps nothing unless an operator turns that on too.
  • Umami 3.4.0 keeps a replay in the session a send names, by the token its answer carries, and says in a 200 that its website's replay is off (recorder_disabled) rather than failing. Its own recorder is rrweb ^2.0.1.
  • rrweb 2.0.1 masks text and input values, not attributes: it has no maskAttributeFn, so a link's href, a title or an aria-label is recorded as the page has it.
  • Analytics' switch is the pattern (#622), and the first page's bytes are budgeted tightly (ADR-0040, ADR-0044).

Decision

  • Replay is off unless two things are on, and each person's own yes is a third.
    • The application's PORTAL_REPLAY (stackr's template) builds the relay with replay, and config.json says replay: true. Without it there are no replay routes, no switch, and nothing is loaded.
    • stackr's UMAMI_REPLAY makes umami-init set the website's replayConfig on every run, so turning it off in .env turns it off in Umami. Both default false.
    • A person's yes to replay is a row of its own (portalr_replay_consent, migration 0003, with row-level security as the analytics table has). The relay refuses it until the person has said yes to analytics (a 422, invalid), and a no to analytics withdraws replay too, owing the deletion as analytics does.
  • The routes are GET and PUT /v1/analytics/replay/consent, and POST /v1/analytics/replay, which take the events route's tenant, membership and session rules.
    • A batch is at most 200 events and 512 KiB, and a person may send 128 KiB of replay a second after a 1 MiB burst (a batch costs its size in bytes, or 8 KiB if smaller; the work of checking one is bounded by the 512 KiB it can be); past it the answer is a 429. The route has its own response texts in the document (413 at 512 KiB, 429 in bytes of replay).
    • It is forwarded only if both yeses are still read as yes and Umami's website is read as keeping replays (portalr's user reads its recorderEnabled and replayConfig.replayEnabled, believed for a minute, one question at a time, and a question that fails is not asked again for 30 seconds; unsure is no, and config.json waits at most a second). Otherwise the answer is recorded: 0, nothing is sent, and config.json says replay: false. Its copy is sent in the background, as the events' is.
    • A yes to replay is read against analytics' yes again after it is written, and withdrawn at once, with its deletion settled, if an analytics no landed between the check and the write, so a replay yes cannot outlive an analytics no.
  • The recorder is a lazy add-on, replay, in the app alone (the admin UI never records, so Access there is never recorded). rrweb is pinned to 2.0.1, the version Umami's own ^2.0.1 resolves to; its helper packages rrweb-snapshot, rrdom, @rrweb/types and @rrweb/utils are pinned to 2.1.7 by the root package.json's overrides and by bun.lock. rrweb alone lacks a licence file, so it has an exception in the notices policy; the helpers ship theirs.
    • It is fetched only when the deployment records replays and the person has said yes to both. Someone who has not never loads rrweb, and a build fails if rrweb is anywhere but this add-on's chunk (onlyWithAddOn).
    • The recorder starts on the relay's yes, not the switch's: replay's switch shows an answer only once the relay has it, and the answer is read again whenever the window is focused, so a withdrawal in another tab stops this tab's recording. A batch the relay records none of, or won't take the session for, stops the recording too.
    • Masked as rrweb records: every text (maskTextSelector: "*", each character an asterisk, so a text keeps its length and the page its layout), every input's value (maskAllInputs, and a fixed eight asterisks, so a password's length is not said), and slimDOMOptions: "all". No canvas, fonts or images are read, and the pointer's path is not recorded: where the person clicks and scrolls is.
    • Blocked, and it fails closed. A page's main is blocked, recorded as an empty box of its size, unless the page marks itself data-portalr-replay="allow" as a direct child of the content area (a mark deeper opens nothing). So a page that says nothing, a page added later, and the not-found pages (which echo an address) are not recorded. Only the runs page marks itself. It has no chat, file, form, markdown renderer or free-text field, and what names things on it is blocked in its own cells: a thread's title, a rule's name, the tracker items, and the thumbs with their comment. What is recorded of it is its structure, statuses, counts, times and buttons, with their text masked. The rules page has a form for installing a rule, the threads list a message preview, and the artifacts, proposals, thread and artifact pages content, so none is allowed. A page that suspends while it reads arrives after the first snapshot, with main still blocked, so the recorder takes a new full snapshot when a page marks itself allow; leaving for a page that doesn't blocks main again at once, and what is added under it is not recorded. Also blocked, wherever they are: what a page marks block (a thread and an artifact), every frame (mini apps run in one), and every dialog but the navigation drawer's, which holds who has access to a thread and its confirmations. A test lists every route in routes.json and holds each to this table, and checks that no chat, file or free-text surface is drawn outside a blocked box.
    • The shell is recorded: the header, the navigation, the switcher and the account menu are outside main, with every text masked.
  • What may be sent unmasked is an allow-list, analytics/replay_allowlist.json, which the recorder and the relay both read. The relay is a second look at what the recorder sent, not a second opinion on what is structural: one file means a pattern that is wrong is wrong in both. What the relay adds is that a recorder that fails to mask, or a batch from something else, is dropped whole. A string is asterisks and spaces, or it is kept by what the list says of its key, and it is masked (in the browser) or the batch is dropped (at the relay) if it is neither:
    • A key of an event or a node must be one rrweb's events have; any other goes, whatever it holds.
    • An attribute is kept only if its name is on the list (or is a data-* or aria-* name, whose value must then be masked), and its value fits the pattern of that name: class, id, role, type, tabindex, lang, dir, rel, target, for, form, headers, autocomplete, inputmode, disabled, checked, hidden, open, readonly, required, multiple, selected, draggable, contenteditable, focusable, colspan, rowspan, width, height, rr_width, rr_height, viewBox, d, points, transform, x, y, x1, x2, y1, y2, cx, cy, r, rx, ry, stroke-width, stroke-linecap, stroke-linejoin, stroke-dasharray, fill, stroke, fill-rule, clip-rule, opacity, aria-expanded, aria-hidden, aria-checked, aria-selected, aria-pressed, aria-disabled, aria-current, aria-haspopup, aria-live, aria-busy, aria-modal, aria-orientation, aria-sort, aria-atomic, aria-multiselectable, aria-required, aria-readonly, aria-invalid, aria-autocomplete, aria-level, aria-posinset, aria-setsize, aria-valuenow, aria-valuemin, aria-valuemax, aria-labelledby, aria-describedby, aria-controls, aria-owns, aria-activedescendant, rr_css, rr_scrollLeft, rr_scrollTop, inert, autofocus, popover, loading, crossorigin, decoding, fetchpriority, spellcheck, translate, enterkeyhint, wrap, scope, playsinline, controls, loop, muted, autoplay, preload, default, reversed, ismap, formnovalidate, novalidate, nomodule, async, defer. The browser leaves out an attribute whose name the list doesn't know, and the relay refuses the batch that has one. A pattern is a single identifier (an id, a for), a list of them, an enumeration, a number, a path of numbers, a class list, or a fixed set of words (rel, autocomplete, and fill and stroke, which take only none, currentColor, transparent, inherit, a hex colour or a url(#id)); xmlns only a known namespace; data-portalr-replay only block or allow (the browser sends block for any other value). Every other string under a worded key (value, text, placeholder, title, alt, href, src, srcset, action, content, label, name, aria-label and the like) must be masked, and holds a string or nothing. A number or a boolean is kept only under a name on the list; a list or an object, only the changes to style. A string in a list must be masked.
    • Every string is capped in length before any pattern is tried (256 characters unless the list says more: 1,000 for a class list, 4,000 for a path, 2 KiB for a style), and every pattern is written to match in time linear in its input, with no ambiguous repeat. A test takes every pattern in the list and every one the module compiles, in Python and in TypeScript, and feeds each repeats, near-matches and unterminated openers, checking that twice the input takes about twice the time (the TypeScript tests compare sizes with each other, not with a fixed time, since a CI browser is slow), so a pattern added later cannot regress. An inline style must be ASCII, since a Kelvin sign folds to a k in lower case. The relay's check runs off the event loop, in a thread.
    • A document type keeps its plain name (html), and its public and system ids only if they are one of the standard W3C pairs, since a player builds the document from them and fails on a mask. A node is a document type only by that shape.
    • No stylesheet text comes from a browser. The first version read the CSS a browser sent and tried to prove it held no text; every round found another way for CSS to hide text (comments around strings, escapes, custom properties, @counter-style), so the relay no longer reads any. A page's own stylesheet, which rrweb inlines from a <link>, is named by the recorder (rr_css, the file's name, if the link is to a CSS file of the page's origin), and the relay puts in the text of the file of that name from the application's own app/assets, read at startup. The recorder names only a CSS file in an assets directory of the page's origin. A name the relay doesn't serve (a tab from before a deploy) gets a rule that does nothing, and the batch goes on. A name is a few bytes and a file's text is not, so a batch may name at most 8 stylesheets and the texts may add at most 1 MiB, or the batch is dropped before anything is forwarded; the limiter charges a batch its size with what the stylesheets would add. Any other CSS (a <style> element, a rule a script inserts, replaceSync) is not sent: its text is empty, or x{} whatever its length, a rule that does nothing. The replay is styled by the application's stylesheet as it is built; styles a script adds at run time are missing from it, as is the deployment's brand stylesheet.
    • An inline style is at most 2 KiB of declarations, each a property from a list (layout, size, position, overflow, a few more) or a custom property's name, and values of numbers with units and keywords from a list: no string, url(), var(), escape or comment. The changes to it that rrweb sends, and a change to one declaration, are held to the same rule.
    • rrweb's placeholder for a script is the page's, not what ran.
    • The tests are written apart from the file. A sentence with a quotation mark stamped into 289 attributes, a style element, an svg text, a shadow root, an editable, an option, a meta and a title reaches neither the browser's batches nor, in a Python test from its own list, any batch the relay accepts. A bare word stamped into each attribute is kept by exactly the names that name or enumerate things (written out in both tests). The Chromium fixture, tests/fixtures/replay_chromium.json, is a regression snapshot, not something a test writes: the events the recorder sent for the sentence page, captured once in Chromium by posting them from the test to a local listener, to be captured again when the recorder's output changes shape. The relay's rule is held to it.
    • What still passes, by design: a bare word in an id, a class, a role, a for, a target or an enumeration, since these are the page's own identifiers; a page that built an id from a person's words would leak it (the app's ids are opaque, and the review is to look). Numbers pass: a width, a tabindex, an aria-valuenow. checked, selected, disabled, aria-checked, aria-pressed and an input's isChecked pass, so they say whether a box is ticked or an item chosen: "anything you type is hidden" is true of text, not of whether a control is on. A masked data-* or aria-* name is kept, so the page's own names for them are recorded.
    • Sent in batches of 50 events, or after five seconds, under a session id portalr signs for the person, as analytics' are; one that fails, or is over 500,000 bytes, is dropped and never retried. The page's address in the first event is a fixed width. The first batch, which holds the page and its styles, is small now that the stylesheet is named, not sent. The recording is stopped when the relay records none of a batch, and tried again after a minute if the person's yes is still read. Where the browser has no :has(), the selector that blocks main is not valid, so the recorder does not start.
  • Umami gets a visit in the person's session, as analytics' events do (<tenant's tag>:<keyed hash>, ADR-0076), sent once for ten minutes of the person's batches, then the events with the token its answer gave. Nothing of the person is sent but that hash: portalr's own address and agent, a test holds it. The same distinct id means the removal from a tenant (ADR-0075) deletes that tenant's session alone, with its replays, and another tenant's stays.
  • A no to replay deletes the person's whole Umami session, and its journeys with it. Umami keeps a replay inside the session it is sent in, so there is no deleting the recording alone: the person's sessions there, in every tenant, go, with the page journeys ADR-0076 copies to them. ClickHouse's events, the record, stay. The switch's approved words, "Turning it off deletes your recordings", are true and say less; the privacy guide says the rest.
  • The switch is in the account menu's Privacy group, after analytics': "Record my sessions to improve the app", with its words and its link "What is recorded, and how it is kept (opens in a new tab)", to the privacy guide's session replay.
    • It is on offer while analytics is on. A yes the relay would refuse is not offered. A no to analytics hides it, and drops what the app read of replay's answer: the relay has withdrawn it, the app reads it again once the no is recorded, and a later yes to analytics finds replay off.
    • A deletion owed is said in the menu, "Deleting your recordings hasn't finished yet. It will be retried until it is done.", whether or not the switch is on offer, and read again every 30 seconds until it is done.
    • A screen reader hears its own status beside analytics': on, off, off with the deletion owed, and, when an answer wasn't recorded, the menu's one sentence ("Your answer wasn't saved, so nothing has changed. Try again.") before the answer it kept. No text of a server's is ever shown (ADR-0070).
    • Its code is in the add-on, the answer, the words and the status, and the menu draws it through one slot of AnalyticsAnswer (replay), so the first page holds none of them. The menu's two switches are one component.
  • Budgets: the app's first page grows by 77 bytes of gzip (202,761 to 202,838 of 203,000), for the loading of the add-on and the chunk the hooks share. The replay add-on is 58,423 bytes (ceiling 61,000, and 2 kB of it the allow-list) and replay-account 1,248 (ceiling 1,400); neither counts in app.total, which does include the chunk the hooks share.
  • Verified against Umami 3.4.0 with UMAMI_REPLAY=false and true: a replay is refused with recorder_disabled when off, kept when on, listed by the website, and gone with the person's sessions when they are deleted; its website says whether it keeps replays (recorderEnabled, replayConfig.replayEnabled); a visit's token serves a person's batches until their sessions are deleted. A recording the app's own page made in a browser passes the relay's check and Umami keeps it. replayConfig takes replayEnabled, heatmapEnabled, sampleRate, maskLevel, maxDuration and blockSelector and drops any other key; a partial update merges, so umami-init leaves an operator's other keys as they are. It has no retention key.
  • Not decided here, and the review's: a replay is not linked to the traces of its session (RFC-0008's session.id join).
  • Retention is stackr's umami-retention, a follow-up to this change that the owner chose, since Umami 3.4.0 has no retention setting and its API (DELETE on a session) deletes a recording only with its whole session and journeys; a replay, GET only, cannot be deleted alone.
    • It deletes rows of umami.session_replay older than UMAMI_REPLAY_RETENTION_DAYS (30 by default; 0 keeps them; at most 36500), by the time each chunk was stored, as Umami's own database role, on Umami's database network alone, every six hours. Sessions, events and journeys stay. A saved replay (a bookmark) left with no recording is deleted.
    • It deletes by chunk, which is stricter than by session, on purpose: the older part of a long session goes at once, and what remains of it may not play back. That is the privacy-protective choice; a recording is not kept whole for the sake of its newest chunk.
    • It runs whether or not replay is on. It only deletes, so recordings made before replay was turned off still expire on the same schedule. The service exists with the umami profile.
    • It is bounded (1,000 rows a batch, 100 batches a run, and it says when there may be more), idempotent, and bounds its waits (lock_timeout 10 s, statement_timeout 5 min). A bad setting or a database it can't read exits non-zero, so Compose restarts it; it has an init for signals; its marker file is on a tmpfs, so a service that has finished no run for a day, however it got there, is unhealthy.
    • It is checked against a real Umami 3.4.0 (scripts/check-umami-retention, CI's "Umami retention" job), run as compose.yaml runs it: old chunks go and recent ones stay, nothing else does, a bad or too large number and a wrong password fail, a batch of one deletes one and says there may be more, a second run finds nothing, loop mode writes its marker and stops at once, and Umami still serves what is left.
    • Review point 9 closes when this change merges.

Options considered

  • Masking in the browser alone, as rrweb does: one missed attribute leaks. A second check at the relay costs a pass over each batch.
  • A relay that cleans a batch, instead of dropping it: it would have to know every shape of rrweb's events, and a mistake would send what it meant to remove. A dropped batch fails closed.
  • Blocking by route, in the recorder: it would name every route, and a new one would be recorded until someone named it. Blocking main unless a page allows itself fails closed: a new page is not recorded until someone marks it.
  • A deny-list of the keys that carry words, which the first version of the relay was: a key no one listed, such as a new attribute, leaked. The allow-list masks what it does not know.
  • Reading the CSS a browser sends for text: five rounds of review found five ways round it. Naming the app's own stylesheet and giving the relay's copy leaves nothing of a client's to read.
  • Replay on analytics' switch: a person who agrees to which pages they open has not agreed to a recording of them.

Consequences

  • A deployment that wants replay does three things: sets PORTAL_REPLAY and UMAMI_REPLAY, and has the review signed off. Each person then decides.
  • A batch over 500,000 bytes, such as a very large page's first, is not recorded, and the replay of that session has no start. The first of the app's own is a quarter of that.
  • rrweb is pinned in the app's package.json, and Renovate moves it; a move needs a look at what it records.
  • A new attribute, standard or a library's, is masked until replay_allowlist.json names it with a pattern and a test; a page that should be recorded says so with allow. Both fail closed, and cost a replay that shows less.
  • The allow-list is read by Python and by TypeScript, so the two cannot drift; its tests are written apart from it.