Add automatic Navigation 3 instrumentation to the Sentry Android Gradle Plugin

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

維護者通常 1 天內回覆

@0xadam-brown 已經在處理了。

開始於 2026年10月21日。

評估

這個 Issue 還沒有評估資料。

描述

Android Feature Platform: Android Platform: Java

Add automatic Navigation 3 instrumentation to the Sentry Android Gradle Plugin

Summary

Add Sentry Android Gradle Plugin support for automatically instrumenting Jetpack Navigation 3 applications.

Today, Nav3 users must manually:

  1. Call SentryNavEffect alongside NavDisplay.
  2. Provide a BackStackEntryMapper for their entire back stack.

This creates significant setup overhead and makes Nav3 instrumentation less discoverable than Nav2 instrumentation.

The SDK-side APIs and default mappers needed for this work are being introduced in sentry-java#6273.

Proposed approach

Instrument the internal rememberDecoratedNavEntries() call used by NavDisplay.

This appears preferable to instrumenting callers of NavDisplay because:

  • The internal function has remained stable across Nav3 releases so far.
  • The hook provides a precise and efficient instrumentation point.
  • ASM does not need to scan arbitrary application code or handle all NavDisplay overloads.
  • The approach should work across the existing Nav3 API variations.

The transformed code should install the SDK’s SentryNavAutoInstrumentation.Effect and configure it with the appropriate back-stack mapping behavior.

Back-stack entry mapping

Automatic instrumentation should use the SDK-provided default mapping behavior:

  • Prefer the kotlinx.serialization @SerialName for NavKey types.
  • Include serialized arguments where supported.
  • Fall back to /unknown when a stable serial name cannot be determined.
  • Preserve the ability for manually configured SentryNavEffect users to provide custom mappers.

The implementation should account for R8/minification. Serial names are compile-time constants and should remain available without requiring broad keep rules.

Configuration and privacy

Determine how automatic instrumentation should select the mapping behavior:

  • Use the BackStackMappingType exposed by SentryNavAutoInstrumentation.
  • Decide whether configuration belongs in SentryOptions, an Android manifest option, or both.
  • Ensure serialized arguments follow the same sanitization and data-collection rules as the SDK-side implementation.
  • Document how users can disable argument collection or automatic Nav3 instrumentation if needed.

Compatibility and safety

The implementation should:

  • Support the currently supported Nav3 versions and define the compatibility policy for future versions.
  • Avoid double instrumentation when an application already uses SentryNavEffect.
  • Avoid conflicts when multiple NavDisplay/SentryNavEffect pairs are active.
  • Clearly document unsupported combinations, including Nav2 and Nav3 instrumentation being active in the same application.
  • Include canary coverage against representative Nav3 applications and API versions.
  • Verify behavior in minified builds.

Acceptance criteria

  • A Nav3 application receives navigation transactions, breadcrumbs, screen names, and back-stack context without manually calling SentryNavEffect.
  • No manually implemented BackStackEntryMapper is required for the common @Serializable NavKey case.
  • Existing manually configured Nav3 integrations continue to work unchanged.
  • Automatic instrumentation can be disabled.
  • Duplicate instrumentation is prevented or safely detected.
  • Tests cover bytecode transformation, runtime behavior, minification, supported Nav3 versions, and failure/fallback cases.
  • The Nav3 documentation explains automatic instrumentation, configuration, limitations, and manual setup.

References

主要語言
Kotlin
星號
1.4k
分支
483
平均合併
2 天 54 分鐘
30 天內合併 PR
207

環境準備

從這裡開始

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

getsentry/sentry-java 的其他 Issue

查看 getsentry/sentry-java 的全部 Issue

相似的 Issue

更多 Kotlin Issue

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

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