Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+48
@@ -0,0 +1,48 @@
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { CookieCategory } from "~/application/cookies/CookieCategory";
|
||||
import { useRootData } from "~/utils/data/useRootData";
|
||||
import CookieHelper from "~/utils/helpers/CookieHelper";
|
||||
|
||||
type ReplayModule = typeof import("~/sentry-replay.client");
|
||||
let loadedReplayModule: Promise<ReplayModule> | undefined;
|
||||
|
||||
export default function ScriptSentryReplay() {
|
||||
const rootData = useRootData();
|
||||
const hasAnalyticsConsent = CookieHelper.hasConsent(rootData.userSession ?? null, CookieCategory.ANALYTICS);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
|
||||
if (!hasAnalyticsConsent) {
|
||||
if (loadedReplayModule) {
|
||||
void loadedReplayModule.then(({ disableSentryReplay }) => disableSentryReplay());
|
||||
}
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}
|
||||
|
||||
void import("~/sentry.client").then(({ readClientSentryConfig }) => {
|
||||
const config = readClientSentryConfig();
|
||||
if (cancelled || !config.dsn || (config.replaysSessionSampleRate <= 0 && config.replaysOnErrorSampleRate <= 0)) {
|
||||
return;
|
||||
}
|
||||
loadedReplayModule ??= import("~/sentry-replay.client");
|
||||
void loadedReplayModule.then(({ enableSentryReplay }) => {
|
||||
if (!cancelled) {
|
||||
enableSentryReplay(config);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
if (loadedReplayModule) {
|
||||
void loadedReplayModule.then(({ disableSentryReplay }) => disableSentryReplay());
|
||||
}
|
||||
};
|
||||
}, [hasAnalyticsConsent]);
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in new issue
Block a user