Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion workers/sentry/src/utils/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ function flattenObject(obj: unknown, prefix = ''): string[] {
* @param eventPayload - Sentry event payload
*/
export function composeTitle(eventPayload: SentryEvent): string {
return `${eventPayload.exception?.values?.[0]?.type || 'Unknown'}: ${eventPayload.exception?.values?.[0]?.value || ''}`;
const exception = eventPayload.exception?.values?.[0];

if (exception) {
return `${exception.type || 'Unknown'}: ${exception.value || ''}`;
}

return eventPayload.message || 'Unknown: ';
}

/**
Expand Down
22 changes: 22 additions & 0 deletions workers/sentry/tests/converter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@ describe('converter utils', () => {

expect(composeTitle(event)).toBe('Unknown: ');
});

it('should compose title from message if exception is missing', () => {
const event: SentryEvent = {
message: 'message'
};

expect(composeTitle(event)).toBe('message');
});

it('should compose title from exception type and value even if message is present', () => {
const event: SentryEvent = {
exception: {
values: [ {
type: 'Error',
value: 'Something went wrong',
} ],
},
message: 'message'
};

expect(composeTitle(event)).toBe('Error: Something went wrong');
});
});

describe('composeBacktrace()', () => {
Expand Down
2 changes: 1 addition & 1 deletion workers/sentry/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ describe('SentryEventWorker', () => {
},
},
catcherVersion: '1.0.1',
title: 'Unknown: ',
title: 'Test timestamp',
type: 'error',
},
}));
Expand Down
Loading