Skip to content

Commit bd7482c

Browse files
RealBhupeshmsonnb
andauthored
fix(browser)!: stop tagging DOMException.code on events (#23992)
## Summary - Stop setting the deprecated `DOMException.code` as an event tag - `DOMException.name` remains available via `error.type` on the exception payload Fixes #10501 ## Test plan - [x] Added regression test in `packages/browser/test/eventbuilder.test.ts` - [ ] CI --------- Co-authored-by: Martin Sonnberger <martin.sonnberger@sentry.io>
1 parent 374b46f commit bd7482c

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

‎MIGRATION.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,12 @@ Sentry.init({
567567
});
568568
```
569569

570+
### `DOMException.code` is no longer set as a tag
571+
572+
Affected SDKs: All SDKs running in the browser.
573+
574+
Events created from a `DOMException` no longer carry a `DOMException.code` tag. The `code` property is deprecated and has been replaced by `DOMException.name`, which is already available as the exception type. If you have searches or alert rules keyed on the tag, switch them to `error.type`.
575+
570576
### `attachStacktrace` defaults to `true`
571577

572578
Affected SDKs: All SDKs.

‎packages/browser/src/eventbuilder.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,6 @@ export function eventFromUnknownInput(
302302
event = eventFromString(stackParser, message, syntheticException, attachStacktrace);
303303
addExceptionTypeValue(event, message);
304304
}
305-
if ('code' in domException) {
306-
// eslint-disable-next-line typescript/no-deprecated
307-
event.tags = { ...event.tags, 'DOMException.code': `${domException.code}` };
308-
}
309305

310306
return event;
311307
}

‎packages/browser/test/eventbuilder.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,15 @@ describe('eventFromUnknownInput', () => {
294294
}),
295295
);
296296
});
297+
298+
it('does not set the deprecated DOMException.code as an event tag', () => {
299+
const exception = new DOMException('Permission denied', 'NotAllowedError');
300+
301+
const event = eventFromUnknownInput(defaultStackParser, exception);
302+
303+
expect(event.exception?.values?.[0]?.type).toBe('NotAllowedError');
304+
expect(event.tags).toBeUndefined();
305+
});
297306
});
298307

299308
describe('extractMessage', () => {

0 commit comments

Comments
 (0)