Skip to content

Scheduling infrastructure for absolutely everyone.

fix: Add Web Crypto feature detection for BotID in React Native WebView (#24790)

Hariom Balharaea5a0bd5f0a8
diff --git a/apps/web/instrumentation-client.ts b/apps/web/instrumentation-client.ts
index c233ab66132..dfc63ad88b9 100644
--- a/apps/web/instrumentation-client.ts
+++ b/apps/web/instrumentation-client.ts
@@ -50,7 +50,11 @@ export function onRouterTransitionStart(url: string, navigationType: "push" | "r
}
}
-process.env.NEXT_PUBLIC_VERCEL_USE_BOTID_IN_BOOKER === "1" &&
+if (
+ process.env.NEXT_PUBLIC_VERCEL_USE_BOTID_IN_BOOKER === "1" &&
+ typeof window !== "undefined" &&
+ typeof window.crypto?.getRandomValues === "function"
+) {
initBotId({
protect: [
{
@@ -59,3 +63,4 @@ process.env.NEXT_PUBLIC_VERCEL_USE_BOTID_IN_BOOKER === "1" &&
},
],
});
+}