`beforeSend`: type `event_id` and `timestamp` as required
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 65/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- developer-experience
Research direction
Start by tracing _processEvent through prepareEvent to processBeforeSend, and find the beforeSend and beforeSendTransaction callback types in @sentry/core. Update their parameter types so prepared events require event_id and timestamp, then run the related TypeScript type checks and tests. Done when both callbacks expose those fields as required and existing callback return types remain unchanged.
Written by the indexing model from the issue text.
Description
Problem Statement
beforeSend receives an ErrorEvent, which inherits event_id?: string and timestamp?: number from Event. But by the time beforeSend runs, both are always set: _processEvent only calls processBeforeSend with the result of prepareEvent, which does
event_id: event.event_id || hint.event_id || uuid4(),
timestamp: event.timestamp || dateTimestampInSeconds(),
So a common beforeSend use, like showing the user the event ID in a "report this error" link, needs a ! or a fallback that can never run.
Solution Brainstorm
Type the beforeSend parameter as ErrorEvent & { event_id: string; timestamp: number } (or a named "prepared event" type), and do the same for beforeSendTransaction. This only narrows a callback parameter, so existing callbacks still type-check, and the return type can stay ErrorEvent | null.
Additional Context
@sentry/core 11.6.0
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
- Dominant language
- TypeScript
- Stars
- 8.8k
- Forks
- 1.9k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 588
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from getsentry/sentry-javascript
-
node:http client span never ends when the response is destroyed without an error (res.destroy())OpenBug Node.js Waiting for: Product Owner
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
getsentry/sentry-javascript#25469 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
getsentry/sentry-javascript#24860 · 1 comment ·
Maintainers usually reply within 1 day
-
javascript
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
getsentry/sentry-javascript#24200 · 2 comments ·
Maintainers usually reply within 1 day
-
Cloudflare Workers javascript Tests
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
getsentry/sentry-javascript#24051 · 1 comment ·
Maintainers usually reply within 1 day
-
Elysia events report as `sentry.javascript.bun`Possibly taken @Shubham-Padkonde claimed this 28 days ago. OpenBug Bun javascript
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
getsentry/sentry-javascript#24045 · 1 comment ·
Maintainers usually reply within 1 day
All issues in getsentry/sentry-javascript
Similar issues
-
backend priority:P3 privacy-fix
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug desktop v3 windows
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
esengine/DeepSeek-Reasonix#13697 · 1 comment ·
Maintainers usually reply within 1 day
-
area:security documentation effort:S priority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
app:web meta:ops
Difficulty 2/5 Half a day Newbie friendliness 78/100
osu-tournament-rating/otr#1113 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100