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
548

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

getsentry/sentry-javascript 的其他 Issue

查看 getsentry/sentry-javascript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。