Commit 7e266b4e authored by Robert Knight's avatar Robert Knight

Handle potentially undefined `event.extra` field

This issue was noticed after a TypeScript update.
parent e822ee15
......@@ -88,6 +88,9 @@ export function init(config) {
try {
const originalErr = hint && hint.originalException;
if (originalErr instanceof Event) {
if (!event.extra) {
event.extra = {};
}
Object.assign(event.extra, {
type: originalErr.type,
// @ts-ignore - `detail` is a property of certain event types.
......
......@@ -164,7 +164,7 @@ describe('sidebar/util/sentry', () => {
it('extracts metadata from thrown `Event`s', () => {
sentry.init({ dsn: 'test-dsn' });
const beforeSend = getBeforeSendHook();
const event = { extra: {} };
const event = {};
beforeSend(event, {
originalException: new CustomEvent('unexpectedevent', {
......@@ -184,7 +184,7 @@ describe('sidebar/util/sentry', () => {
it('ignores errors serializing non-Error exception values', () => {
sentry.init({ dsn: 'test-dsn' });
const beforeSend = getBeforeSendHook();
const event = { extra: {} };
const event = {};
const originalException = new CustomEvent('unexpectedevent');
Object.defineProperty(originalException, 'detail', {
get: () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment