Expose Cocoa MetricKit report selection (enabledMetricReports / enabledDiagnosticReports)

未關閉
#6,988 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
35/100
Issue 類型
功能
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
ios, react-native, typescript
領域
mobile

研究方向

Start with packages/core/src/js/options.ts and packages/core/ios/RNSentryStart.m, then trace how wrapper.ts forwards options to native. First verify on a device whether an untyped metrickit dictionary reaches Cocoa; then check Cocoa’s accepted diagnostic report values and the experimental API pattern. Done means typed, documented options pass native tests and work across the listed build modes, architectures, and platforms.

由索引模型根據 Issue 內容生成。

描述

Cocoa Feature iOS React-Native
Problem

sentry-cocoa 9.33.0 (bumped in #6987) lets apps choose which MetricKit reports the SDK collects. The RN SDK has no way to set this today. It only exposes enableMetricKit and enableMetricKitRawPayload (packages/core/src/js/options.ts).

New in Cocoa 9.33.0:

  • options.experimental.metrickit.enabledMetricReports can now be set through the enabledMetricReports key of the metrickit options dictionary, which also accepts "all" (getsentry/sentry-cocoa#9490).
  • New metric reports on iOS/macOS 27+: animationTotalHitchTime, animationTotalAnimationTime, metalFramesPerSecond, metalFrameCount, metalActiveDrawingDuration. On 27+, animationScrollHitchTimeRatio is no longer sent (getsentry/sentry-cocoa#9476).
  • Memory exception diagnostics on iOS 27+, collected when enabledDiagnosticReports contains .memoryException (getsentry/sentry-cocoa#9465).
Why this isn't blocked like #6926

SentryExperimentalOptions.metrickit is @nonobjc, which is part of what blocks #6926. But RN builds Cocoa options with RNSentryInternal optionsFromDictionary (packages/core/ios/RNSentryStart.m), and JS forwards options it doesn't know about to native (wrapper.ts initNativeSdk spreads the remaining options). So the new metrickit dictionary key should reach Cocoa's own parser without a Swift shim. That means metrickit: { enabledMetricReports: 'all' } may already work today, just without types. This hasn't been checked on a device.

Proposal

Wait until Cocoa takes these options out of experimental. Cocoa made a breaking change to the MetricReport enum in 9.33.0, so the shape is still changing. After that:

  • Add a typed, iOS-only option under _experiments, for example _experiments.metricKit: { enabledMetricReports?: string[] | 'all'; enabledDiagnosticReports?: string[] | 'all' }, and pass it through as Cocoa's metrickit dictionary.
  • Check which enabledDiagnosticReports values the dictionary parser accepts. #9490 only mentions enabledMetricReports.
  • Document that this only works when enableMetricKit: true, and which reports need iOS 27+.
Acceptance criteria
  • Verified on a device whether an untyped metrickit dictionary already reaches Cocoa (and record the result).
  • Typed experimental option added, with JSDoc, and the API report regenerated.
  • Works with CocoaPods (static/dynamic) and SwiftPM, on the old and new architecture. It does nothing on Android and other platforms.
  • Tests cover the option being passed to the native options.

Related: #6926, #6457, #6987

主要語言
TypeScript
星號
1.8k
分支
371
平均合併
22 小時 3 分鐘
30 天內合併 PR
106

環境準備

從這裡開始

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

getsentry/sentry-react-native 的其他 Issue

查看 getsentry/sentry-react-native 的全部 Issue

相似的 Issue

更多 TypeScript Issue

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

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