Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

`beforeSend`: type `event_id` and `timestamp` as required

未关闭 适合新手
#25,286 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
65/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript

调研方向

首先沿着 _processEvent 经过 prepareEvent 跟踪到 processBeforeSend,并找到 @sentry/core 中的 beforeSend 和 beforeSendTransaction 回调类型。更新它们的参数类型,使已准备的事件要求包含 event_id 和 timestamp,然后运行相关的 TypeScript 类型检查和测试。完成标准是两个回调都将这些字段声明为必需字段,且现有的回调返回类型保持不变。

由索引模型根据 Issue 内容生成。

描述

Core Feature: Typescript Meta: Breaking
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.

主要语言
TypeScript
星标
8.8k
派生
1.9k
平均合并
1 天 10 小时
30 天内合并 PR
580

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

getsentry/sentry-javascript 的其他 Issue

查看 getsentry/sentry-javascript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。