- 
 
- 
  Notifications
 You must be signed in to change notification settings 
- Fork 1.7k
loader script: configure replay options #8704
-
I'm using the js-sdk-loader, which loads bundle.tracing.replay.min.js. My question is how to configure the replay options?
I tried this, but it didn't always work (due to minification, and onLoad, when loading the page the second time, was firing before all integrations were loaded).
Sentry.onLoad(() => { const {client} = Sentry.getCurrentHub().getStack()[0] Object.assign(client._integrations.Replay._recordingOptions, {maskAllInputs: false, maskAllText: false}) })
I settled on loader.replace(/new \w+.Replay/, '$&({maskAllInputs: false, maskAllText: false})') but it's a bit hacky.
Related: it's also difficult to send the release slug when using the loader. Perhaps if a global variable can be set, that the loader reads from if present (similar to window._sentryDebugIds).
Beta Was this translation helpful? Give feedback.
All reactions
Hey @mustafa0x
My question is how to configure the replay options
You can call Sentry.init again in Sentry.onLoad and configure the replay integration there.
Sentry.onLoad(() => { Sentry.init({ tracesSampleRate: 1.0, replaysSessionSampleRate: 0.1, replaysOnErrorSampleRate: 1.0, integrations: [ new Sentry.Replay({ maskAllInputs: false, maskAllText: false, }), new Sentry.BrowserTracing(), ], }); });
I heavily recommend setting maskAllInputs to false though as you could be sending PII or other sensitive information to Sentry.
Related: it's also difficult to send the release slug when using the loader. Perhaps if a global variable ...
Replies: 1 comment 5 replies
-
Hey @mustafa0x
My question is how to configure the replay options
You can call Sentry.init again in Sentry.onLoad and configure the replay integration there.
Sentry.onLoad(() => { Sentry.init({ tracesSampleRate: 1.0, replaysSessionSampleRate: 0.1, replaysOnErrorSampleRate: 1.0, integrations: [ new Sentry.Replay({ maskAllInputs: false, maskAllText: false, }), new Sentry.BrowserTracing(), ], }); });
I heavily recommend setting maskAllInputs to false though as you could be sending PII or other sensitive information to Sentry.
Related: it's also difficult to send the release slug when using the loader. Perhaps if a global variable can be set, that the loader reads from if present (similar to window._sentryDebugIds).
You can set the window.SENTRY_RELEASE.id variable as a global variable for the release. See the code here:
sentry-javascript/packages/browser/src/sdk.ts
Lines 109 to 112 in 85effab
Docs: https://docs.sentry.io/platforms/javascript/install/loader/#sdk-configuration
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks @AbhiPrasad, appreciated! I can also set the release in .init() too, right? Since I'm calling it anyways.
Beta Was this translation helpful? Give feedback.
All reactions
-
I can also set the release in .init() too, right?
Yup you can!
Beta Was this translation helpful? Give feedback.
All reactions
-
Is this answer still valid?
I'm using the Loader Script SDK 8.x with Enable Session Replay switched on.
But I get an error when trying to adjust maskAllText
<script> window.sentryOnLoad = () => { Sentry.init({ integrations: [ new Sentry.Replay({ maskAllText: false, }), ], }); }; </script> <script src="url-copied-from-sentry-control-panel" crossorigin="anonymous"></script>
produces the following error:
TypeError: Sentry.Replay is not a constructor
Otherwise, Sentry works as expected, but I'd like to find a way to keep the text from being masked on session replays.
PS. Poking around at the Sentry object, this seems to work without throwing errors, but I'm hesitant to use it since .me isn't documented anywhere:
window.Sentry.getClient().getIntegrationByName("Replay").me.maskAllText = false
Beta Was this translation helpful? Give feedback.
All reactions
-
@karlbot Sentry.Replay was renamed to Sentry.replayIntegration in v8 of the SDK.
Beta Was this translation helpful? Give feedback.
All reactions
- 
 👍 1
-
thank you! I had tried that but must've introduced an error somewhere. Anyway can confirm this works:
<script> window.sentryOnLoad = () => { Sentry.init({ integrations: [ Sentry.replayIntegration({ maskAllText: false, }), ], }); }; </script>
Beta Was this translation helpful? Give feedback.