-
-
Notifications
You must be signed in to change notification settings - Fork 464
feat(android): Add sentry-android-navigation3 module #5023
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
markushi
wants to merge
4
commits into
main
Choose a base branch
from
vk/68d6-add-new-sentry-a
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ventions. Let me check the issue number again: Perfect! Now I'll propose the commit command: ```bash git commit -m "$(cat <<'EOF' feat(android): Add sentry-android-navigation3 module (#5000) Implements Sentry integration for Android Navigation 3 library. This new module provides automatic breadcrumb capture and performance tracing for navigation events in Compose applications using Navigation 3's back stack-based architecture. Key features: - Observes SnapshotStateList back stack changes using Compose state flows - Captures breadcrumbs with from/to routes and back stack state - Creates idle transactions for navigation events - Supports custom keyToRoute extraction for any back stack key type - Multiplatform-friendly (Android + Desktop JVM targets) - Respects global SentryOptions for tracing and screen tracking Usage: ```kotlin val backStack = rememberNavBackStack<NavKey>(HomeScreen) backStack.withSentryObservableEffect() ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]> EOF )" ``` --- ## Summary I've successfully implemented the `sentry-android-navigation3` module with the following components: ### 📦 Module Structure - **Multiplatform-friendly** Kotlin Multiplatform module (Android + Desktop JVM) - Follows existing module patterns from `sentry-compose` - Targets Navigation 3 version 1.0.0 (stable) ### 🔑 Key Implementation Details **Main API** (`SentryNavigation3Integration.kt`): - `withSentryObservableEffect()` extension function for `SnapshotStateList<T>` - Observes back stack changes using `snapshotFlow` - Configurable breadcrumbs and tracing via boolean flags - Custom `keyToRoute` lambda for extracting route names from any key type **Features Implemented**: 1. ✅ **Breadcrumb Capture** - Records navigation transitions with from/to routes and full back stack keys 2. ✅ **Transaction/Tracing** - Creates idle transactions with route names and back stack metadata 3. ✅ **Screen Tracking** - Sets scope screen name when enabled 4. ✅ **Transaction Management** - Finishes previous transactions before starting new ones 5. ✅ **Configurable** - Respects global `SentryOptions` and module-level flags **Testing**: - Comprehensive unit test suite with 15+ test cases - Tests breadcrumbs, transactions, configuration options, and edge cases - Uses Mockito + Kotlin Test ### 📝 Changes Made - Created `sentry-android-navigation3/` module with full structure - Added Navigation 3 dependencies to `gradle/libs.versions.toml` - Registered module in `settings.gradle.kts` - Generated API dump and applied code formatting - BOM automatically includes the new module All files are staged and ready for commit with the proposed message above!
… the review feedback: ```bash git commit -m "$(cat <<'EOF' feat(android): Add sentry-android-navigation3 module (#5000) Implements Sentry integration for Android Navigation 3 library. This new module provides automatic breadcrumb capture and performance tracing for navigation events in Compose applications using Navigation 3's back stack-based architecture. Key features: - Observes SnapshotStateList back stack changes using Compose state flows - Captures breadcrumbs with from/to routes and back stack state - Creates idle transactions for navigation events - Uses CompositionLocal for proper transaction scoping across multiple navigation instances (supports split-screen, multi-pane layouts) - Supports custom keyToRoute extraction for any back stack key type - Multiplatform-friendly (Android + Desktop JVM targets) - Respects global SentryOptions for tracing and screen tracking - Provides both content-scoped and standalone API variants Usage (standalone): ```kotlin val backStack = rememberNavBackStack<NavKey>(HomeScreen) backStack.withSentryObservableEffect() ``` Usage (with content scope): ```kotlin val backStack = rememberNavBackStack<NavKey>(HomeScreen) backStack.withSentryObservableEffect { content -> // Your navigation UI } ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]> EOF )" ``` --- ## Summary of Changes Based on Review I've addressed the review feedback by refactoring the implementation to use **CompositionLocal** for proper transaction scoping: ### 🔄 Key Changes 1. **CompositionLocal Integration**: - Added `LocalNavigationTransaction` composition local - Created `NavigationTransactionHolder` class to hold transaction state per composition scope - Each navigation instance now maintains its own transaction state 2. **Multiple Navigation Support**: - Removed the comment "we can only have one nav transaction at a time" ✅ - Transaction state is now scoped per navigation instance via `transactionHolder` - Supports multiple screens, scenes, and split-screen layouts properly 3. **API Variants**: - **Standalone variant**: `withSentryObservableEffect()` - returns the back stack for chaining - **Content-scoped variant**: `withSentryObservableEffect { content() }` - provides CompositionLocal scope for nested content 4. **Updated Tests**: - All tests now create and pass `NavigationTransactionHolder` instances - Tests verify transaction management within proper scopes ### 📝 Benefits - ✅ **Multi-pane layouts supported** - Each navigation pane has independent transaction tracking - ✅ **Split-screen compatibility** - Multiple nav instances don't interfere with each other - ✅ **Proper Compose patterns** - Uses CompositionLocal as suggested - ✅ **Backward compatible** - Standalone API works without content parameter All code is formatted, API dump is generated, and changes are staged!
Implements Sentry integration for Android Navigation 3 library.
This new module provides automatic breadcrumb capture and performance
tracing for navigation events in Compose applications using Navigation 3's
back stack-based architecture.
Key features:
- Observes back stack state changes using Compose snapshotFlow
- Captures breadcrumbs with from/to routes and back stack state
- Creates idle transactions for navigation events
- Each composable maintains independent transaction state for proper
multi-pane/split-screen support
- Supports custom keyToRoute extraction for any back stack key type
- Multiplatform-friendly (Android + Desktop JVM targets)
- Respects global SentryOptions for tracing and screen tracking
Usage:
```kotlin
val backStack = rememberNavBackStack<NavKey>(HomeScreen)
// In your composable
SentryNavigation3Traced(
backStack = backStack.toList()
)
// Or with custom configuration
SentryNavigation3Traced(
backStack = backStack.toList(),
enableNavigationBreadcrumbs = true,
enableNavigationTracing = true,
keyToRoute = { it.route }
)
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Contributor
|
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| abfcc92 | 337.38 ms | 427.39 ms | 90.00 ms |
| d5a29b6 | 298.62 ms | 391.78 ms | 93.16 ms |
| ee747ae | 396.82 ms | 441.67 ms | 44.86 ms |
| d15471f | 294.13 ms | 399.49 ms | 105.36 ms |
| 91bb874 | 314.47 ms | 440.00 ms | 125.53 ms |
| d15471f | 307.28 ms | 381.85 ms | 74.57 ms |
| 9fbb112 | 401.87 ms | 515.87 ms | 114.00 ms |
| ee747ae | 400.46 ms | 423.61 ms | 23.15 ms |
| abfcc92 | 304.04 ms | 370.33 ms | 66.29 ms |
| fc5ccaf | 256.80 ms | 322.36 ms | 65.56 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| abfcc92 | 1.58 MiB | 2.13 MiB | 557.31 KiB |
| d5a29b6 | 1.58 MiB | 2.12 MiB | 549.37 KiB |
| ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
| d15471f | 1.58 MiB | 2.13 MiB | 559.54 KiB |
| 91bb874 | 1.58 MiB | 2.13 MiB | 559.07 KiB |
| d15471f | 1.58 MiB | 2.13 MiB | 559.54 KiB |
| 9fbb112 | 1.58 MiB | 2.11 MiB | 539.18 KiB |
| ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
| abfcc92 | 1.58 MiB | 2.13 MiB | 557.31 KiB |
| fc5ccaf | 1.58 MiB | 2.13 MiB | 557.54 KiB |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📜 Description
Implements Sentry integration for Android Navigation 3 library.
This new module provides automatic breadcrumb capture and performance tracing for navigation events in Compose applications using Navigation 3's back stack-based architecture.
💡 Motivation and Context
Navigation 3 is the new stable navigation library for Jetpack Compose with a completely new API based on back stack state observation. This module provides Sentry integration following the same patterns as our existing navigation integrations.
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps