-
-
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.
We use a heavy dose of `any`, that I would like to reduce. So I started out to look into `wrap()`, which made heave use of this, and tried to rewrite it to avoid `any` as much as possible. This required some changes around it, but should now have much better type inferrence etc. than before, and be more "realistic" in what it tells you. While at this, I also removed the `before` argument that we were not using anymore - `wrap` is not exported anymore, so this is purely internal.
- Loading branch information
Showing
7 changed files
with
164 additions
and
128 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...integration-tests/suites/public-api/instrumentation/eventListener/event-target/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,11 @@ | ||
const btn = document.createElement('button'); | ||
btn.id = 'btn'; | ||
document.body.appendChild(btn); | ||
|
||
const functionListener = function () { | ||
throw new Error('event_listener_error'); | ||
}; | ||
|
||
btn.addEventListener('click', functionListener); | ||
|
||
btn.click(); |
29 changes: 29 additions & 0 deletions
29
...er-integration-tests/suites/public-api/instrumentation/eventListener/event-target/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,29 @@ | ||
import { expect } from '@playwright/test'; | ||
import type { Event } from '@sentry/types'; | ||
|
||
import { sentryTest } from '../../../../../utils/fixtures'; | ||
import { getFirstSentryEnvelopeRequest } from '../../../../../utils/helpers'; | ||
|
||
sentryTest('should capture target name in mechanism data', async ({ getLocalTestUrl, page }) => { | ||
const url = await getLocalTestUrl({ testDir: __dirname }); | ||
|
||
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url); | ||
|
||
expect(eventData.exception?.values).toHaveLength(1); | ||
expect(eventData.exception?.values?.[0]).toMatchObject({ | ||
type: 'Error', | ||
value: 'event_listener_error', | ||
mechanism: { | ||
type: 'instrument', | ||
handled: false, | ||
data: { | ||
function: 'addEventListener', | ||
handler: 'functionListener', | ||
target: 'EventTarget', | ||
}, | ||
}, | ||
stacktrace: { | ||
frames: expect.any(Array), | ||
}, | ||
}); | ||
}); |
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
Oops, something went wrong.