37 lines
819 B
TypeScript
37 lines
819 B
TypeScript
import * as Sentry from "@sentry/react-router";
|
|
|
|
export type SentryReplayConfig = {
|
|
replaysSessionSampleRate: number;
|
|
replaysOnErrorSampleRate: number;
|
|
};
|
|
|
|
export function enableSentryReplay(config: SentryReplayConfig): boolean {
|
|
if (!Sentry.isInitialized() || (config.replaysSessionSampleRate <= 0 && config.replaysOnErrorSampleRate <= 0)) {
|
|
return false;
|
|
}
|
|
|
|
const existing = Sentry.getReplay();
|
|
if (existing) {
|
|
existing.start();
|
|
return true;
|
|
}
|
|
|
|
Sentry.addIntegration(
|
|
Sentry.replayIntegration({
|
|
blockAllMedia: true,
|
|
maskAllInputs: true,
|
|
maskAllText: true,
|
|
}),
|
|
);
|
|
return true;
|
|
}
|
|
|
|
export async function disableSentryReplay(): Promise<boolean> {
|
|
const replay = Sentry.getReplay();
|
|
if (!replay) {
|
|
return false;
|
|
}
|
|
await replay.stop();
|
|
return true;
|
|
}
|