From da68a4e9fc420e4dab02d5e825da7bf0057295dc Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Tue, 11 Feb 2025 00:36:58 +0100 Subject: [PATCH] load js by default --- flutter/example/integration_test/web_sdk_test.dart | 3 --- flutter/example/lib/main.dart | 1 - .../lib/src/integrations/web_sdk_integration.dart | 6 +----- flutter/lib/src/sentry_flutter.dart | 6 +++--- flutter/lib/src/sentry_flutter_options.dart | 7 ------- .../test/integrations/web_sdk_integration_test.dart | 12 ------------ 6 files changed, 4 insertions(+), 31 deletions(-) diff --git a/flutter/example/integration_test/web_sdk_test.dart b/flutter/example/integration_test/web_sdk_test.dart index f33bd59721..f47b834be5 100644 --- a/flutter/example/integration_test/web_sdk_test.dart +++ b/flutter/example/integration_test/web_sdk_test.dart @@ -52,7 +52,6 @@ void main() { testWidgets('Sentry JS SDK initialized', (tester) async { await restoreFlutterOnErrorAfter(() async { await SentryFlutter.init((options) { - options.enableSentryJs = true; options.dsn = fakeDsn; }, appRunner: () async { await tester.pumpWidget(const app.MyApp()); @@ -77,7 +76,6 @@ void main() { await restoreFlutterOnErrorAfter(() async { await SentryFlutter.init((options) { - options.enableSentryJs = true; options.dsn = fakeDsn; options.beforeSend = (event, hint) { dartEvent = event; @@ -130,7 +128,6 @@ void main() { testWidgets('Sentry JS SDK is not initialized', (tester) async { await restoreFlutterOnErrorAfter(() async { await SentryFlutter.init((options) { - options.enableSentryJs = false; options.dsn = fakeDsn; }, appRunner: () async { await tester.pumpWidget(const app.MyApp()); diff --git a/flutter/example/lib/main.dart b/flutter/example/lib/main.dart index 87977f7113..a9496c1068 100644 --- a/flutter/example/lib/main.dart +++ b/flutter/example/lib/main.dart @@ -81,7 +81,6 @@ Future setupSentry( options.debug = kDebugMode; options.spotlight = Spotlight(enabled: true); options.enableTimeToFullDisplayTracing = true; - options.enableSentryJs = true; options.maxRequestBodySize = MaxRequestBodySize.always; options.maxResponseBodySize = MaxResponseBodySize.always; diff --git a/flutter/lib/src/integrations/web_sdk_integration.dart b/flutter/lib/src/integrations/web_sdk_integration.dart index 80bdb0ebd4..05d0d2e658 100644 --- a/flutter/lib/src/integrations/web_sdk_integration.dart +++ b/flutter/lib/src/integrations/web_sdk_integration.dart @@ -5,7 +5,6 @@ import 'package:sentry/sentry.dart'; import '../native/sentry_native_binding.dart'; import '../sentry_flutter_options.dart'; -import '../web/javascript_transport.dart'; import '../web/script_loader/sentry_script_loader.dart'; import '../web/sentry_js_bundle.dart'; @@ -27,7 +26,7 @@ class WebSdkIntegration implements Integration { @override FutureOr call(Hub hub, SentryFlutterOptions options) async { - if (!options.enableSentryJs || !options.autoInitializeNativeSdk) { + if (!options.autoInitializeNativeSdk) { return; } @@ -39,9 +38,6 @@ class WebSdkIntegration implements Integration { : productionScripts; await _scriptLoader.loadWebSdk(scripts); await _web.init(hub); - if (_web.supportsCaptureEnvelope) { - options.transport = JavascriptTransport(_web, options); - } options.sdk.addIntegration(name); } catch (exception, stackTrace) { options.logger( diff --git a/flutter/lib/src/sentry_flutter.dart b/flutter/lib/src/sentry_flutter.dart index ae25f8e206..16a73cec16 100644 --- a/flutter/lib/src/sentry_flutter.dart +++ b/flutter/lib/src/sentry_flutter.dart @@ -27,6 +27,7 @@ import 'renderer/renderer.dart'; import 'replay/integration.dart'; import 'version.dart'; import 'view_hierarchy/view_hierarchy_integration.dart'; +import 'web/javascript_transport.dart'; /// Configuration options callback typedef FlutterOptionsConfiguration = FutureOr Function( @@ -118,11 +119,10 @@ mixin SentryFlutter { // Not all platforms have a native integration. if (_native != null) { if (_native!.supportsCaptureEnvelope) { - // Sentry's native web integration is only enabled when enableSentryJs=true. - // Transport configuration happens in web_integration because the configuration - // options aren't available until after the options callback executes. if (!options.platformChecker.isWeb) { options.transport = FileSystemTransport(_native!, options); + } else { + options.transport = JavascriptTransport(_native!, options); } } if (!options.platformChecker.isWeb) { diff --git a/flutter/lib/src/sentry_flutter_options.dart b/flutter/lib/src/sentry_flutter_options.dart index 1481f3b57b..266246fd6b 100644 --- a/flutter/lib/src/sentry_flutter_options.dart +++ b/flutter/lib/src/sentry_flutter_options.dart @@ -290,13 +290,6 @@ class SentryFlutterOptions extends SentryOptions { /// you must use `SentryWidgetsFlutterBinding.ensureInitialized()` instead. bool enableFramesTracking = true; - /// Controls initialization of the Sentry Javascript SDK on web platforms. - /// When enabled and [autoInitializeNativeSdk] is true, loads and initializes - /// the JS SDK in the document head. - /// - /// Defaults to `false` - bool enableSentryJs = false; - /// By using this, you are disabling native [Breadcrumb] tracking and instead /// you are just tracking [Breadcrumb]s which result from events available /// in the current Flutter environment. diff --git a/flutter/test/integrations/web_sdk_integration_test.dart b/flutter/test/integrations/web_sdk_integration_test.dart index 9521e4c34d..7321932e6b 100644 --- a/flutter/test/integrations/web_sdk_integration_test.dart +++ b/flutter/test/integrations/web_sdk_integration_test.dart @@ -27,7 +27,6 @@ void main() { group('enabled', () { setUp(() { - fixture.options.enableSentryJs = true; fixture.options.autoInitializeNativeSdk = true; }); @@ -52,17 +51,9 @@ void main() { _TestScenario( 'with autoInitializeNativeSdk=false', () { - fixture.options.enableSentryJs = true; fixture.options.autoInitializeNativeSdk = false; }, ), - _TestScenario( - 'with enableSentryJs=false', - () { - fixture.options.enableSentryJs = false; - fixture.options.autoInitializeNativeSdk = true; - }, - ), ]; for (final scenario in disabledScenarios) { @@ -86,7 +77,6 @@ void main() { group('transport configuration', () { test('integration disabled: does not use javascript transport', () async { - fixture.options.enableSentryJs = false; fixture.options.autoInitializeNativeSdk = false; expect(fixture.options.transport, isA()); @@ -99,7 +89,6 @@ void main() { test( 'integration enabled and supportsCaptureEnvelope is false: does not use javascript transport', () async { - fixture.options.enableSentryJs = true; fixture.options.autoInitializeNativeSdk = true; when(fixture.web.supportsCaptureEnvelope).thenReturn(false); @@ -113,7 +102,6 @@ void main() { test( 'integration enabled and supportsCaptureEnvelope is true: uses javascript transport', () async { - fixture.options.enableSentryJs = true; fixture.options.autoInitializeNativeSdk = true; expect(fixture.options.transport, isA());