JavaScript SDK - checkSanitization method

Details about the checkSanitization method from OpenReplay's SDK

JavaScript SDK ⁠-⁠ checkSanitization method

This method returns the sanitization level the tracker currently applies to a recorded node. It’s useful for debugging masking rules, for example after calling resanitize().

checkSanitization(el: Node): SanitizeLevel | undefined
  • el: Node: The DOM node to check.

Returns the node’s current level: 0 (Plain), 1 (Obscured) or 2 (Hidden), matching the SanitizeLevel enum exported by @openreplay/tracker. Returns undefined if the node isn’t tracked or the tracker isn’t initialized.

import { tracker, SanitizeLevel } from '@openreplay/tracker'

const level = tracker.checkSanitization(document.getElementById('account-details'))
if (level === SanitizeLevel.Plain) {
  console.warn('account details are recorded in plain')
}