Skip to content

Commit ea5a0bd

Browse files
fix: Add Web Crypto feature detection for BotID in React Native WebView (calcom#24790)
* fix: Add Web Crypto feature detection for BotID in React Native WebView Fixes calcom#24360 - Add feature detection to check for window.crypto availability before initializing BotID - Skip BotID initialization in React Native WebView environments - Prevents 'undefined is not an object (evaluating crypto)' error during booking - BotID requires Web Crypto API which is not available in React Native WebView Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * refactor: Use minimal feature detection for BotID initialization - Remove React Native WebView-specific check - Use pure feature detection for Web Crypto API - Check for window.crypto.getRandomValues availability - Add SSR guard with typeof window check This approach is more robust and environment-agnostic, working across all environments that lack Web Crypto support, not just React Native. Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 67c9fd9 commit ea5a0bd

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

apps/web/instrumentation-client.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ export function onRouterTransitionStart(url: string, navigationType: "push" | "r
5050
}
5151
}
5252

53-
process.env.NEXT_PUBLIC_VERCEL_USE_BOTID_IN_BOOKER === "1" &&
53+
if (
54+
process.env.NEXT_PUBLIC_VERCEL_USE_BOTID_IN_BOOKER === "1" &&
55+
typeof window !== "undefined" &&
56+
typeof window.crypto?.getRandomValues === "function"
57+
) {
5458
initBotId({
5559
protect: [
5660
{
@@ -59,3 +63,4 @@ process.env.NEXT_PUBLIC_VERCEL_USE_BOTID_IN_BOOKER === "1" &&
5963
},
6064
],
6165
});
66+
}

0 commit comments

Comments
 (0)