|
11 | 11 | */ |
12 | 12 |
|
13 | 13 | /* eslint-disable no-console */ |
14 | | -/* eslint-disable no-bitwise */ |
15 | 14 |
|
16 | 15 | import type { DsnComponents } from '@sentry/core'; |
17 | | -import { dsnToString, makeDsn } from '@sentry/core'; |
| 16 | +import { dsnToString, makeDsn, uuid4 } from '@sentry/core'; |
18 | 17 |
|
19 | 18 | const SENTRY_DSN_ENV = 'SENTRY_DSN'; |
20 | 19 | const EAS_BUILD_ENV = 'EAS_BUILD'; |
@@ -95,26 +94,6 @@ function getEnvelopeEndpoint(dsn: DsnComponents): string { |
95 | 94 | return `${protocol}://${host}${portStr}${pathStr}/api/${projectId}/envelope/?sentry_key=${publicKey}&sentry_version=7`; |
96 | 95 | } |
97 | 96 |
|
98 | | -function generateEventId(): string { |
99 | | - const bytes = new Uint8Array(16); |
100 | | - if (typeof crypto !== 'undefined' && crypto.getRandomValues) { |
101 | | - crypto.getRandomValues(bytes); |
102 | | - } else { |
103 | | - for (let i = 0; i < 16; i++) { |
104 | | - bytes[i] = Math.floor(Math.random() * 256); |
105 | | - } |
106 | | - } |
107 | | - const byte6 = bytes[6]; |
108 | | - const byte8 = bytes[8]; |
109 | | - if (byte6 !== undefined && byte8 !== undefined) { |
110 | | - bytes[6] = (byte6 & 0x0f) | 0x40; |
111 | | - bytes[8] = (byte8 & 0x3f) | 0x80; |
112 | | - } |
113 | | - return Array.from(bytes) |
114 | | - .map(b => b.toString(16).padStart(2, '0')) |
115 | | - .join(''); |
116 | | -} |
117 | | - |
118 | 97 | function createEASBuildTags(env: EASBuildEnv): Record<string, string> { |
119 | 98 | const tags: Record<string, string> = {}; |
120 | 99 | if (env.EAS_BUILD_PLATFORM) tags['eas.platform'] = env.EAS_BUILD_PLATFORM; |
@@ -191,7 +170,7 @@ function createBaseEvent( |
191 | 170 | customTags?: Record<string, string>, |
192 | 171 | ): SentryEvent { |
193 | 172 | return { |
194 | | - event_id: generateEventId(), |
| 173 | + event_id: uuid4(), |
195 | 174 | timestamp: Date.now() / 1000, |
196 | 175 | platform: 'node', |
197 | 176 | level, |
|
0 commit comments