Issue
I use the JavaScript Loader Script with Session Replay, and recordings are fully masked. I want to unmask text (or other content) in those replays.
Applies To
All SaaS Customers and Self-Hosted Users
JavaScript Loader Script
Session Replay
Replay privacy (
maskAllText/blockAllMedia)
Resolution
Configure Replay privacy in a custom Sentry.init via window.sentryOnLoad, defined before the Loader Script tag. Do not confuse this with Sentry.onLoad(), which is only for calling SDK methods after the Loader has finished loading.
Enable Session Replay on the Loader in Project Settings → Client Keys (DSN) → Configure.
Add
window.sentryOnLoadbefore the Loader Script and set Replay privacy options there.
<script>
// Must run before the Loader Script
window.sentryOnLoad = function () {
Sentry.init({
integrations: [
Sentry.replayIntegration({
// Only disable defaults if the page has no sensitive data,
// or you already mask/block the sensitive parts another way.
maskAllText: false,
blockAllMedia: false,
}),
],
});
};
</script>
<script
src="https://js.sentry-cdn.com/___PUBLIC_KEY___.min.js"
crossorigin="anonymous"
></script>
Default Replay privacy masks all text and blocks media. Turning those off can capture PII. For partial unmasking, keep the defaults and use unmask / unblock selectors (or the sentry-unmask / related classes) instead of disabling everything.
