Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add connectivity integration in options
  • Loading branch information
denrase committed Nov 28, 2023
commit 2b3acd0d4e0783afd51c162250329334a5f32f4b
5 changes: 5 additions & 0 deletions flutter/lib/src/sentry_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import '../sentry_flutter.dart';
import 'event_processor/android_platform_exception_event_processor.dart';
import 'event_processor/flutter_exception_event_processor.dart';
import 'event_processor/platform_exception_event_processor.dart';
import 'integrations/connectivity_integration.dart';
import 'integrations/screenshot_integration.dart';
import 'native/factory.dart';
import 'native/native_scope_observer.dart';
Expand Down Expand Up @@ -171,6 +172,10 @@ mixin SentryFlutter {
integrations.add(ScreenshotIntegration());
}

if (!platform.isIOS && !platform.isMacOS || !platform.isAndroid) {
integrations.add(ConnectivityIntegration());
}

// works with Skia, CanvasKit and HTML renderer
integrations.add(SentryViewHierarchyIntegration());

Expand Down
2 changes: 1 addition & 1 deletion flutter/test/sentry_flutter_options_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void main() {
expect(options.enableAutoNativeBreadcrumbs, isFalse);
});

testWidgets('useFlutterBreadcrumbTracking', (WidgetTester tester) async {
testWidgets('useNativeBreadcrumbTracking', (WidgetTester tester) async {
final options = SentryFlutterOptions();
options.useNativeBreadcrumbTracking();

Expand Down
29 changes: 25 additions & 4 deletions flutter/test/sentry_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:sentry_flutter/src/integrations/connectivity_integration.dart';
import 'package:sentry_flutter/src/integrations/integrations.dart';
import 'package:sentry_flutter/src/integrations/screenshot_integration.dart';
import 'package:sentry_flutter/src/profiling.dart';
Expand Down Expand Up @@ -43,6 +44,11 @@ final nativeIntegrations = [
NativeSdkIntegration,
];

// These should be added to every platform except Android & iOS/macOS.
final nonMobileIntegrations = [
ConnectivityIntegration,
];

void main() {
TestWidgetsFlutterBinding.ensureInitialized();

Expand Down Expand Up @@ -88,7 +94,11 @@ void main() {
...platformAgnosticIntegrations,
...nonWebIntegrations,
],
shouldNotHaveIntegrations: iOsAndMacOsIntegrations);
shouldNotHaveIntegrations: [
...iOsAndMacOsIntegrations,
...nonWebIntegrations,
],
);

integrations
.indexWhere((element) => element is WidgetsFlutterBindingIntegration);
Expand Down Expand Up @@ -138,7 +148,10 @@ void main() {
...platformAgnosticIntegrations,
...nonWebIntegrations,
],
shouldNotHaveIntegrations: androidIntegrations,
shouldNotHaveIntegrations: [
...androidIntegrations,
...nonWebIntegrations,
],
);

testBefore(
Expand Down Expand Up @@ -187,7 +200,10 @@ void main() {
...platformAgnosticIntegrations,
...nonWebIntegrations,
],
shouldNotHaveIntegrations: androidIntegrations,
shouldNotHaveIntegrations: [
...androidIntegrations,
...nonWebIntegrations,
]
);

testBefore(
Expand Down Expand Up @@ -234,6 +250,7 @@ void main() {
shouldHaveIntegrations: [
...platformAgnosticIntegrations,
...nonWebIntegrations,
...nonMobileIntegrations,
],
shouldNotHaveIntegrations: [
...androidIntegrations,
Expand Down Expand Up @@ -285,6 +302,7 @@ void main() {
shouldHaveIntegrations: [
...platformAgnosticIntegrations,
...nonWebIntegrations,
...nonMobileIntegrations,
],
shouldNotHaveIntegrations: [
...androidIntegrations,
Expand Down Expand Up @@ -336,7 +354,10 @@ void main() {

testConfiguration(
integrations: integrations,
shouldHaveIntegrations: platformAgnosticIntegrations,
shouldHaveIntegrations: [
...platformAgnosticIntegrations,
...nonMobileIntegrations,
],
shouldNotHaveIntegrations: [
...androidIntegrations,
...iOsAndMacOsIntegrations,
Expand Down