Skip to content

Commit 5598f4c

Browse files
authored
Merge branch 'main' into feat/support-allow-urls-deny-urls
2 parents c0ffc67 + ba56a96 commit 5598f4c

5 files changed

Lines changed: 101 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
### Features
6+
57
- Support allowUrls and denyUrls for Flutter Web ([#2227](https://github.com/getsentry/sentry-dart/pull/2227))
68
```dart
79
await SentryFlutter.init(
@@ -14,6 +16,18 @@
1416
appRunner: () => runApp(MyApp()),
1517
);
1618
```
19+
- Add `ignoreRoutes` parameter to `SentryNavigatorObserver`. ([#2218](https://github.com/getsentry/sentry-dart/pull/2218))
20+
- This will ignore the Routes and prevent the Route from being pushed to the Sentry server.
21+
- Ignored routes will also create no TTID and TTFD spans.
22+
```dart
23+
SentryNavigatorObserver(ignoreRoutes: ["/ignoreThisRoute"]),
24+
```
25+
26+
### Dependencies
27+
28+
- Bump Android SDK from v7.13.0 to v7.14.0 ([#2228](https://github.com/getsentry/sentry-dart/pull/2228))
29+
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#7140)
30+
- [diff](https://github.com/getsentry/sentry-java/compare/7.13.0...7.14.0)
1731

1832
## 8.7.0
1933

flutter/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ android {
6060
}
6161

6262
dependencies {
63-
api 'io.sentry:sentry-android:7.13.0'
63+
api 'io.sentry:sentry-android:7.14.0'
6464
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
6565

6666
// Required -- JUnit 4 framework

flutter/lib/src/navigation/sentry_navigator_observer.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,14 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
8080
RouteNameExtractor? routeNameExtractor,
8181
AdditionalInfoExtractor? additionalInfoProvider,
8282
@visibleForTesting TimeToDisplayTracker? timeToDisplayTracker,
83+
List<String>? ignoreRoutes,
8384
}) : _hub = hub ?? HubAdapter(),
8485
_enableAutoTransactions = enableAutoTransactions,
8586
_autoFinishAfter = autoFinishAfter,
8687
_setRouteNameAsTransaction = setRouteNameAsTransaction,
8788
_routeNameExtractor = routeNameExtractor,
8889
_additionalInfoProvider = additionalInfoProvider,
90+
_ignoreRoutes = ignoreRoutes ?? [],
8991
_native = SentryFlutter.native {
9092
_isCreated = true;
9193
if (enableAutoTransactions) {
@@ -113,6 +115,7 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
113115
final RouteNameExtractor? _routeNameExtractor;
114116
final AdditionalInfoExtractor? _additionalInfoProvider;
115117
final SentryNativeBinding? _native;
118+
final List<String> _ignoreRoutes;
116119
static TimeToDisplayTracker? _timeToDisplayTracker;
117120

118121
@internal
@@ -141,6 +144,11 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
141144
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
142145
super.didPush(route, previousRoute);
143146

147+
if (_isRouteIgnored(route) ||
148+
previousRoute != null && _isRouteIgnored(previousRoute)) {
149+
return;
150+
}
151+
144152
_setCurrentRouteName(route);
145153
_setCurrentRouteNameAsTransaction(route);
146154

@@ -160,6 +168,11 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
160168
void didReplace({Route<dynamic>? newRoute, Route<dynamic>? oldRoute}) {
161169
super.didReplace(newRoute: newRoute, oldRoute: oldRoute);
162170

171+
if (newRoute != null && _isRouteIgnored(newRoute) ||
172+
oldRoute != null && _isRouteIgnored(oldRoute)) {
173+
return;
174+
}
175+
163176
_setCurrentRouteName(newRoute);
164177
_setCurrentRouteNameAsTransaction(newRoute);
165178

@@ -174,6 +187,11 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
174187
void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
175188
super.didPop(route, previousRoute);
176189

190+
if (_isRouteIgnored(route) ||
191+
previousRoute != null && _isRouteIgnored(previousRoute)) {
192+
return;
193+
}
194+
177195
_setCurrentRouteName(previousRoute);
178196
_setCurrentRouteNameAsTransaction(previousRoute);
179197

@@ -376,6 +394,11 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
376394

377395
@internal
378396
static const String rootScreenName = 'root /';
397+
398+
bool _isRouteIgnored(Route<dynamic> route) {
399+
return _ignoreRoutes.isNotEmpty &&
400+
_ignoreRoutes.contains(_getRouteName(route));
401+
}
379402
}
380403

381404
/// This class makes it easier to record breadcrumbs for events of Flutters

flutter/test/sentry_navigator_observer_test.dart

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,66 @@ void main() {
975975
observer.didReplace(newRoute: route(to), oldRoute: route(previous));
976976
expect(hub.scope.transaction, 'to_test');
977977
});
978+
979+
test('ignores Route and prevents recognition of this route for didPush',
980+
() async {
981+
final firstRoute = route(RouteSettings(name: 'default'));
982+
final secondRoute = route(RouteSettings(name: 'testRoute'));
983+
984+
final hub = _MockHub();
985+
986+
final sut = fixture.getSut(hub: hub, ignoreRoutes: ["testRoute"]);
987+
988+
sut.didPush(firstRoute, null);
989+
expect(
990+
SentryNavigatorObserver.currentRouteName, firstRoute.settings.name);
991+
sut.didPush(secondRoute, firstRoute);
992+
expect(
993+
SentryNavigatorObserver.currentRouteName, firstRoute.settings.name);
994+
sut.didPush(firstRoute, secondRoute);
995+
expect(
996+
SentryNavigatorObserver.currentRouteName, firstRoute.settings.name);
997+
});
998+
999+
test('ignores Route and prevents recognition of this route for didPop',
1000+
() async {
1001+
final firstRoute = route(RouteSettings(name: 'default'));
1002+
final secondRoute = route(RouteSettings(name: 'testRoute'));
1003+
1004+
final hub = _MockHub();
1005+
1006+
final sut = fixture.getSut(hub: hub, ignoreRoutes: ["testRoute"]);
1007+
1008+
sut.didPush(firstRoute, null);
1009+
expect(
1010+
SentryNavigatorObserver.currentRouteName, firstRoute.settings.name);
1011+
sut.didPush(secondRoute, firstRoute);
1012+
expect(
1013+
SentryNavigatorObserver.currentRouteName, firstRoute.settings.name);
1014+
sut.didPop(firstRoute, secondRoute);
1015+
expect(
1016+
SentryNavigatorObserver.currentRouteName, firstRoute.settings.name);
1017+
});
1018+
1019+
test('ignores Route and prevents recognition of this route for didReplace',
1020+
() async {
1021+
final firstRoute = route(RouteSettings(name: 'default'));
1022+
final secondRoute = route(RouteSettings(name: 'testRoute'));
1023+
1024+
final hub = _MockHub();
1025+
1026+
final sut = fixture.getSut(hub: hub, ignoreRoutes: ["testRoute"]);
1027+
1028+
sut.didReplace(newRoute: firstRoute);
1029+
expect(
1030+
SentryNavigatorObserver.currentRouteName, firstRoute.settings.name);
1031+
sut.didReplace(newRoute: secondRoute, oldRoute: firstRoute);
1032+
expect(
1033+
SentryNavigatorObserver.currentRouteName, firstRoute.settings.name);
1034+
sut.didReplace(newRoute: firstRoute, oldRoute: secondRoute);
1035+
expect(
1036+
SentryNavigatorObserver.currentRouteName, firstRoute.settings.name);
1037+
});
9781038
});
9791039
}
9801040

@@ -987,6 +1047,7 @@ class Fixture {
9871047
RouteNameExtractor? routeNameExtractor,
9881048
AdditionalInfoExtractor? additionalInfoProvider,
9891049
bool enableTimeToFullDisplayTracing = false,
1050+
List<String>? ignoreRoutes,
9901051
}) {
9911052
final frameCallbackHandler = FakeFrameCallbackHandler();
9921053
final timeToInitialDisplayTracker =
@@ -1003,6 +1064,7 @@ class Fixture {
10031064
routeNameExtractor: routeNameExtractor,
10041065
additionalInfoProvider: additionalInfoProvider,
10051066
timeToDisplayTracker: timeToDisplayTracker,
1067+
ignoreRoutes: ignoreRoutes,
10061068
);
10071069
}
10081070

metrics/flutter.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = 3.22.3
1+
version = 3.24.0
22
repo = https://github.com/flutter/flutter

0 commit comments

Comments
 (0)