JavaScript SDK - resanitize 方法
此方法会针对当前 DOM 重新评估脱敏,并重新发送所有发生变化的内容,在会话进行中更新已经录制的节点。
脱敏通常在节点首次被录制时应用。如果你在某个节点已被捕获之后更改了应被遮蔽或隐藏的内容,该更改不会自动反映到回放中。调用 resanitize() 可强制 tracker 重新扫描,并将更新后的脱敏规则应用到已经属于录制内容的节点上。
请在以下情况之后调用它:
- 在已经位于页面上的元素上切换
data-openreplay-obscured/data-openreplay-hidden属性,或 - 更改了你的
domSanitizer所依据的内容(class、id 等)。
resanitize(el?: Element): void
el?: Element:你所更改的最上层节点。tracker 会重新扫描该元素及其子树。省略它则会重新扫描整个文档。
此方法不返回任何值。重新评估后的脱敏会直接应用到正在进行的录制中,结果可在 OpenReplay 平台中查看。
// 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()