From d84010df15f2e7968a541508d870578faf170826 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Feb 2025 16:35:27 +0100 Subject: [PATCH 01/23] build(deps): bump ruby/setup-ruby from 1.214.0 to 1.215.0 (#2655) Bumps [ruby/setup-ruby](https://github.com/ruby/setup-ruby) from 1.214.0 to 1.215.0. - [Release notes](https://github.com/ruby/setup-ruby/releases) - [Changelog](https://github.com/ruby/setup-ruby/blob/master/release.rb) - [Commits](https://github.com/ruby/setup-ruby/compare/1287d2b408066abada82d5ad1c63652e758428d9...2654679fe7f7c29875c669398a8ec0791b8a64a1) --- updated-dependencies: - dependency-name: ruby/setup-ruby dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/testflight.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testflight.yml b/.github/workflows/testflight.yml index e2b95fd66a..2eb68fe55c 100644 --- a/.github/workflows/testflight.yml +++ b/.github/workflows/testflight.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v4 - uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff # pin@v2.18.0 - run: xcodes select 15.0.1 - - uses: ruby/setup-ruby@1287d2b408066abada82d5ad1c63652e758428d9 # pin@v1.214.0 + - uses: ruby/setup-ruby@2654679fe7f7c29875c669398a8ec0791b8a64a1 # pin@v1.215.0 with: ruby-version: '2.7.5' bundler-cache: true From f0c4b72e08059cf6362477e69c8998bd1997a45c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Feb 2025 11:00:33 +0100 Subject: [PATCH 02/23] build(deps): bump actions/create-github-app-token from 1.11.1 to 1.11.2 (#2654) Bumps [actions/create-github-app-token](https://github.com/actions/create-github-app-token) from 1.11.1 to 1.11.2. - [Release notes](https://github.com/actions/create-github-app-token/releases) - [Commits](https://github.com/actions/create-github-app-token/compare/c1a285145b9d317df6ced56c09f525b5c2b6f755...136412a57a7081aa63c935a2cc2918f76c34f514) --- updated-dependencies: - dependency-name: actions/create-github-app-token dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 713ebd0b51..86bfdc4972 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Get auth token id: token - uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1 + uses: actions/create-github-app-token@136412a57a7081aa63c935a2cc2918f76c34f514 # v1.11.2 with: app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }} private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }} From b39b48cca3955618f006c47bb9a6826becc4aeef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Andra=C5=A1ec?= Date: Thu, 6 Feb 2025 11:02:18 +0100 Subject: [PATCH 03/23] Remove macOS display refresh rate support (#2628) --- CHANGELOG.md | 8 +++++++ .../sentry_flutter/SentryFlutterPlugin.swift | 24 +------------------ 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a51f7c509..2641c46222 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## Unreleased + +### Other + +- Remove macOS display refresh rate support ([#2628](https://github.com/getsentry/sentry-dart/pull/2628)) + - Can't reliably detect on multi-monitor systems and on older macOS versions. + - Not very meaningful, as other applications may be running in parallel and affecting it. + ## 8.13.0 ### Breaking changes diff --git a/flutter/ios/sentry_flutter/Sources/sentry_flutter/SentryFlutterPlugin.swift b/flutter/ios/sentry_flutter/Sources/sentry_flutter/SentryFlutterPlugin.swift index bf65dae55e..54c519f6c4 100644 --- a/flutter/ios/sentry_flutter/Sources/sentry_flutter/SentryFlutterPlugin.swift +++ b/flutter/ios/sentry_flutter/Sources/sentry_flutter/SentryFlutterPlugin.swift @@ -741,29 +741,7 @@ public class SentryFlutterPlugin: NSObject, FlutterPlugin { } #elseif os(macOS) private func displayRefreshRate(_ result: @escaping FlutterResult) { - // We don't use CADisplayLink for macOS because it's only available starting with macOS 14 - guard let window = NSApplication.shared.keyWindow else { - result(nil) - return - } - - guard let screen = window.screen else { - result(nil) - return - } - - guard let displayID = - screen.deviceDescription[NSDeviceDescriptionKey("NSScreenNumber")] as? CGDirectDisplayID else { - result(nil) - return - } - - guard let mode = CGDisplayCopyDisplayMode(displayID) else { - result(nil) - return - } - - result(Int(mode.refreshRate)) + result(nil) } #endif From e5aed2207e99309ed0fefef14218a8518e7c7004 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Feb 2025 13:47:02 +0100 Subject: [PATCH 04/23] build(deps): bump browser-actions/setup-chrome from 1.7.2 to 1.7.3 (#2620) Bumps [browser-actions/setup-chrome](https://github.com/browser-actions/setup-chrome) from 1.7.2 to 1.7.3. - [Release notes](https://github.com/browser-actions/setup-chrome/releases) - [Changelog](https://github.com/browser-actions/setup-chrome/blob/master/CHANGELOG.md) - [Commits](https://github.com/browser-actions/setup-chrome/compare/facf10a55b9caf92e0cc749b4f82bf8220989148...c785b87e244131f27c9f19c1a33e2ead956ab7ce) --- updated-dependencies: - dependency-name: browser-actions/setup-chrome dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Giancarlo Buenaflor --- .github/workflows/flutter_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/flutter_test.yml b/.github/workflows/flutter_test.yml index 7c6b49c77c..5a1d087b27 100644 --- a/.github/workflows/flutter_test.yml +++ b/.github/workflows/flutter_test.yml @@ -173,7 +173,7 @@ jobs: uses: actions/checkout@v4 - name: Install Chrome Browser - uses: browser-actions/setup-chrome@facf10a55b9caf92e0cc749b4f82bf8220989148 # pin@v1.7.2 + uses: browser-actions/setup-chrome@c785b87e244131f27c9f19c1a33e2ead956ab7ce # pin@v1.7.3 with: chrome-version: stable - run: chrome --version From c5c50ed66e9b89b7e1ee77e2954fe24abeb2ccf6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 6 Feb 2025 14:08:24 +0100 Subject: [PATCH 05/23] chore: update scripts/update-symbol-collector.sh to 1.23.0 (#2665) Co-authored-by: GitHub --- .../flutter_symbol_collector/lib/src/symbol_collector_cli.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/flutter_symbol_collector/lib/src/symbol_collector_cli.dart b/scripts/flutter_symbol_collector/lib/src/symbol_collector_cli.dart index 8407568f82..e60cf55ab3 100644 --- a/scripts/flutter_symbol_collector/lib/src/symbol_collector_cli.dart +++ b/scripts/flutter_symbol_collector/lib/src/symbol_collector_cli.dart @@ -19,7 +19,7 @@ class SymbolCollectorCli { // https://github.com/getsentry/symbol-collector/releases @internal - static const version = '1.22.0'; + static const version = '1.23.0'; @internal late final String cli; From 0b7de9a13a75dbed0b61d5e5a8f8e16f6c89bd40 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 6 Feb 2025 14:09:01 +0100 Subject: [PATCH 06/23] chore: update metrics/flutter.properties to 3.27.4 (#2666) Co-authored-by: GitHub --- metrics/flutter.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metrics/flutter.properties b/metrics/flutter.properties index 76d62f44b8..b014ab48e0 100644 --- a/metrics/flutter.properties +++ b/metrics/flutter.properties @@ -1,2 +1,2 @@ -version = 3.27.3 +version = 3.27.4 repo = https://github.com/flutter/flutter From 0f89732b41eb9d059bca3c82b5fbed24be92180f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 18:35:46 +0100 Subject: [PATCH 07/23] build(deps): bump actions/create-github-app-token from 1.11.2 to 1.11.3 (#2678) Bumps [actions/create-github-app-token](https://github.com/actions/create-github-app-token) from 1.11.2 to 1.11.3. - [Release notes](https://github.com/actions/create-github-app-token/releases) - [Commits](https://github.com/actions/create-github-app-token/compare/136412a57a7081aa63c935a2cc2918f76c34f514...67e27a7eb7db372a1c61a7f9bdab8699e9ee57f7) --- updated-dependencies: - dependency-name: actions/create-github-app-token dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 86bfdc4972..01b86c8924 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Get auth token id: token - uses: actions/create-github-app-token@136412a57a7081aa63c935a2cc2918f76c34f514 # v1.11.2 + uses: actions/create-github-app-token@67e27a7eb7db372a1c61a7f9bdab8699e9ee57f7 # v1.11.3 with: app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }} private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }} From 1470cd9f3e224110894c9beb99fbf91e514e465f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 18:35:57 +0100 Subject: [PATCH 08/23] build(deps): bump ruby/setup-ruby from 1.215.0 to 1.218.0 (#2677) Bumps [ruby/setup-ruby](https://github.com/ruby/setup-ruby) from 1.215.0 to 1.218.0. - [Release notes](https://github.com/ruby/setup-ruby/releases) - [Changelog](https://github.com/ruby/setup-ruby/blob/master/release.rb) - [Commits](https://github.com/ruby/setup-ruby/compare/2654679fe7f7c29875c669398a8ec0791b8a64a1...d781c1b4ed31764801bfae177617bb0446f5ef8d) --- updated-dependencies: - dependency-name: ruby/setup-ruby dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/testflight.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testflight.yml b/.github/workflows/testflight.yml index 2eb68fe55c..65dd8b9ff1 100644 --- a/.github/workflows/testflight.yml +++ b/.github/workflows/testflight.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v4 - uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff # pin@v2.18.0 - run: xcodes select 15.0.1 - - uses: ruby/setup-ruby@2654679fe7f7c29875c669398a8ec0791b8a64a1 # pin@v1.215.0 + - uses: ruby/setup-ruby@d781c1b4ed31764801bfae177617bb0446f5ef8d # pin@v1.218.0 with: ruby-version: '2.7.5' bundler-cache: true From 515c540480d65bc6d534e4607deab4137b7d0450 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 18:39:14 +0100 Subject: [PATCH 09/23] chore: update flutter/scripts/update-native.sh to 0.7.20 (#2652) Co-authored-by: GitHub Co-authored-by: Giancarlo Buenaflor --- CHANGELOG.md | 6 ++++++ flutter/sentry-native/CMakeCache.txt | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2641c46222..1f94d78339 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ - Can't reliably detect on multi-monitor systems and on older macOS versions. - Not very meaningful, as other applications may be running in parallel and affecting it. +### Dependencies + +- Bump Native SDK from v0.7.19 to v0.7.20 ([#2652](https://github.com/getsentry/sentry-dart/pull/2652)) + - [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#0720) + - [diff](https://github.com/getsentry/sentry-native/compare/0.7.19...0.7.20) + ## 8.13.0 ### Breaking changes diff --git a/flutter/sentry-native/CMakeCache.txt b/flutter/sentry-native/CMakeCache.txt index 1cb0401f4a..291d60cf7a 100644 --- a/flutter/sentry-native/CMakeCache.txt +++ b/flutter/sentry-native/CMakeCache.txt @@ -2,4 +2,4 @@ # Basically, this is a properties file we use both in CMake and update-deps.yml to update dependencies. repo=https://github.com/getsentry/sentry-native -version=0.7.19 +version=0.7.20 From d7dc4e566f62ad41a6ccec50685e17d7db347444 Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Tue, 11 Feb 2025 13:51:00 +0100 Subject: [PATCH 10/23] Deprecate `autoAppStart` and `setAppStartEnd` (#2681) * deprecate * update CHANGELOG --- CHANGELOG.md | 4 ++++ .../lib/src/integrations/native_app_start_integration.dart | 2 ++ flutter/lib/src/sentry_flutter.dart | 2 ++ flutter/lib/src/sentry_flutter_options.dart | 2 ++ .../test/integrations/native_app_start_integration_test.dart | 2 ++ 5 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f94d78339..8f851ec02e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Deprecations + +- Deprecate `autoAppStart` and `setAppStartEnd` ([#2681](https://github.com/getsentry/sentry-dart/pull/2681)) + ### Other - Remove macOS display refresh rate support ([#2628](https://github.com/getsentry/sentry-dart/pull/2628)) diff --git a/flutter/lib/src/integrations/native_app_start_integration.dart b/flutter/lib/src/integrations/native_app_start_integration.dart index bf1e356283..a57adead46 100644 --- a/flutter/lib/src/integrations/native_app_start_integration.dart +++ b/flutter/lib/src/integrations/native_app_start_integration.dart @@ -18,6 +18,7 @@ class NativeAppStartIntegration extends Integration { DateTime? _appStartEnd; /// This timestamp marks the end of app startup. Either set by calling + // ignore: deprecated_member_use_from_same_package /// [SentryFlutter.setAppStartEnd]. The [SentryFlutterOptions.autoAppStart] /// option needs to be false. @internal @@ -43,6 +44,7 @@ class NativeAppStartIntegration extends Integration { try { DateTime? appStartEnd; + // ignore: deprecated_member_use_from_same_package if (options.autoAppStart) { // ignore: invalid_use_of_internal_member appStartEnd = DateTime.fromMicrosecondsSinceEpoch(timings.first diff --git a/flutter/lib/src/sentry_flutter.dart b/flutter/lib/src/sentry_flutter.dart index 692b12894a..844f88098d 100644 --- a/flutter/lib/src/sentry_flutter.dart +++ b/flutter/lib/src/sentry_flutter.dart @@ -230,6 +230,8 @@ mixin SentryFlutter { /// Manually set when your app finished startup. Make sure to set /// [SentryFlutterOptions.autoAppStart] to false on init. The timeout duration /// for this to work is 10 seconds. + @Deprecated( + 'Will be removed in v9. This functionality will not be supported anymore.') static void setAppStartEnd(DateTime appStartEnd) { // ignore: invalid_use_of_internal_member final integrations = Sentry.currentHub.options.integrations diff --git a/flutter/lib/src/sentry_flutter_options.dart b/flutter/lib/src/sentry_flutter_options.dart index d19cd75b6f..d01b775dc2 100644 --- a/flutter/lib/src/sentry_flutter_options.dart +++ b/flutter/lib/src/sentry_flutter_options.dart @@ -179,6 +179,8 @@ class SentryFlutterOptions extends SentryOptions { /// first transaction. Set to false when configuring option to disable or if /// you want to set the end time of app startup manually using /// [SentryFlutter.setAppStartEnd]. + @Deprecated( + 'Will be removed in v9. In order to disable app starts disable it via option.removeIntegration(...) instead') bool autoAppStart = true; /// Automatically attaches a screenshot when capturing an error or exception. diff --git a/flutter/test/integrations/native_app_start_integration_test.dart b/flutter/test/integrations/native_app_start_integration_test.dart index 4696dc8987..728eebcc98 100644 --- a/flutter/test/integrations/native_app_start_integration_test.dart +++ b/flutter/test/integrations/native_app_start_integration_test.dart @@ -118,6 +118,7 @@ void main() { test('with disabled auto app start waits until appStartEnd is set', () async { + // ignore: deprecated_member_use_from_same_package fixture.options.autoAppStart = false; fixture.callIntegration(); @@ -137,6 +138,7 @@ void main() { }); test('with disabled auto app start waits until timeout', () async { + // ignore: deprecated_member_use_from_same_package fixture.options.autoAppStart = false; fixture.callIntegration(); From 57323e59467ad69ddca15227bc6172c7d83375d4 Mon Sep 17 00:00:00 2001 From: Martin Haintz Date: Wed, 12 Feb 2025 11:50:37 +0100 Subject: [PATCH 11/23] Disable `ScreenshotIntegration`, `WidgetsBindingIntegration ` and `SentryWidget` in multi-view apps (#2366) --- CHANGELOG.md | 4 ++ .../integration_test/web_sdk_test.dart | 35 ++++++++++ .../integrations/on_error_integration.dart | 49 +------------ .../integrations/screenshot_integration.dart | 8 +++ .../widgets_binding_integration.dart | 8 +++ flutter/lib/src/sentry_flutter.dart | 11 +-- flutter/lib/src/sentry_flutter_options.dart | 3 + flutter/lib/src/sentry_widget.dart | 37 ++++++++-- .../utils/platform_dispatcher_wrapper.dart | 70 +++++++++++++++++++ ...ets_binding_on_error_integration_test.dart | 1 + .../on_error_integration_test.dart | 1 + .../screenshot_integration_test.dart | 25 +++++-- .../widgets_binding_integration_test.dart | 43 ++++++++++++ flutter/test/sentry_widget_test.dart | 26 +++++++ 14 files changed, 259 insertions(+), 62 deletions(-) create mode 100644 flutter/lib/src/utils/platform_dispatcher_wrapper.dart create mode 100644 flutter/test/integrations/widgets_binding_integration_test.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f851ec02e..b4139463b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Features + +- Disable `ScreenshotIntegration`, `WidgetsBindingIntegration` and `SentryWidget` in multi-view apps #2366 ([#2366](https://github.com/getsentry/sentry-dart/pull/2366)) + ### Deprecations - Deprecate `autoAppStart` and `setAppStartEnd` ([#2681](https://github.com/getsentry/sentry-dart/pull/2681)) diff --git a/flutter/example/integration_test/web_sdk_test.dart b/flutter/example/integration_test/web_sdk_test.dart index f33bd59721..5adf45c03a 100644 --- a/flutter/example/integration_test/web_sdk_test.dart +++ b/flutter/example/integration_test/web_sdk_test.dart @@ -124,6 +124,41 @@ void main() { // sent in the JS layer expect(jsEventJson, equals(dartEventJson)); }); + + testWidgets('includes single-view supporting integrations', + (tester) async { + SentryFlutterOptions? confOptions; + + await restoreFlutterOnErrorAfter(() async { + await SentryFlutter.init((options) { + options.enableSentryJs = true; + options.dsn = fakeDsn; + options.attachScreenshot = true; + + confOptions = options; + }, appRunner: () async { + await tester.pumpWidget( + SentryWidget(child: const app.MyApp()), + ); + }); + }); + expect( + confOptions?.sdk.integrations.contains("screenshotIntegration"), + isTrue, + ); + expect( + confOptions?.sdk.integrations.contains("widgetsBindingIntegration"), + isTrue, + ); + expect( + find.byType(SentryScreenshotWidget), + findsOneWidget, + ); + expect( + find.byType(SentryUserInteractionWidget), + findsOneWidget, + ); + }); }); group('disabled', () { diff --git a/flutter/lib/src/integrations/on_error_integration.dart b/flutter/lib/src/integrations/on_error_integration.dart index f01d1a03ee..67c3b1100b 100644 --- a/flutter/lib/src/integrations/on_error_integration.dart +++ b/flutter/lib/src/integrations/on_error_integration.dart @@ -1,11 +1,8 @@ -import 'dart:ui'; - -import 'package:flutter/widgets.dart'; import 'package:sentry/sentry.dart'; -import '../sentry_flutter_options.dart'; - // ignore: implementation_imports import 'package:sentry/src/utils/stacktrace_utils.dart'; +import '../sentry_flutter_options.dart'; +import '../utils/platform_dispatcher_wrapper.dart'; typedef ErrorCallback = bool Function(Object exception, StackTrace stackTrace); @@ -110,45 +107,3 @@ class OnErrorIntegration implements Integration { } } } - -/// This class wraps the `this as dynamic` hack in a type-safe manner. -/// It helps to introduce code, which uses newer features from Flutter -/// without breaking Sentry on older versions of Flutter. -// Should not become part of public API. -@visibleForTesting -class PlatformDispatcherWrapper { - PlatformDispatcherWrapper(this._dispatcher); - - final PlatformDispatcher? _dispatcher; - - /// Should not be accessed if [isOnErrorSupported] == false - ErrorCallback? get onError => - (_dispatcher as dynamic)?.onError as ErrorCallback?; - - /// Should not be accessed if [isOnErrorSupported] == false - set onError(ErrorCallback? callback) { - (_dispatcher as dynamic)?.onError = callback; - } - - bool isOnErrorSupported(SentryFlutterOptions options) { - try { - onError; - } on NoSuchMethodError { - // This error is expected on pre 3.1 Flutter version - return false; - } catch (exception, stacktrace) { - // This error is neither expected on pre 3.1 nor on >= 3.1 Flutter versions - options.logger( - SentryLevel.debug, - 'An unexpected exception was thrown, please create an issue at https://github.com/getsentry/sentry-dart/issues', - exception: exception, - stackTrace: stacktrace, - ); - if (options.automatedTestMode) { - rethrow; - } - return false; - } - return true; - } -} diff --git a/flutter/lib/src/integrations/screenshot_integration.dart b/flutter/lib/src/integrations/screenshot_integration.dart index 10cf60228a..00782ea4aa 100644 --- a/flutter/lib/src/integrations/screenshot_integration.dart +++ b/flutter/lib/src/integrations/screenshot_integration.dart @@ -10,6 +10,14 @@ class ScreenshotIntegration implements Integration { @override void call(Hub hub, SentryFlutterOptions options) { + if (options.isMultiViewApp) { + // ignore: invalid_use_of_internal_member + options.logger( + SentryLevel.debug, + '`ScreenshotIntegration` is not available in multi-view applications.', + ); + return; + } if (options.attachScreenshot) { _options = options; final screenshotEventProcessor = ScreenshotEventProcessor(options); diff --git a/flutter/lib/src/integrations/widgets_binding_integration.dart b/flutter/lib/src/integrations/widgets_binding_integration.dart index 8ebab7e7af..64a4fd3717 100644 --- a/flutter/lib/src/integrations/widgets_binding_integration.dart +++ b/flutter/lib/src/integrations/widgets_binding_integration.dart @@ -12,6 +12,14 @@ class WidgetsBindingIntegration implements Integration { @override void call(Hub hub, SentryFlutterOptions options) { + if (options.isMultiViewApp) { + // ignore: invalid_use_of_internal_member + options.logger( + SentryLevel.debug, + '`WidgetsBindingIntegration` is not available in multi-view applications.', + ); + return; + } _options = options; final observer = SentryWidgetsBindingObserver( hub: hub, diff --git a/flutter/lib/src/sentry_flutter.dart b/flutter/lib/src/sentry_flutter.dart index 844f88098d..1d2a29548a 100644 --- a/flutter/lib/src/sentry_flutter.dart +++ b/flutter/lib/src/sentry_flutter.dart @@ -26,6 +26,7 @@ import 'native/sentry_native_binding.dart'; import 'profiling.dart'; import 'renderer/renderer.dart'; import 'replay/integration.dart'; +import 'utils/platform_dispatcher_wrapper.dart'; import 'version.dart'; import 'view_hierarchy/view_hierarchy_integration.dart'; @@ -66,8 +67,8 @@ mixin SentryFlutter { _native = createBinding(options); } - final platformDispatcher = PlatformDispatcher.instance; - final wrapper = PlatformDispatcherWrapper(platformDispatcher); + final wrapper = PlatformDispatcherWrapper(PlatformDispatcher.instance); + options.isMultiViewApp = wrapper.isMultiViewEnabled(options); // Flutter Web doesn't capture [Future] errors if using [PlatformDispatcher.onError] and not // the [runZonedGuarded]. @@ -85,8 +86,10 @@ mixin SentryFlutter { // first step is to install the native integration and set default values, // so we are able to capture future errors. - final defaultIntegrations = - _createDefaultIntegrations(options, isOnErrorSupported); + final defaultIntegrations = _createDefaultIntegrations( + options, + isOnErrorSupported, + ); for (final defaultIntegration in defaultIntegrations) { options.addIntegration(defaultIntegration); } diff --git a/flutter/lib/src/sentry_flutter_options.dart b/flutter/lib/src/sentry_flutter_options.dart index d01b775dc2..f8d5ba06b9 100644 --- a/flutter/lib/src/sentry_flutter_options.dart +++ b/flutter/lib/src/sentry_flutter_options.dart @@ -238,6 +238,9 @@ class SentryFlutterOptions extends SentryOptions { @meta.internal late RendererWrapper rendererWrapper = RendererWrapper(); + @meta.internal + bool isMultiViewApp = false; + @meta.internal late MethodChannel methodChannel = const MethodChannel('sentry_flutter'); diff --git a/flutter/lib/src/sentry_widget.dart b/flutter/lib/src/sentry_widget.dart index 40709a5465..027d351d50 100644 --- a/flutter/lib/src/sentry_widget.dart +++ b/flutter/lib/src/sentry_widget.dart @@ -10,8 +10,22 @@ final sentryWidgetGlobalKey = GlobalKey(debugLabel: 'sentry_widget'); /// as [SentryScreenshotWidget] and [SentryUserInteractionWidget]. class SentryWidget extends StatefulWidget { final Widget child; + late final Hub _hub; - const SentryWidget({super.key, required this.child}); + SentryWidget({ + super.key, + required this.child, + @internal Hub? hub, + }) { + _hub = hub ?? HubAdapter(); + } + + SentryFlutterOptions? get _options => + // ignore: invalid_use_of_internal_member + _hub.options is SentryFlutterOptions + // ignore: invalid_use_of_internal_member + ? _hub.options as SentryFlutterOptions? + : null; @override _SentryWidgetState createState() => _SentryWidgetState(); @@ -21,11 +35,20 @@ class _SentryWidgetState extends State { @override Widget build(BuildContext context) { Widget content = widget.child; - content = SentryScreenshotWidget(child: content); - content = SentryUserInteractionWidget(child: content); - return Container( - key: sentryWidgetGlobalKey, - child: content, - ); + if (widget._options?.isMultiViewApp ?? false) { + // ignore: invalid_use_of_internal_member + Sentry.currentHub.options.logger( + SentryLevel.debug, + '`SentryWidget` is not available in multi-view apps.', + ); + return content; + } else { + content = SentryScreenshotWidget(child: content); + content = SentryUserInteractionWidget(child: content); + return Container( + key: sentryWidgetGlobalKey, + child: content, + ); + } } } diff --git a/flutter/lib/src/utils/platform_dispatcher_wrapper.dart b/flutter/lib/src/utils/platform_dispatcher_wrapper.dart new file mode 100644 index 0000000000..38933d6269 --- /dev/null +++ b/flutter/lib/src/utils/platform_dispatcher_wrapper.dart @@ -0,0 +1,70 @@ +import 'dart:ui'; + +import 'package:meta/meta.dart'; +import 'package:sentry/sentry.dart'; +import '../integrations/on_error_integration.dart'; +import '../sentry_flutter_options.dart'; + +/// This class wraps the `this as dynamic` hack in a type-safe manner. +/// It helps to introduce code, which uses newer features from Flutter +/// without breaking Sentry on older versions of Flutter. +/// +/// Should not become part of public API. +@internal +class PlatformDispatcherWrapper { + PlatformDispatcherWrapper(this._dispatcher); + + final PlatformDispatcher? _dispatcher; + + bool isMultiViewEnabled(SentryFlutterOptions options) { + try { + return ((_dispatcher as dynamic)?.implicitView as FlutterView?) == null; + } on NoSuchMethodError { + // This error is expected on pre 3.10.0 Flutter version + return false; + } catch (exception, stacktrace) { + // This error is neither expected on pre 3.10.0 nor on >= 3.10.0 Flutter versions + options.logger( + SentryLevel.debug, + 'An unexpected exception was thrown, please create an issue at https://github.com/getsentry/sentry-dart/issues', + exception: exception, + stackTrace: stacktrace, + ); + if (options.automatedTestMode) { + rethrow; + } + return false; + } + } + + /// Should not be accessed if [isOnErrorSupported] == false + ErrorCallback? get onError => + (_dispatcher as dynamic)?.onError as ErrorCallback?; + + /// Should not be accessed if [isOnErrorSupported] == false + set onError(ErrorCallback? callback) { + (_dispatcher as dynamic)?.onError = callback; + } + + bool isOnErrorSupported(SentryFlutterOptions options) { + try { + onError; + } on NoSuchMethodError { + // This error is expected on pre 3.1 Flutter version + return false; + } catch (exception, stacktrace) { + // This error is neither expected on pre 3.1 nor on >= 3.1 Flutter versions + options.logger( + SentryLevel.debug, + 'An unexpected exception was thrown, please create an issue at https://github.com/getsentry/sentry-dart/issues', + exception: exception, + stackTrace: stacktrace, + ); + if (options.automatedTestMode) { + rethrow; + } + return false; + } + return true; + } +} diff --git a/flutter/test/integrations/not_initialized_widgets_binding_on_error_integration_test.dart b/flutter/test/integrations/not_initialized_widgets_binding_on_error_integration_test.dart index 6df7df0d0f..789c21af79 100644 --- a/flutter/test/integrations/not_initialized_widgets_binding_on_error_integration_test.dart +++ b/flutter/test/integrations/not_initialized_widgets_binding_on_error_integration_test.dart @@ -2,6 +2,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; import 'package:sentry/sentry.dart'; import 'package:sentry_flutter/src/integrations/on_error_integration.dart'; +import 'package:sentry_flutter/src/utils/platform_dispatcher_wrapper.dart'; import '../mocks.dart'; import '../mocks.mocks.dart'; diff --git a/flutter/test/integrations/on_error_integration_test.dart b/flutter/test/integrations/on_error_integration_test.dart index 8d90905fde..8bcb4cc67c 100644 --- a/flutter/test/integrations/on_error_integration_test.dart +++ b/flutter/test/integrations/on_error_integration_test.dart @@ -2,6 +2,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; import 'package:sentry/sentry.dart'; import 'package:sentry_flutter/src/integrations/on_error_integration.dart'; +import 'package:sentry_flutter/src/utils/platform_dispatcher_wrapper.dart'; import '../mocks.dart'; import '../mocks.mocks.dart'; diff --git a/flutter/test/integrations/screenshot_integration_test.dart b/flutter/test/integrations/screenshot_integration_test.dart index cedf8bca43..b45b8d9d80 100644 --- a/flutter/test/integrations/screenshot_integration_test.dart +++ b/flutter/test/integrations/screenshot_integration_test.dart @@ -41,8 +41,10 @@ void main() { integration(fixture.hub, fixture.options); - expect(fixture.options.sdk.integrations.contains('screenshotIntegration'), - true); + expect( + fixture.options.sdk.integrations.contains('screenshotIntegration'), + true, + ); }); test('screenshotIntegration does not add integration to the sdk list', () { @@ -50,8 +52,23 @@ void main() { integration(fixture.hub, fixture.options); - expect(fixture.options.sdk.integrations.contains('screenshotIntegration'), - false); + expect( + fixture.options.sdk.integrations.contains('screenshotIntegration'), + false, + ); + }); + + test( + 'screenshotIntegration does not add integration to the sdk list for multiview app', + () { + final integration = fixture.getSut(); + fixture.options.isMultiViewApp = true; + integration(fixture.hub, fixture.options); + + expect( + fixture.options.sdk.integrations.contains('screenshotIntegration'), + false, + ); }); test('screenshotIntegration close resets processor', () { diff --git a/flutter/test/integrations/widgets_binding_integration_test.dart b/flutter/test/integrations/widgets_binding_integration_test.dart new file mode 100644 index 0000000000..4a395738d8 --- /dev/null +++ b/flutter/test/integrations/widgets_binding_integration_test.dart @@ -0,0 +1,43 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:sentry_flutter/src/integrations/widgets_binding_integration.dart'; + +import '../mocks.dart'; +import '../mocks.mocks.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + late Fixture fixture; + + setUp(() { + fixture = Fixture(); + }); + + group('WidgetsBindingIntegration', () { + test('adds integration', () { + final integration = WidgetsBindingIntegration(); + integration(fixture.hub, fixture.options); + + expect( + fixture.options.sdk.integrations.contains('widgetsBindingIntegration'), + true, + ); + }); + + test('does not add integration if multi-view app', () { + final integration = WidgetsBindingIntegration(); + fixture.options.isMultiViewApp = true; + integration(fixture.hub, fixture.options); + + expect( + fixture.options.sdk.integrations.contains('widgetsBindingIntegration'), + false, + ); + }); + }); +} + +class Fixture { + final hub = MockHub(); + final options = defaultTestOptions(); +} diff --git a/flutter/test/sentry_widget_test.dart b/flutter/test/sentry_widget_test.dart index a64fded42f..12314b60f5 100644 --- a/flutter/test/sentry_widget_test.dart +++ b/flutter/test/sentry_widget_test.dart @@ -1,7 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/mockito.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; +import 'mocks.dart'; +import 'mocks.mocks.dart'; + void main() { group('SentryWidget', () { const testChild = Text('Test Child'); @@ -33,5 +37,27 @@ void main() { expect(find.byType(SentryScreenshotWidget), findsOneWidget); expect(find.byWidget(testChild), findsOneWidget); }); + + testWidgets( + 'SentryWidget does not add SentryUserInteractionWidget or SentryScreenshotWidget when multiview-app', + (WidgetTester tester) async { + final options = defaultTestOptions(); + options.isMultiViewApp = true; + final hub = MockHub(); + when(hub.options).thenReturn(options); + + await tester.pumpWidget( + MaterialApp( + home: SentryWidget( + hub: hub, + child: testChild, + ), + ), + ); + + expect(find.byType(SentryUserInteractionWidget), findsNothing); + expect(find.byType(SentryScreenshotWidget), findsNothing); + expect(find.byWidget(testChild), findsOneWidget); + }); }); } From 808a04ee0ac64abf7a9ec02244ecdd1ed2405e96 Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Wed, 12 Feb 2025 13:30:46 +0100 Subject: [PATCH 12/23] update Android dependency to 7.22.0 (#2705) --- CHANGELOG.md | 3 +++ flutter/android/build.gradle | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4139463b9..14ef6215ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,9 @@ ### Dependencies +- Bump Android SDK from v7.20.1 to v7.22.0 ([#2660](https://github.com/getsentry/sentry-dart/pull/2660)) + - [changelog](https://github.com/getsentry/sentry-java/blob/7.x.x/CHANGELOG.md#7220) + - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...7.22.0) - Bump Native SDK from v0.7.19 to v0.7.20 ([#2652](https://github.com/getsentry/sentry-dart/pull/2652)) - [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#0720) - [diff](https://github.com/getsentry/sentry-native/compare/0.7.19...0.7.20) diff --git a/flutter/android/build.gradle b/flutter/android/build.gradle index e91208507f..a0807d2bfc 100644 --- a/flutter/android/build.gradle +++ b/flutter/android/build.gradle @@ -60,7 +60,7 @@ android { } dependencies { - api 'io.sentry:sentry-android:7.20.1' + api 'io.sentry:sentry-android:7.22.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" // Required -- JUnit 4 framework From 9e3070e29e0bd5ae43e4b3ca0ebba6e31852d091 Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Wed, 12 Feb 2025 13:33:48 +0100 Subject: [PATCH 13/23] fix: message of frames tracking warning (#2704) * fix message of frames tracking warning * update CHANGELOG --- CHANGELOG.md | 4 ++++ flutter/lib/src/integrations/frames_tracking_integration.dart | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14ef6215ce..22c1e999ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ - Disable `ScreenshotIntegration`, `WidgetsBindingIntegration` and `SentryWidget` in multi-view apps #2366 ([#2366](https://github.com/getsentry/sentry-dart/pull/2366)) +### Fixes + +- Reference to `SentryWidgetsFlutterBinding` in warning message in `FramesTrackingIntegration` ([#2704](https://github.com/getsentry/sentry-dart/pull/2704)) + ### Deprecations - Deprecate `autoAppStart` and `setAppStartEnd` ([#2681](https://github.com/getsentry/sentry-dart/pull/2681)) diff --git a/flutter/lib/src/integrations/frames_tracking_integration.dart b/flutter/lib/src/integrations/frames_tracking_integration.dart index b5be70a519..944987a02a 100644 --- a/flutter/lib/src/integrations/frames_tracking_integration.dart +++ b/flutter/lib/src/integrations/frames_tracking_integration.dart @@ -32,7 +32,7 @@ class FramesTrackingIntegration implements Integration { if (widgetsBinding == null || widgetsBinding is! SentryWidgetsBindingMixin) { return options.logger(SentryLevel.warning, - '$FramesTrackingIntegration disabled: incompatible binding, SentryFlutterWidgetsBinding has not been instantiated. Please, use SentryFlutterWidgetsBinding.ensureInitialized() instead of FlutterWidgetsBinding.ensureInitialized()'); + '$FramesTrackingIntegration disabled: incompatible binding, SentryWidgetsFlutterBinding has not been instantiated. Please, use SentryWidgetsFlutterBinding.ensureInitialized() instead of WidgetsFlutterBinding.ensureInitialized()'); } _widgetsBinding = widgetsBinding; From 3392f27cfa702b3958ea2893c430cd24fdd8d273 Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Thu, 13 Feb 2025 15:59:24 +0100 Subject: [PATCH 14/23] ci: add ignore dart:html warnings (#2707) --- dart/example_web_legacy/web/main.dart | 1 + .../enricher/html_enricher_event_processor.dart | 1 + dart/lib/src/origin_html.dart | 1 + dart/lib/src/platform/_html_platform.dart | 2 ++ .../url_filter/html_url_filter_event_processor.dart | 6 ++++-- .../connectivity/html_connectivity_provider.dart | 1 + flutter/lib/src/web/script_loader/html_script_dom_api.dart | 2 ++ flutter/test/web/html_utils.dart | 1 + 8 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dart/example_web_legacy/web/main.dart b/dart/example_web_legacy/web/main.dart index 506bedf159..f2d303447a 100644 --- a/dart/example_web_legacy/web/main.dart +++ b/dart/example_web_legacy/web/main.dart @@ -1,4 +1,5 @@ import 'dart:async'; +// ignore: deprecated_member_use import 'dart:html'; import 'package:sentry/sentry.dart'; diff --git a/dart/lib/src/event_processor/enricher/html_enricher_event_processor.dart b/dart/lib/src/event_processor/enricher/html_enricher_event_processor.dart index e51cff4b71..b988c7d14b 100644 --- a/dart/lib/src/event_processor/enricher/html_enricher_event_processor.dart +++ b/dart/lib/src/event_processor/enricher/html_enricher_event_processor.dart @@ -1,3 +1,4 @@ +// ignore: deprecated_member_use import 'dart:html' as html show window, Window; import '../../../sentry.dart'; diff --git a/dart/lib/src/origin_html.dart b/dart/lib/src/origin_html.dart index ed1e066c5e..43a6a18b11 100644 --- a/dart/lib/src/origin_html.dart +++ b/dart/lib/src/origin_html.dart @@ -1,3 +1,4 @@ +// ignore: deprecated_member_use import 'dart:html'; /// request origin, used for browser stacktrace diff --git a/dart/lib/src/platform/_html_platform.dart b/dart/lib/src/platform/_html_platform.dart index d3fa84eed9..ea9b388e52 100644 --- a/dart/lib/src/platform/_html_platform.dart +++ b/dart/lib/src/platform/_html_platform.dart @@ -1,4 +1,6 @@ +// ignore: deprecated_member_use import 'dart:html' as html; + import 'platform.dart'; const Platform instance = WebPlatform(); diff --git a/flutter/lib/src/event_processor/url_filter/html_url_filter_event_processor.dart b/flutter/lib/src/event_processor/url_filter/html_url_filter_event_processor.dart index 39b73cb0cb..acd00daeb9 100644 --- a/flutter/lib/src/event_processor/url_filter/html_url_filter_event_processor.dart +++ b/flutter/lib/src/event_processor/url_filter/html_url_filter_event_processor.dart @@ -1,10 +1,12 @@ +// ignore: deprecated_member_use import 'dart:html' as html show window, Window; -import '../../../sentry_flutter.dart'; -import 'url_filter_event_processor.dart'; // ignore: implementation_imports import 'package:sentry/src/utils/regex_utils.dart'; +import '../../../sentry_flutter.dart'; +import 'url_filter_event_processor.dart'; + // ignore_for_file: invalid_use_of_internal_member UrlFilterEventProcessor urlFilterEventProcessor(SentryFlutterOptions options) => diff --git a/flutter/lib/src/integrations/connectivity/html_connectivity_provider.dart b/flutter/lib/src/integrations/connectivity/html_connectivity_provider.dart index 34d0e0ab42..1b30376aaf 100644 --- a/flutter/lib/src/integrations/connectivity/html_connectivity_provider.dart +++ b/flutter/lib/src/integrations/connectivity/html_connectivity_provider.dart @@ -1,4 +1,5 @@ import 'dart:async'; +// ignore: deprecated_member_use import 'dart:html' as html; import 'connectivity_provider.dart'; diff --git a/flutter/lib/src/web/script_loader/html_script_dom_api.dart b/flutter/lib/src/web/script_loader/html_script_dom_api.dart index 8c702e785f..233376eae3 100644 --- a/flutter/lib/src/web/script_loader/html_script_dom_api.dart +++ b/flutter/lib/src/web/script_loader/html_script_dom_api.dart @@ -1,5 +1,7 @@ import 'dart:async'; +// ignore: deprecated_member_use import 'dart:html'; +// ignore: deprecated_member_use import 'dart:js_util' as js_util; import '../../../sentry_flutter.dart'; diff --git a/flutter/test/web/html_utils.dart b/flutter/test/web/html_utils.dart index 91ede9c59b..9d1557a668 100644 --- a/flutter/test/web/html_utils.dart +++ b/flutter/test/web/html_utils.dart @@ -1,3 +1,4 @@ +// ignore: deprecated_member_use import 'dart:html'; void injectMetaTag(Map attributes) { From e1897c5877208c193b6255d144d20d783a8bbcbd Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Mon, 17 Feb 2025 12:42:28 +0100 Subject: [PATCH 15/23] deprecate: drift `SentryQueryExecutor` (#2715) * add deprecation note * add deprecations * update message * update CHANGELOG * fix analyze --- CHANGELOG.md | 10 ++++++++++ drift/lib/src/sentry_query_executor.dart | 3 +++ drift/lib/src/sentry_span_helper.dart | 3 ++- drift/test/sentry_database_test.dart | 2 +- flutter/example/lib/main.dart | 1 + 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22c1e999ec..b4debbf9f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,16 @@ ### Deprecations +- Deprecate Drift `SentryQueryExecutor` ([#2715](https://github.com/getsentry/sentry-dart/pull/2715)) + - This will be replace by `SentryQueryInterceptor` in the next major v9 +```dart +// Example usage in Sentry Flutter v9 +final executor = NativeDatabase.memory().interceptWith( + SentryQueryInterceptor(databaseName: 'your_db_name'), +); + +final db = AppDatabase(executor); +``` - Deprecate `autoAppStart` and `setAppStartEnd` ([#2681](https://github.com/getsentry/sentry-dart/pull/2681)) ### Other diff --git a/drift/lib/src/sentry_query_executor.dart b/drift/lib/src/sentry_query_executor.dart index 95784670c8..63aaf77d3b 100644 --- a/drift/lib/src/sentry_query_executor.dart +++ b/drift/lib/src/sentry_query_executor.dart @@ -16,6 +16,9 @@ typedef DatabaseOpener = FutureOr Function(); /// If the constructor parameter queryExecutor is null, [LazyDatabase] will be /// used as a default. @experimental +@Deprecated( + 'This will be replaced by SentryQueryInterceptor in the next major v9 ' + 'where you can use executor.interceptWith(...) to attach the SentryQueryInterceptor') class SentryQueryExecutor extends QueryExecutor { Hub _hub; diff --git a/drift/lib/src/sentry_span_helper.dart b/drift/lib/src/sentry_span_helper.dart index 762bd24d08..008a01a1a6 100644 --- a/drift/lib/src/sentry_span_helper.dart +++ b/drift/lib/src/sentry_span_helper.dart @@ -1,5 +1,6 @@ -import 'package:meta/meta.dart'; +// ignore_for_file: deprecated_member_use_from_same_package +import 'package:meta/meta.dart'; import 'package:sentry/sentry.dart'; import 'sentry_query_executor.dart'; diff --git a/drift/test/sentry_database_test.dart b/drift/test/sentry_database_test.dart index 4a3d4daa3c..1e3e2768a0 100644 --- a/drift/test/sentry_database_test.dart +++ b/drift/test/sentry_database_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: invalid_use_of_internal_member, library_annotations +// ignore_for_file: invalid_use_of_internal_member, library_annotations, deprecated_member_use_from_same_package @TestOn('vm') diff --git a/flutter/example/lib/main.dart b/flutter/example/lib/main.dart index d67aec2adc..3df93752fd 100644 --- a/flutter/example/lib/main.dart +++ b/flutter/example/lib/main.dart @@ -660,6 +660,7 @@ class MainScaffold extends StatelessWidget { bindToScope: true, ); + // ignore: deprecated_member_use final executor = SentryQueryExecutor( () async => inMemoryExecutor(), databaseName: 'sentry_in_memory_db', From ccfe7a39fa6d6c95d7b0330cb5da2a6cc4159b6e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 16:32:25 +0100 Subject: [PATCH 16/23] build(deps): bump ruby/setup-ruby from 1.218.0 to 1.221.0 (#2725) Bumps [ruby/setup-ruby](https://github.com/ruby/setup-ruby) from 1.218.0 to 1.221.0. - [Release notes](https://github.com/ruby/setup-ruby/releases) - [Changelog](https://github.com/ruby/setup-ruby/blob/master/release.rb) - [Commits](https://github.com/ruby/setup-ruby/compare/d781c1b4ed31764801bfae177617bb0446f5ef8d...32110d4e311bd8996b2a82bf2a43b714ccc91777) --- updated-dependencies: - dependency-name: ruby/setup-ruby dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/testflight.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testflight.yml b/.github/workflows/testflight.yml index 65dd8b9ff1..89e954fd78 100644 --- a/.github/workflows/testflight.yml +++ b/.github/workflows/testflight.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v4 - uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff # pin@v2.18.0 - run: xcodes select 15.0.1 - - uses: ruby/setup-ruby@d781c1b4ed31764801bfae177617bb0446f5ef8d # pin@v1.218.0 + - uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # pin@v1.221.0 with: ruby-version: '2.7.5' bundler-cache: true From 0c11ce26e7d092f8dcd9657727e355ff305ccc77 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Feb 2025 10:29:22 +0100 Subject: [PATCH 17/23] build(deps): bump actions/create-github-app-token from 1.11.3 to 1.11.5 (#2723) Bumps [actions/create-github-app-token](https://github.com/actions/create-github-app-token) from 1.11.3 to 1.11.5. - [Release notes](https://github.com/actions/create-github-app-token/releases) - [Commits](https://github.com/actions/create-github-app-token/compare/67e27a7eb7db372a1c61a7f9bdab8699e9ee57f7...0d564482f06ca65fa9e77e2510873638c82206f2) --- updated-dependencies: - dependency-name: actions/create-github-app-token dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 01b86c8924..ebf2a2673b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Get auth token id: token - uses: actions/create-github-app-token@67e27a7eb7db372a1c61a7f9bdab8699e9ee57f7 # v1.11.3 + uses: actions/create-github-app-token@0d564482f06ca65fa9e77e2510873638c82206f2 # v1.11.5 with: app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }} private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }} From a7de7ef65a3f6da4866e8acc3ca3b9ed0f200d31 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Feb 2025 10:31:22 +0100 Subject: [PATCH 18/23] build(deps): bump dart-lang/setup-dart from 1.7.0 to 1.7.1 (#2724) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.7.0 to 1.7.1. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/e630b99d28a3b71860378cafdc2a067c71107f94...e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/analyze.yml | 2 +- .github/workflows/diagrams.yml | 2 +- .github/workflows/e2e_dart.yml | 2 +- .github/workflows/flutter-symbols.yml | 4 ++-- .github/workflows/format-and-fix.yml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml index 8ffee32ffb..faa6d2b2b1 100644 --- a/.github/workflows/analyze.yml +++ b/.github/workflows/analyze.yml @@ -32,7 +32,7 @@ jobs: working-directory: ${{ inputs.package }} steps: - uses: actions/checkout@v4 - - uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 # pin@v1 + - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c # pin@v1 if: ${{ inputs.sdk == 'dart' }} - uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff # pin@v2.18.0 if: ${{ inputs.sdk == 'flutter' }} diff --git a/.github/workflows/diagrams.yml b/.github/workflows/diagrams.yml index bb4c1b6197..d909808b72 100644 --- a/.github/workflows/diagrams.yml +++ b/.github/workflows/diagrams.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest name: "Create class diagrams of all packages" steps: - - uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 # pin@v1 + - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c # pin@v1 with: sdk: stable diff --git a/.github/workflows/e2e_dart.yml b/.github/workflows/e2e_dart.yml index ba247b3394..ad4a4ab945 100644 --- a/.github/workflows/e2e_dart.yml +++ b/.github/workflows/e2e_dart.yml @@ -38,7 +38,7 @@ jobs: matrix: sdk: [stable, beta] steps: - - uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 # pin@v1 + - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c # pin@v1 with: sdk: ${{ matrix.sdk }} - uses: actions/checkout@v4 diff --git a/.github/workflows/flutter-symbols.yml b/.github/workflows/flutter-symbols.yml index b31e429e1e..d5838ae007 100644 --- a/.github/workflows/flutter-symbols.yml +++ b/.github/workflows/flutter-symbols.yml @@ -21,7 +21,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 # pin@v1 + - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c # pin@v1 - run: dart pub get @@ -33,7 +33,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 # pin@v1 + - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c # pin@v1 - run: dart pub get diff --git a/.github/workflows/format-and-fix.yml b/.github/workflows/format-and-fix.yml index 26bc972bd8..a4a2865d27 100644 --- a/.github/workflows/format-and-fix.yml +++ b/.github/workflows/format-and-fix.yml @@ -30,7 +30,7 @@ jobs: working-directory: ${{ matrix.package.name }} steps: - uses: actions/checkout@v4 - - uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 # pin@v1 + - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c # pin@v1 if: ${{ matrix.package.sdk == 'dart' }} - uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff # pin@v2.18.0 if: ${{ matrix.package.sdk == 'flutter' }} From 67a57169fae8bb8b1308841bf46e60788eaee18a Mon Sep 17 00:00:00 2001 From: Ivan Dlugos <6349682+vaind@users.noreply.github.com> Date: Tue, 18 Feb 2025 22:56:26 +0100 Subject: [PATCH 19/23] fix: navigation breadcrumb with missing `to` crashes native (#2720) * fix: navigation breadcrumb with missing `to` crashes native * chore: changelog --- CHANGELOG.md | 3 ++- .../flutter/SentryFlutterReplayBreadcrumbConverter.kt | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4debbf9f5..bc290455ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,10 @@ - Disable `ScreenshotIntegration`, `WidgetsBindingIntegration` and `SentryWidget` in multi-view apps #2366 ([#2366](https://github.com/getsentry/sentry-dart/pull/2366)) -### Fixes +### Fixes - Reference to `SentryWidgetsFlutterBinding` in warning message in `FramesTrackingIntegration` ([#2704](https://github.com/getsentry/sentry-dart/pull/2704)) +- Replay video interuption if a `navigation` breadcrumb is missing `to` route info ([#2720](https://github.com/getsentry/sentry-dart/pull/2720)) ### Deprecations diff --git a/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterReplayBreadcrumbConverter.kt b/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterReplayBreadcrumbConverter.kt index a711a36439..3c264c8d47 100644 --- a/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterReplayBreadcrumbConverter.kt +++ b/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterReplayBreadcrumbConverter.kt @@ -28,7 +28,13 @@ class SentryFlutterReplayBreadcrumbConverter : DefaultReplayBreadcrumbConverter( "sentry.event" -> null "sentry.transaction" -> null "http" -> convertNetworkBreadcrumb(breadcrumb) - "navigation" -> newRRWebBreadcrumb(breadcrumb) + "navigation" -> { + if (breadcrumb.data.containsKey("to") && breadcrumb.data["to"] is String) { + newRRWebBreadcrumb(breadcrumb) + } else { + null + } + } "ui.click" -> newRRWebBreadcrumb(breadcrumb).apply { category = "ui.tap" From e11265d7010426f93965a3f5609ebcd23c9e0dca Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 19 Feb 2025 15:28:15 +0100 Subject: [PATCH 20/23] chore: update flutter/scripts/update-cocoa.sh to 8.45.0 (#2718) Co-authored-by: GitHub --- CHANGELOG.md | 3 +++ flutter/ios/sentry_flutter.podspec | 2 +- flutter/ios/sentry_flutter/Package.swift | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc290455ec..ade1671912 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,9 @@ final db = AppDatabase(executor); - Bump Native SDK from v0.7.19 to v0.7.20 ([#2652](https://github.com/getsentry/sentry-dart/pull/2652)) - [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#0720) - [diff](https://github.com/getsentry/sentry-native/compare/0.7.19...0.7.20) +- Bump Cocoa SDK from v8.44.0 to v8.45.0 ([#2718](https://github.com/getsentry/sentry-dart/pull/2718)) + - [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8450) + - [diff](https://github.com/getsentry/sentry-cocoa/compare/8.44.0...8.45.0) ## 8.13.0 diff --git a/flutter/ios/sentry_flutter.podspec b/flutter/ios/sentry_flutter.podspec index a750dac6cd..cea98e005c 100644 --- a/flutter/ios/sentry_flutter.podspec +++ b/flutter/ios/sentry_flutter.podspec @@ -16,7 +16,7 @@ Sentry SDK for Flutter with support to native through sentry-cocoa. :tag => s.version.to_s } s.source_files = 'sentry_flutter/Sources/**/*' s.public_header_files = 'sentry_flutter/Sources/**/*.h' - s.dependency 'Sentry/HybridSDK', '8.44.0' + s.dependency 'Sentry/HybridSDK', '8.45.0' s.ios.dependency 'Flutter' s.osx.dependency 'FlutterMacOS' s.ios.deployment_target = '12.0' diff --git a/flutter/ios/sentry_flutter/Package.swift b/flutter/ios/sentry_flutter/Package.swift index 43cffd7135..664a4b3fe8 100644 --- a/flutter/ios/sentry_flutter/Package.swift +++ b/flutter/ios/sentry_flutter/Package.swift @@ -13,7 +13,7 @@ let package = Package( .library(name: "sentry-flutter", targets: ["sentry_flutter", "sentry_flutter_objc"]) ], dependencies: [ - .package(url: "https://github.com/getsentry/sentry-cocoa", from: "8.44.0") + .package(url: "https://github.com/getsentry/sentry-cocoa", from: "8.45.0") ], targets: [ .target( From f304748a4ece3d7e828ba2e6f5e151bbcbc405ce Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Wed, 19 Feb 2025 15:40:34 +0100 Subject: [PATCH 21/23] fix: auto ip guarded by `sendDefaultPii` (#2726) * fix auto ip * fix default IP address guarded by sendDefaultPii * remove null ip assertion, this will be set by default later * update CHANGELOG * fix tests * fix test * Add behavioral changes header * fix spelling * Update sentry_client.dart * format * add more assertions --- CHANGELOG.md | 5 ++ dart/lib/src/sentry_client.dart | 19 +++-- dart/test/sentry_client_test.dart | 47 ++++++++++-- .../load_contexts_integration_test.dart | 75 ++++++++++++++++++- 4 files changed, 133 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ade1671912..c90455ab48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +### Behavioral changes + +- ⚠️ Auto IP assignment for `SentryUser` is now guarded by `sendDefaultPii` ([#2726](https://github.com/getsentry/sentry-dart/pull/2726)) + - If you rely on Sentry automatically processing the IP address of the user, set `options.sendDefaultPii = true` or manually set the IP address of the `SentryUser` to `{{auto}}` + ### Features - Disable `ScreenshotIntegration`, `WidgetsBindingIntegration` and `SentryWidget` in multi-view apps #2366 ([#2366](https://github.com/getsentry/sentry-dart/pull/2366)) diff --git a/dart/lib/src/sentry_client.dart b/dart/lib/src/sentry_client.dart index dc59eea643..bef31c1e9f 100644 --- a/dart/lib/src/sentry_client.dart +++ b/dart/lib/src/sentry_client.dart @@ -35,6 +35,9 @@ import 'version.dart'; /// to true. const _defaultIpAddress = '{{auto}}'; +@visibleForTesting +String get defaultIpAddress => _defaultIpAddress; + /// Logs crash reports and events to the Sentry.io service. class SentryClient { final SentryOptions _options; @@ -304,12 +307,18 @@ class SentryClient { } SentryEvent _createUserOrSetDefaultIpAddress(SentryEvent event) { - var user = event.user; - if (user == null) { - return event.copyWith(user: SentryUser(ipAddress: _defaultIpAddress)); - } else if (event.user?.ipAddress == null) { - return event.copyWith(user: user.copyWith(ipAddress: _defaultIpAddress)); + final user = event.user; + final effectiveIpAddress = + user?.ipAddress ?? (_options.sendDefaultPii ? _defaultIpAddress : null); + + if (effectiveIpAddress != null) { + final updatedUser = user == null + ? SentryUser(ipAddress: effectiveIpAddress) + : user.copyWith(ipAddress: effectiveIpAddress); + + return event.copyWith(user: updatedUser); } + return event; } diff --git a/dart/test/sentry_client_test.dart b/dart/test/sentry_client_test.dart index 170dc9d36a..ede2330686 100644 --- a/dart/test/sentry_client_test.dart +++ b/dart/test/sentry_client_test.dart @@ -1003,16 +1003,17 @@ void main() { }); }); - group('SentryClient: sets user & user ip', () { + group('SentryClient: user & user ip', () { late Fixture fixture; setUp(() { fixture = Fixture(); }); - test('event has no user', () async { + test('event has no user and sendDefaultPii = true', () async { final client = fixture.getSut(sendDefaultPii: true); var fakeEvent = SentryEvent(); + expect(fakeEvent.user, isNull); await client.captureEvent(fakeEvent); @@ -1021,12 +1022,27 @@ void main() { expect(fixture.transport.envelopes.length, 1); expect(capturedEvent.user, isNotNull); - expect(capturedEvent.user?.ipAddress, '{{auto}}'); + expect(capturedEvent.user?.ipAddress, defaultIpAddress); + }); + + test('event has no user and sendDefaultPii = false', () async { + final client = fixture.getSut(sendDefaultPii: false); + var fakeEvent = SentryEvent(); + expect(fakeEvent.user, isNull); + + await client.captureEvent(fakeEvent); + + final capturedEnvelope = fixture.transport.envelopes.first; + final capturedEvent = await eventFromEnvelope(capturedEnvelope); + + expect(fixture.transport.envelopes.length, 1); + expect(capturedEvent.user, isNull); }); test('event has a user with IP address', () async { final client = fixture.getSut(sendDefaultPii: true); + expect(fakeEvent.user?.ipAddress, isNotNull); await client.captureEvent(fakeEvent); final capturedEnvelope = fixture.transport.envelopes.first; @@ -1040,10 +1056,31 @@ void main() { expect(capturedEvent.user?.email, fakeEvent.user!.email); }); - test('event has a user without IP address', () async { + test('event has a user without IP address and sendDefaultPii = true', + () async { final client = fixture.getSut(sendDefaultPii: true); final event = fakeEvent.copyWith(user: fakeUser); + expect(event.user?.ipAddress, isNull); + + await client.captureEvent(event); + + final capturedEnvelope = fixture.transport.envelopes.first; + final capturedEvent = await eventFromEnvelope(capturedEnvelope); + + expect(fixture.transport.envelopes.length, 1); + expect(capturedEvent.user, isNotNull); + expect(capturedEvent.user?.ipAddress, defaultIpAddress); + expect(capturedEvent.user?.id, fakeUser.id); + expect(capturedEvent.user?.email, fakeUser.email); + }); + + test('event has a user without IP address and sendDefaultPii = false', + () async { + final client = fixture.getSut(sendDefaultPii: false); + + final event = fakeEvent.copyWith(user: fakeUser); + expect(event.user?.ipAddress, isNull); await client.captureEvent(event); @@ -1052,7 +1089,7 @@ void main() { expect(fixture.transport.envelopes.length, 1); expect(capturedEvent.user, isNotNull); - expect(capturedEvent.user?.ipAddress, '{{auto}}'); + expect(capturedEvent.user?.ipAddress, isNull); expect(capturedEvent.user?.id, fakeUser.id); expect(capturedEvent.user?.email, fakeUser.email); }); diff --git a/flutter/test/integrations/load_contexts_integration_test.dart b/flutter/test/integrations/load_contexts_integration_test.dart index caed2f3293..33be3e56af 100644 --- a/flutter/test/integrations/load_contexts_integration_test.dart +++ b/flutter/test/integrations/load_contexts_integration_test.dart @@ -3,9 +3,9 @@ library flutter_test; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; +import 'package:sentry/src/sentry_tracer.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:sentry_flutter/src/integrations/load_contexts_integration.dart'; -import 'package:sentry/src/sentry_tracer.dart'; import 'fixture.dart'; @@ -86,9 +86,10 @@ void main() { }); test( - 'apply default IP to user during captureEvent after loading context if ip is null', + 'apply default IP to user during captureEvent after loading context if ip is null and sendDefaultPii is true', () async { fixture.options.enableScopeSync = true; + fixture.options.sendDefaultPii = true; const expectedIp = '{{auto}}'; String? actualIp; @@ -118,9 +119,42 @@ void main() { }); test( - 'apply default IP to user during captureTransaction after loading context if ip is null', + 'does not apply default IP to user during captureEvent after loading context if ip is null and sendDefaultPii is false', + () async { + fixture.options.enableScopeSync = true; + // sendDefaultPii false is by default + + String? actualIp; + + const expectedId = '1'; + String? actualId; + + fixture.options.beforeSend = (event, hint) { + actualIp = event.user?.ipAddress; + actualId = event.user?.id; + return event; + }; + + final options = fixture.options; + + final user = SentryUser(id: expectedId); + when(fixture.binding.loadContexts()) + .thenAnswer((_) async => {'user': user.toJson()}); + + final client = SentryClient(options); + final event = SentryEvent(); + + await client.captureEvent(event); + + expect(actualIp, isNull); + expect(actualId, expectedId); + }); + + test( + 'apply default IP to user during captureTransaction after loading context if ip is null and sendDefaultPii is true', () async { fixture.options.enableScopeSync = true; + fixture.options.sendDefaultPii = true; const expectedIp = '{{auto}}'; String? actualIp; @@ -151,5 +185,40 @@ void main() { expect(actualIp, expectedIp); expect(actualId, expectedId); }); + + test( + 'does not apply default IP to user during captureTransaction after loading context if ip is null and sendDefaultPii is false', + () async { + fixture.options.enableScopeSync = true; + // sendDefaultPii false is by default + + String? actualIp; + + const expectedId = '1'; + String? actualId; + + fixture.options.beforeSendTransaction = (transaction) { + actualIp = transaction.user?.ipAddress; + actualId = transaction.user?.id; + return transaction; + }; + + final options = fixture.options; + + final user = SentryUser(id: expectedId); + when(fixture.binding.loadContexts()) + .thenAnswer((_) async => {'user': user.toJson()}); + + final client = SentryClient(options); + final tracer = + SentryTracer(SentryTransactionContext('name', 'op'), fixture.hub); + final transaction = SentryTransaction(tracer); + + // ignore: invalid_use_of_internal_member + await client.captureTransaction(transaction); + + expect(actualIp, isNull); + expect(actualId, expectedId); + }); }); } From 12ed940a83b0a4b4f0052b2ef0d6b74daccf73d5 Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Wed, 19 Feb 2025 15:45:07 +0100 Subject: [PATCH 22/23] feat(android): use debug image loading by address api (#2706) * update Android dependency to 7.22.0 * add new debug image loading api * update CHANGELOG * run ktlint * update * update * update * Update CHANGELOG.md * Update CHANGELOG.md * add test * update test * updateg * update --- CHANGELOG.md | 8 ++- .../io/sentry/flutter/SentryFlutterPlugin.kt | 52 ++++++++++++------- .../integration_test/integration_test.dart | 31 +++++++++++ 3 files changed, 70 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c90455ab48..f45bb5deeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,10 +11,16 @@ - Disable `ScreenshotIntegration`, `WidgetsBindingIntegration` and `SentryWidget` in multi-view apps #2366 ([#2366](https://github.com/getsentry/sentry-dart/pull/2366)) +### Enhancements + +- Use `loadDebugImagesForAddresses` API for Android ([#2706](https://github.com/getsentry/sentry-dart/pull/2706)) + - This reduces the envelope size and data transferred across method channels + - If debug images received by `loadDebugImagesForAddresses` are empty, the SDK loads all debug images as fallback + ### Fixes - Reference to `SentryWidgetsFlutterBinding` in warning message in `FramesTrackingIntegration` ([#2704](https://github.com/getsentry/sentry-dart/pull/2704)) -- Replay video interuption if a `navigation` breadcrumb is missing `to` route info ([#2720](https://github.com/getsentry/sentry-dart/pull/2720)) +- Replay video interruption if a `navigation` breadcrumb is missing `to` route info ([#2720](https://github.com/getsentry/sentry-dart/pull/2720)) ### Deprecations diff --git a/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterPlugin.kt b/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterPlugin.kt index 3634d151bd..3cd7a4bb1c 100644 --- a/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterPlugin.kt +++ b/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterPlugin.kt @@ -85,7 +85,7 @@ class SentryFlutterPlugin : when (call.method) { "initNativeSdk" -> initNativeSdk(call, result) "captureEnvelope" -> captureEnvelope(call, result) - "loadImageList" -> loadImageList(result) + "loadImageList" -> loadImageList(call, result) "closeNativeSdk" -> closeNativeSdk(result) "fetchNativeAppStart" -> fetchNativeAppStart(result) "beginNativeFrames" -> beginNativeFrames(result) @@ -483,31 +483,43 @@ class SentryFlutterPlugin : result.error("3", "Envelope is null or empty", null) } - private fun loadImageList(result: Result) { + private fun loadImageList( + call: MethodCall, + result: Result, + ) { val options = HubAdapter.getInstance().options as SentryAndroidOptions - val newDebugImages = mutableListOf>() - val debugImages: List? = options.debugImagesLoader.loadDebugImages() - - debugImages?.let { - it.forEach { image -> - val item = mutableMapOf() - - item["image_addr"] = image.imageAddr - item["image_size"] = image.imageSize - item["code_file"] = image.codeFile - item["type"] = image.type - item["debug_id"] = image.debugId - item["code_id"] = image.codeId - item["debug_file"] = image.debugFile - - newDebugImages.add(item) + val addresses = call.arguments() as List? ?: listOf() + val debugImages = + if (addresses.isEmpty()) { + options.debugImagesLoader + .loadDebugImages() + ?.toList() + .serialize() + } else { + options.debugImagesLoader + .loadDebugImagesForAddresses(addresses.toSet()) + ?.ifEmpty { options.debugImagesLoader.loadDebugImages() } + ?.toList() + .serialize() } - } - result.success(newDebugImages) + result.success(debugImages) } + private fun List?.serialize() = this?.map { it.serialize() } + + private fun DebugImage.serialize() = + mapOf( + "image_addr" to imageAddr, + "image_size" to imageSize, + "code_file" to codeFile, + "type" to type, + "debug_id" to debugId, + "code_id" to codeId, + "debug_file" to debugFile, + ) + private fun closeNativeSdk(result: Result) { HubAdapter.getInstance().close() framesTracker?.stop() diff --git a/flutter/example/integration_test/integration_test.dart b/flutter/example/integration_test/integration_test.dart index 6fd6916b7d..8259d02cac 100644 --- a/flutter/example/integration_test/integration_test.dart +++ b/flutter/example/integration_test/integration_test.dart @@ -167,6 +167,37 @@ void main() { await transaction.finish(); }); + testWidgets('setup sentry and test loading debug image', (tester) async { + await restoreFlutterOnErrorAfter(() async { + await setupSentryAndApp(tester); + }); + + // By default it should load all debug images + final allDebugImages = await SentryFlutter.native + ?.loadDebugImages(SentryStackTrace(frames: const [])); + // Typically loading all images results in a larger numbers + expect(allDebugImages!.length > 100, isTrue); + + // We can take any other random image for testing + final expectedImage = allDebugImages.first; + expect(expectedImage.imageAddr, isNotNull); + final imageAddr = + int.parse(expectedImage.imageAddr!.replaceAll('0x', ''), radix: 16); + + // Use the base image address and increase by offset + // so the instructionAddress will be within the range of the image address + final imageOffset = (expectedImage.imageSize! / 2).toInt(); + final instructionAddr = '0x${(imageAddr + imageOffset).toRadixString(16)}'; + final sentryFrame = SentryStackFrame(instructionAddr: instructionAddr); + + final debugImageByStacktrace = await SentryFlutter.native + ?.loadDebugImages(SentryStackTrace(frames: [sentryFrame])); + expect(debugImageByStacktrace!.length, 1); + expect(debugImageByStacktrace.first.imageAddr, isNotNull); + expect(debugImageByStacktrace.first.imageAddr, isNotEmpty); + expect(debugImageByStacktrace.first.imageAddr, expectedImage.imageAddr); + }); + group('e2e', () { var output = find.byKey(const Key('output')); late Fixture fixture; From ea1d45d64f52551e2e033c50b0ff8512e3d8a4e3 Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Wed, 19 Feb 2025 20:04:04 +0100 Subject: [PATCH 23/23] merge release `8.13.1` (#2734) * update Android dependency to 7.22.0 (#2705) * fix: navigation breadcrumb with missing to crashes native (#2720) * release: 8.13.1 --------- Co-authored-by: getsentry-bot Co-authored-by: getsentry-bot --- CHANGELOG.md | 16 ++++++++++++---- dart/lib/src/version.dart | 2 +- dart/pubspec.yaml | 2 +- dio/lib/src/version.dart | 2 +- dio/pubspec.yaml | 4 ++-- drift/lib/src/version.dart | 2 +- drift/pubspec.yaml | 4 ++-- file/lib/src/version.dart | 2 +- file/pubspec.yaml | 4 ++-- flutter/example/pubspec.yaml | 2 +- flutter/lib/src/version.dart | 2 +- flutter/pubspec.yaml | 4 ++-- hive/lib/src/version.dart | 2 +- hive/pubspec.yaml | 4 ++-- isar/lib/src/version.dart | 2 +- isar/pubspec.yaml | 4 ++-- link/pubspec.yaml | 4 ++-- logging/lib/src/version.dart | 2 +- logging/pubspec.yaml | 4 ++-- sqflite/lib/src/version.dart | 2 +- sqflite/pubspec.yaml | 4 ++-- 21 files changed, 41 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f45bb5deeb..7b6d3b2980 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,6 @@ ### Fixes - Reference to `SentryWidgetsFlutterBinding` in warning message in `FramesTrackingIntegration` ([#2704](https://github.com/getsentry/sentry-dart/pull/2704)) -- Replay video interruption if a `navigation` breadcrumb is missing `to` route info ([#2720](https://github.com/getsentry/sentry-dart/pull/2720)) ### Deprecations @@ -44,9 +43,6 @@ final db = AppDatabase(executor); ### Dependencies -- Bump Android SDK from v7.20.1 to v7.22.0 ([#2660](https://github.com/getsentry/sentry-dart/pull/2660)) - - [changelog](https://github.com/getsentry/sentry-java/blob/7.x.x/CHANGELOG.md#7220) - - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...7.22.0) - Bump Native SDK from v0.7.19 to v0.7.20 ([#2652](https://github.com/getsentry/sentry-dart/pull/2652)) - [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#0720) - [diff](https://github.com/getsentry/sentry-native/compare/0.7.19...0.7.20) @@ -54,6 +50,18 @@ final db = AppDatabase(executor); - [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8450) - [diff](https://github.com/getsentry/sentry-cocoa/compare/8.44.0...8.45.0) +## 8.13.1 + +### Fixes + +- Replay video interruption if a `navigation` breadcrumb is missing `to` route info ([#2720](https://github.com/getsentry/sentry-dart/pull/2720)) + +### Dependencies + +- Bump Android SDK from v7.20.1 to v7.22.0 ([#2705](https://github.com/getsentry/sentry-dart/pull/2705)) + - [changelog](https://github.com/getsentry/sentry-java/blob/7.x.x/CHANGELOG.md#7220) + - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...7.22.0) + ## 8.13.0 ### Breaking changes diff --git a/dart/lib/src/version.dart b/dart/lib/src/version.dart index b8ca6c1e46..1de225e871 100644 --- a/dart/lib/src/version.dart +++ b/dart/lib/src/version.dart @@ -9,7 +9,7 @@ library version; /// The SDK version reported to Sentry.io in the submitted events. -const String sdkVersion = '8.13.0'; +const String sdkVersion = '8.13.1'; String sdkName(bool isWeb) => isWeb ? _browserSdkName : _ioSdkName; diff --git a/dart/pubspec.yaml b/dart/pubspec.yaml index c9b65d5ac5..00c8b31248 100644 --- a/dart/pubspec.yaml +++ b/dart/pubspec.yaml @@ -1,5 +1,5 @@ name: sentry -version: 8.13.0 +version: 8.13.1 description: > A crash reporting library for Dart that sends crash reports to Sentry.io. This library supports Dart VM and Web. For Flutter consider sentry_flutter instead. diff --git a/dio/lib/src/version.dart b/dio/lib/src/version.dart index f356d79579..8f21d18a05 100644 --- a/dio/lib/src/version.dart +++ b/dio/lib/src/version.dart @@ -1,5 +1,5 @@ /// The SDK version reported to Sentry.io in the submitted events. -const String sdkVersion = '8.13.0'; +const String sdkVersion = '8.13.1'; /// The package name reported to Sentry.io in the submitted events. const String packageName = 'pub:sentry_dio'; diff --git a/dio/pubspec.yaml b/dio/pubspec.yaml index 9834877d26..d1b911a82b 100644 --- a/dio/pubspec.yaml +++ b/dio/pubspec.yaml @@ -1,6 +1,6 @@ name: sentry_dio description: An integration which adds support for performance tracing for the Dio package. -version: 8.13.0 +version: 8.13.1 homepage: https://docs.sentry.io/platforms/dart/ repository: https://github.com/getsentry/sentry-dart issue_tracker: https://github.com/getsentry/sentry-dart/issues @@ -19,7 +19,7 @@ platforms: dependencies: dio: ^5.0.0 - sentry: 8.13.0 + sentry: 8.13.1 dev_dependencies: meta: ^1.3.0 diff --git a/drift/lib/src/version.dart b/drift/lib/src/version.dart index 5386931faf..da8f53116d 100644 --- a/drift/lib/src/version.dart +++ b/drift/lib/src/version.dart @@ -1,5 +1,5 @@ /// The SDK version reported to Sentry.io in the submitted events. -const String sdkVersion = '8.13.0'; +const String sdkVersion = '8.13.1'; /// The package name reported to Sentry.io in the submitted events. const String packageName = 'pub:sentry_drift'; diff --git a/drift/pubspec.yaml b/drift/pubspec.yaml index 161fc3080e..910aa6cc56 100644 --- a/drift/pubspec.yaml +++ b/drift/pubspec.yaml @@ -1,6 +1,6 @@ name: sentry_drift description: An integration which adds support for performance tracing for the drift package. -version: 8.13.0 +version: 8.13.1 homepage: https://docs.sentry.io/platforms/flutter/ repository: https://github.com/getsentry/sentry-dart issue_tracker: https://github.com/getsentry/sentry-dart/issues @@ -17,7 +17,7 @@ platforms: web: dependencies: - sentry: 8.13.0 + sentry: 8.13.1 meta: ^1.3.0 drift: ^2.13.0 diff --git a/file/lib/src/version.dart b/file/lib/src/version.dart index 549212a6cb..ec5356f531 100644 --- a/file/lib/src/version.dart +++ b/file/lib/src/version.dart @@ -1,5 +1,5 @@ /// The SDK version reported to Sentry.io in the submitted events. -const String sdkVersion = '8.13.0'; +const String sdkVersion = '8.13.1'; /// The package name reported to Sentry.io in the submitted events. const String packageName = 'pub:sentry_file'; diff --git a/file/pubspec.yaml b/file/pubspec.yaml index 8c0327fb06..a7768b8e8c 100644 --- a/file/pubspec.yaml +++ b/file/pubspec.yaml @@ -1,6 +1,6 @@ name: sentry_file description: An integration which adds support for performance tracing for dart.io.File. -version: 8.13.0 +version: 8.13.1 homepage: https://docs.sentry.io/platforms/dart/ repository: https://github.com/getsentry/sentry-dart issue_tracker: https://github.com/getsentry/sentry-dart/issues @@ -17,7 +17,7 @@ platforms: windows: dependencies: - sentry: 8.13.0 + sentry: 8.13.1 meta: ^1.3.0 dev_dependencies: diff --git a/flutter/example/pubspec.yaml b/flutter/example/pubspec.yaml index 6b9c517750..30c70296bf 100644 --- a/flutter/example/pubspec.yaml +++ b/flutter/example/pubspec.yaml @@ -1,6 +1,6 @@ name: sentry_flutter_example description: Demonstrates how to use the sentry_flutter plugin. -version: 8.13.0 +version: 8.13.1 publish_to: 'none' # Remove this line if you wish to publish to pub.dev diff --git a/flutter/lib/src/version.dart b/flutter/lib/src/version.dart index 818e02f7ba..c57ad790f2 100644 --- a/flutter/lib/src/version.dart +++ b/flutter/lib/src/version.dart @@ -1,5 +1,5 @@ /// The SDK version reported to Sentry.io in the submitted events. -const String sdkVersion = '8.13.0'; +const String sdkVersion = '8.13.1'; /// The default SDK name reported to Sentry.io in the submitted events. const String sdkName = 'sentry.dart.flutter'; diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml index 923bd45d1d..37a2cb2910 100644 --- a/flutter/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -1,5 +1,5 @@ name: sentry_flutter -version: 8.13.0 +version: 8.13.1 description: Sentry SDK for Flutter. This package aims to support different Flutter targets by relying on the many platforms supported by Sentry with native SDKs. homepage: https://docs.sentry.io/platforms/flutter/ repository: https://github.com/getsentry/sentry-dart @@ -23,7 +23,7 @@ dependencies: sdk: flutter flutter_web_plugins: sdk: flutter - sentry: 8.13.0 + sentry: 8.13.1 package_info_plus: '>=1.0.0' meta: ^1.3.0 ffi: ^2.0.0 diff --git a/hive/lib/src/version.dart b/hive/lib/src/version.dart index 253629ca83..9a0dad15d5 100644 --- a/hive/lib/src/version.dart +++ b/hive/lib/src/version.dart @@ -1,5 +1,5 @@ /// The SDK version reported to Sentry.io in the submitted events. -const String sdkVersion = '8.13.0'; +const String sdkVersion = '8.13.1'; /// The package name reported to Sentry.io in the submitted events. const String packageName = 'pub:sentry_hive'; diff --git a/hive/pubspec.yaml b/hive/pubspec.yaml index 2307861109..95b9f6b34d 100644 --- a/hive/pubspec.yaml +++ b/hive/pubspec.yaml @@ -1,6 +1,6 @@ name: sentry_hive description: An integration which adds support for performance tracing for the hive package. -version: 8.13.0 +version: 8.13.1 homepage: https://docs.sentry.io/platforms/flutter/ repository: https://github.com/getsentry/sentry-dart issue_tracker: https://github.com/getsentry/sentry-dart/issues @@ -17,7 +17,7 @@ platforms: web: dependencies: - sentry: 8.13.0 + sentry: 8.13.1 hive: ^2.2.3 meta: ^1.3.0 diff --git a/isar/lib/src/version.dart b/isar/lib/src/version.dart index 554942d405..2ec1bf8d62 100644 --- a/isar/lib/src/version.dart +++ b/isar/lib/src/version.dart @@ -1,5 +1,5 @@ /// The SDK version reported to Sentry.io in the submitted events. -const String sdkVersion = '8.13.0'; +const String sdkVersion = '8.13.1'; /// The package name reported to Sentry.io in the submitted events. const String packageName = 'pub:sentry_isar'; diff --git a/isar/pubspec.yaml b/isar/pubspec.yaml index 81a7fa5ba0..1c709ebee9 100644 --- a/isar/pubspec.yaml +++ b/isar/pubspec.yaml @@ -1,6 +1,6 @@ name: sentry_isar description: An integration which adds support for performance tracing for the isar package. -version: 8.13.0 +version: 8.13.1 homepage: https://docs.sentry.io/platforms/flutter/ repository: https://github.com/getsentry/sentry-dart issue_tracker: https://github.com/getsentry/sentry-dart/issues @@ -20,7 +20,7 @@ platforms: dependencies: isar: ^3.1.0 isar_flutter_libs: ^3.1.0 # contains Isar Core - sentry: 8.13.0 + sentry: 8.13.1 meta: ^1.3.0 path: ^1.8.3 diff --git a/link/pubspec.yaml b/link/pubspec.yaml index f5bb40f9f4..740820bdec 100644 --- a/link/pubspec.yaml +++ b/link/pubspec.yaml @@ -1,6 +1,6 @@ name: sentry_link description: Automatic capture of exceptions and GraphQL errors for the gql eco-system, like graphql and ferry -version: 8.13.0 +version: 8.13.1 homepage: https://docs.sentry.io/platforms/dart/ repository: https://github.com/getsentry/sentry-dart issue_tracker: https://github.com/getsentry/sentry-dart/issues @@ -13,7 +13,7 @@ dependencies: gql_exec: ">=0.4.4 <2.0.0" gql_link: ">=0.5.0 <2.0.0" gql: ">=0.14.0 <2.0.0" - sentry: 8.13.0 + sentry: 8.13.1 dev_dependencies: lints: ^4.0.0 diff --git a/logging/lib/src/version.dart b/logging/lib/src/version.dart index b96cae5646..34e261a816 100644 --- a/logging/lib/src/version.dart +++ b/logging/lib/src/version.dart @@ -1,5 +1,5 @@ /// The SDK version reported to Sentry.io in the submitted events. -const String sdkVersion = '8.13.0'; +const String sdkVersion = '8.13.1'; /// The package name reported to Sentry.io in the submitted events. const String packageName = 'pub:sentry_logging'; diff --git a/logging/pubspec.yaml b/logging/pubspec.yaml index 8825edf593..f29eee5081 100644 --- a/logging/pubspec.yaml +++ b/logging/pubspec.yaml @@ -1,6 +1,6 @@ name: sentry_logging description: An integration which adds support for recording log from the logging package. -version: 8.13.0 +version: 8.13.1 homepage: https://docs.sentry.io/platforms/dart/ repository: https://github.com/getsentry/sentry-dart issue_tracker: https://github.com/getsentry/sentry-dart/issues @@ -19,7 +19,7 @@ platforms: dependencies: logging: ^1.0.0 - sentry: 8.13.0 + sentry: 8.13.1 dev_dependencies: lints: '>=2.0.0' diff --git a/sqflite/lib/src/version.dart b/sqflite/lib/src/version.dart index bac93198ce..5cce226e6a 100644 --- a/sqflite/lib/src/version.dart +++ b/sqflite/lib/src/version.dart @@ -1,5 +1,5 @@ /// The SDK version reported to Sentry.io in the submitted events. -const String sdkVersion = '8.13.0'; +const String sdkVersion = '8.13.1'; /// The package name reported to Sentry.io in the submitted events. const String packageName = 'pub:sentry_sqflite'; diff --git a/sqflite/pubspec.yaml b/sqflite/pubspec.yaml index 25727c3304..d6e4354e1b 100644 --- a/sqflite/pubspec.yaml +++ b/sqflite/pubspec.yaml @@ -1,6 +1,6 @@ name: sentry_sqflite description: An integration which adds support for performance tracing for the sqflite package. -version: 8.13.0 +version: 8.13.1 homepage: https://docs.sentry.io/platforms/flutter/ repository: https://github.com/getsentry/sentry-dart issue_tracker: https://github.com/getsentry/sentry-dart/issues @@ -15,7 +15,7 @@ platforms: macos: dependencies: - sentry: 8.13.0 + sentry: 8.13.1 sqflite: ^2.2.8 sqflite_common: ^2.0.0 meta: ^1.3.0