Skip to content

Commit 99805e6

Browse files
committed
imp(sentry): types cast
1 parent da487bf commit 99805e6

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

workers/sentry/src/index.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,21 @@ export default class SentryEventWorker extends Worker {
6767
if (itemHeader.type !== 'event') {
6868
return;
6969
}
70-
71-
const hawkEvent = this.transformToHawkFormat(envelopeHeaders as EventEnvelope[0], item as EventItem, projectId);
72-
7370
const payloadHasSDK = typeof itemPayload === 'object' && 'sdk' in itemPayload;
74-
71+
7572
/**
7673
* @todo react-native could be added if we support source-map sending for Metro bundler
7774
*/
7875
const sentryJsSDK = ['browser', 'react', 'vue', 'angular', 'capacirtor', 'electron'];
76+
77+
const isJsSDK = payloadHasSDK && sentryJsSDK.includes(itemPayload.sdk.name)
78+
79+
const hawkEvent = this.transformToHawkFormat(envelopeHeaders as EventEnvelope[0], item as EventItem, projectId);
7980

8081
/**
8182
* If we have release attached to the event
8283
*/
83-
if (payloadHasSDK && sentryJsSDK.includes(itemPayload.sdk.name) && hawkEvent.payload.release !== undefined) {
84+
if (isJsSDK) {
8485
await this.addTask(WorkerNames.JAVASCRIPT, hawkEvent as JavaScriptEventWorkerTask);
8586

8687
return;
@@ -105,7 +106,8 @@ export default class SentryEventWorker extends Worker {
105106
private transformToHawkFormat(
106107
envelopeHeader: EventEnvelope[0],
107108
eventItem: EventItem,
108-
projectId: string
109+
projectId: string,
110+
isJsSDK: boolean,
109111
): DefaultEventWorkerTask | JavaScriptEventWorkerTask {
110112
/* eslint-disable @typescript-eslint/naming-convention */
111113
const { sent_at, trace } = envelopeHeader;
@@ -170,8 +172,8 @@ export default class SentryEventWorker extends Worker {
170172

171173
return {
172174
projectId,
173-
catcherType: this.type as 'errors/default',
174-
payload: event as CatcherMessagePayload<typeof this.type>,
175+
catcherType: isJsSDK ? 'errors/javascript' : 'errors/default',
176+
payload: event as isJsSDK ? CatcherMessagePayload<'errors/javascript'> : CatcherMessagePayload<'errors/default'>,
175177
timestamp: sentAtUnix,
176178
};
177179
}

0 commit comments

Comments
 (0)