-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(browser): Mark stack trace from
captureMessage
with `attachStac…
…ktrace: true` as synthetic (#14668) Add the `synthetic: true` flag to the `mechanism` of a synthetic exception captured alongside a `captureMessage` call. Setting this property marks the exception as synthetic for processing on the backend
- Loading branch information
Showing
5 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
...ntegration-tests/suites/public-api/captureMessage/simple_message_attachStackTrace/init.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
window.Sentry = Sentry; | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
attachStacktrace: true, | ||
}); |
1 change: 1 addition & 0 deletions
1
...gration-tests/suites/public-api/captureMessage/simple_message_attachStackTrace/subject.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Sentry.captureMessage('foo'); |
28 changes: 28 additions & 0 deletions
28
...ntegration-tests/suites/public-api/captureMessage/simple_message_attachStackTrace/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { expect } from '@playwright/test'; | ||
import type { Event } from '@sentry/core'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; | ||
|
||
sentryTest( | ||
'captures a simple message string with stack trace if `attachStackTrace` is `true`', | ||
async ({ getLocalTestUrl, page }) => { | ||
const url = await getLocalTestUrl({ testDir: __dirname }); | ||
|
||
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url); | ||
|
||
expect(eventData.message).toBe('foo'); | ||
expect(eventData.level).toBe('info'); | ||
expect(eventData.exception?.values?.[0]).toEqual({ | ||
mechanism: { | ||
handled: true, | ||
type: 'generic', | ||
synthetic: true, | ||
}, | ||
stacktrace: { | ||
frames: expect.arrayContaining([expect.any(Object), expect.any(Object)]), | ||
}, | ||
value: 'foo', | ||
}); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters