Skip to content

Commit d9b8388

Browse files
committed
shorten chunk validation function
1 parent bbf0794 commit d9b8388

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

packages/browser/src/profiling/utils.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ const MS_TO_NS = 1e6;
3333
// Checking if we are in Main or Worker thread: `self` (not `window`) is the `globalThis` in Web Workers and `importScripts` are only available in Web Workers
3434
const isMainThread = 'window' in GLOBAL_OBJ && GLOBAL_OBJ.window === GLOBAL_OBJ && typeof importScripts === 'undefined';
3535

36-
export const PROFILER_THREAD_ID_STRING = String(0); // todo: ID for Web Worker threads
36+
// Setting ID to 0 as we cannot get an ID from Web Workers
37+
export const PROFILER_THREAD_ID_STRING = String(0);
3738
export const PROFILER_THREAD_NAME = isMainThread ? 'main' : 'worker';
3839

3940
// We force make this optional to be on the safe side...
@@ -271,23 +272,10 @@ export function validateProfileChunk(chunk: ProfileChunk): { valid: boolean; rea
271272
return { valid: false, reason: 'missing or invalid chunk_id' };
272273
}
273274

274-
// client_sdk name/version are required
275-
if (
276-
!chunk.client_sdk ||
277-
typeof chunk.client_sdk.name !== 'string' ||
278-
typeof chunk.client_sdk.version !== 'string'
279-
) {
275+
if (!chunk.client_sdk) {
280276
return { valid: false, reason: 'missing client_sdk metadata' };
281277
}
282278

283-
if (typeof chunk.platform !== 'string') {
284-
return { valid: false, reason: 'missing platform' };
285-
}
286-
287-
if (typeof chunk.release !== 'string') {
288-
return { valid: false, reason: 'missing release' };
289-
}
290-
291279
// Profile data must have frames, stacks, samples
292280
const profile = chunk.profile as { frames?: unknown[]; stacks?: unknown[]; samples?: unknown[] } | undefined;
293281
if (!profile) {

0 commit comments

Comments
 (0)