Skip to content

Commit

Permalink
Add additional flag and update comment
Browse files Browse the repository at this point in the history
  • Loading branch information
buenaflor committed May 10, 2024
1 parent 7001b46 commit 0063429
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 7 additions & 3 deletions flutter/lib/src/integrations/native_app_start_integration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,13 @@ class NativeAppStartIntegration extends Integration<SentryFlutterOptions> {
// is not created therefore we need to create a transaction ourselves.
// We detect this by checking if the currentRouteName is null.
// This is a workaround since there is no api that tells us if
// the navigator observer exists or not. The currentRouteName is always
// set during a didPush triggered by the navigator observer.
if (SentryNavigatorObserver.currentRouteName == null) {
// the navigator observer exists and has been attached.
// The navigator observer also triggers much earlier so if it was attached
// it would have already set the routeName and the isCreated flag.
// The currentRouteName is always set during a didPush triggered
// by the navigator observer.
if (!SentryNavigatorObserver.isCreated &&
SentryNavigatorObserver.currentRouteName == null) {
const screenName = SentryNavigatorObserver.rootScreenName;
final transaction = hub.startTransaction(
screenName, SentrySpanOperations.uiLoad,
Expand Down
6 changes: 6 additions & 0 deletions flutter/lib/src/navigation/sentry_navigator_observer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
_routeNameExtractor = routeNameExtractor,
_additionalInfoProvider = additionalInfoProvider,
_native = SentryFlutter.native {
_isCreated = true;
if (enableAutoTransactions) {
_hub.options.sdk.addIntegration('UINavigationTracing');
}
Expand Down Expand Up @@ -121,6 +122,11 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {

static String? _currentRouteName;

static bool _isCreated = false;

@internal
static bool get isCreated => _isCreated;

@internal
static String? get currentRouteName => _currentRouteName;

Expand Down

0 comments on commit 0063429

Please sign in to comment.