getsentry / sentry-dart

Sentry SDK for Dart and Flutter
https://sentry.io/for/flutter/
MIT License
725 stars 224 forks source link

SentryNavigationObserver is not catching tab route changes #2123

Open cerealexx opened 2 weeks ago

cerealexx commented 2 weeks ago

Platform

Flutter Mobile

Obfuscation

Disabled

Debug Info

Enabled

Doctor

[✓] Flutter (Channel stable, 3.22.1, on macOS 14.4.1 23E224 darwin-arm64, locale es-ES) • Flutter version 3.22.1 on channel stable at /Users/alejandroartigas/development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision a14f74ff3a (4 weeks ago), 2024-05-22 11:08:21 -0500 • Engine revision 55eae6864b • Dart version 3.4.1 • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/alejandroartigas/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15C500b • CocoaPods version 1.15.2

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.90.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.90.0

[✓] Network resources • All expected network resources are available.

Version

7.18.0

Steps to Reproduce

  1. Inject SentryNavigatorObserver instance in the navigatorObservers list of the router.
  2. Navigate to any nested route with tabs.
  3. No nested navigation is caught by the observer and in Sentry navigations look like this:
    {
    from: HomeRoute,
    state: didPush
    },
    {
    state: didPop,
    to: HomeRoute
    }

    I'm using AutoRoute and my router config looks like this:

    AutoRoute(
    path: '/home',
    page: HomeRoute.page,
    children: [
    ...childrenRoutes,
    ],
    ),

Expected Result

The navigation observer should catch nested route navigation through tabs. Either that or have a method in the sdk to trigger screen tracking so I can build my own working observer and opt out the default one.

Actual Result

Captura de pantalla 2024-06-20 a las 16 13 57

Are you willing to submit a PR?

None

ueman commented 2 weeks ago

Nested navigators need their own SentryNavigationObserver, since nested navigators don't inherit observers from the root navigator. This can't be fixed in Sentry (or any other library that offers NavigationObserver)