Skip to content

Commit

Permalink
Fix: Do not set the transaction to scope if no op (#828)
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto authored Apr 12, 2022
1 parent 9cd2c20 commit 9af7777
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 76 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

* Fix: Do not set the transaction to scope if no op (#828)

## 6.5.0-beta.1

- No documented changes.
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 @@ -182,6 +182,12 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
},
);

// if _enableAutoTransactions is enabled but there's no traces sample rate
if (_transaction is NoOpSentrySpan) {
_transaction = null;
return;
}

if (arguments != null) {
_transaction?.setData('route_settings_arguments', arguments);
}
Expand Down
6 changes: 4 additions & 2 deletions flutter/test/mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/services.dart';
import 'package:mockito/annotations.dart';
import 'package:sentry/sentry.dart';
import 'package:sentry/src/platform/platform.dart';
import 'package:sentry/src/sentry_tracer.dart';

import 'package:meta/meta.dart';
import 'package:sentry_flutter/src/sentry_native.dart';
Expand All @@ -25,12 +26,13 @@ ISentrySpan startTransactionShim(
Function(ISentrySpan)? onFinish,
Map<String, dynamic>? customSamplingContext,
}) {
return MockNoOpSentrySpan();
return MockSentryTracer();
}

@GenerateMocks([
Transport,
NoOpSentrySpan,
// ignore: invalid_use_of_internal_member
SentryTracer,
MethodChannel,
SentryNative,
], customMocks: [
Expand Down
Loading

0 comments on commit 9af7777

Please sign in to comment.