JavaScript SDK ⁠-⁠ resanitize method

This method re-evaluates sanitization against the current DOM and re-emits whatever changed, updating already-recorded nodes mid-session.

Sanitization is normally applied when a node is first recorded. If you change what should be obscured or hidden after a node has already been captured, that change won’t be reflected in the replay on its own. Call resanitize() to force the tracker to re-scan and apply the updated sanitization rules to nodes that are already part of the recording.

Call it after:

  • toggling data-openreplay-obscured / data-openreplay-hidden attributes on elements that are already on the page, or
  • changing whatever your domSanitizer keys on (class, id, etc.).
resanitize(el?: Element): void
  • el?: Element: The highest node you changed. The tracker re-scans this element and its subtree. Omit it to re-scan the whole document.

This method does not return any value. The re-evaluated sanitization is applied directly to the ongoing recording and the results are visible in the OpenReplay platform.

// Obscure a section after the user opens sensitive content
const panel = document.getElementById('account-details')
panel.setAttribute('data-openreplay-obscured', '')

// Tell the tracker to re-apply sanitization to that subtree
tracker.resanitize(panel)
// Re-scan the whole document after changing domSanitizer rules
tracker.resanitize()