Skip to content

Commit 2bb4b88

Browse files
authored
fix(platform): Add fallback for crypto.randomUUID() (#12827)
1 parent 74163a0 commit 2bb4b88

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/components/search/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ algoliaInsights('init', {
3333
// We dont want to track anyone cross page/sessions or use cookies
3434
// so just generate a random token each time the page is loaded and
3535
// treat it as a random user.
36-
const randomUserToken = crypto.randomUUID();
36+
const randomUserToken = (() => {
37+
try {
38+
return crypto.randomUUID();
39+
} catch {
40+
// Fallback to a simple random string if crypto.randomUUID() is not available
41+
return Math.random().toString(36).substring(2) + Date.now().toString(36);
42+
}
43+
})();
3744

3845
// this type is not exported from the global-search package
3946
type SentryGlobalSearchConfig = ConstructorParameters<typeof SentryGlobalSearch>[0];

0 commit comments

Comments
 (0)