Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable ScreenshotIntegration, WidgetsBindingIntegration and SentryWidget in multi-view apps #2366

Merged
merged 32 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1b36c56
add multiview helper to make the sentry widget, multiview aware.
martinhaintz Oct 21, 2024
f6239fb
switch to implicit view approach
martinhaintz Oct 21, 2024
36a84aa
add changelog
martinhaintz Oct 21, 2024
540d1c0
make it flutter 3.0.0 compatible
martinhaintz Oct 21, 2024
1dab88e
fix exception
martinhaintz Oct 21, 2024
179091d
fix exception
martinhaintz Oct 21, 2024
3e8ab97
remove unused platform code
martinhaintz Oct 22, 2024
4f8cb52
automatically disable WidgetsBindingIntegration() for multiview
martinhaintz Oct 22, 2024
218975a
add debug message, if not available
martinhaintz Oct 22, 2024
0dbce52
fix `WidgetsBindingIntegration` call
martinhaintz Oct 22, 2024
9e610e4
fix, screenshotIntegration call
martinhaintz Oct 22, 2024
cae9153
Merge branch 'main' into feat/multiview-aware
martinhaintz Oct 22, 2024
481b982
Update CHANGELOG.md
martinhaintz Oct 28, 2024
55c4790
Move MultiViewCheck for WidgetsBindingIntegration inside object
martinhaintz Oct 28, 2024
f0e82e4
Move MultiViewCheck for ScreenshotIntegration inside object
martinhaintz Oct 28, 2024
d52c4fe
move platform dispatcher wrapper in a separate file
martinhaintz Oct 28, 2024
addcc64
Merge branch 'main' into feat/multiview-aware
martinhaintz Oct 28, 2024
11fc266
Merge branch 'main' into feat/multiview-aware
denrase Jan 28, 2025
c92c8de
Merge branch 'main' into feat/multiview-aware
denrase Feb 3, 2025
be2b2de
move multiview check to init
denrase Feb 3, 2025
df169ab
move back to integrations/widget and add tests
denrase Feb 4, 2025
0e36b03
update cl entry
denrase Feb 4, 2025
e037114
fix analyzer issues
denrase Feb 4, 2025
b228520
move wrapper to own file to fix analyzer warnign
denrase Feb 4, 2025
1d57db2
use onerror cb
denrase Feb 4, 2025
2baf2a4
Merge branch 'main' into feat/multiview-aware
denrase Feb 11, 2025
728ee2e
fix cl
denrase Feb 11, 2025
34a6145
add test
denrase Feb 11, 2025
55eb500
Merge branch 'main' into feat/multiview-aware
denrase Feb 11, 2025
72556e0
fix cl
denrase Feb 11, 2025
bc5c2e1
don’t test for screenshot integration
denrase Feb 11, 2025
bb385c5
fix test
denrase Feb 11, 2025
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Features

- Add `MultiViewHelper` to make the sentry plugin multiview aware for the web platform and automatically disable `SentryScreenshotWidget`, `SentryUserInteractionWidget` and `WidgetsBindingIntegration` in multi-view applications.([#2366](https://github.com/getsentry/sentry-dart/pull/2366))

### Enhancements

- Cache parsed DSN ([#2365](https://github.com/getsentry/sentry-dart/pull/2365))
Expand Down
16 changes: 13 additions & 3 deletions flutter/lib/src/sentry_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import 'profiling.dart';
import 'renderer/renderer.dart';
import 'span_frame_metrics_collector.dart';
import 'utils/multi_view_helper.dart';
import 'version.dart';
import 'view_hierarchy/view_hierarchy_integration.dart';

Expand Down Expand Up @@ -163,8 +164,16 @@
// Will catch any errors that may occur in the Flutter framework itself.
integrations.add(FlutterErrorIntegration());

// This tracks Flutter application events, such as lifecycle events.
integrations.add(WidgetsBindingIntegration());
if (MultiViewHelper.isMultiViewEnabled()) {
// ignore: invalid_use_of_internal_member
options.logger(

Check warning on line 169 in flutter/lib/src/sentry_flutter.dart

View check run for this annotation

Codecov / codecov/patch

flutter/lib/src/sentry_flutter.dart#L169

Added line #L169 was not covered by tests
SentryLevel.debug,
'`WidgetsBindingIntegration` is not available in multi-view applications.',
);
} else {
// This tracks Flutter application events, such as lifecycle events.
integrations.add(WidgetsBindingIntegration());
}

// The ordering here matters, as we'd like to first start the native integration.
// That allow us to send events to the network and then the Flutter integrations.
Expand All @@ -180,7 +189,8 @@
}

final renderer = options.rendererWrapper.getRenderer();
if (!platformChecker.isWeb || renderer == FlutterRenderer.canvasKit) {
if (!MultiViewHelper.isMultiViewEnabled() && !platformChecker.isWeb ||
renderer == FlutterRenderer.canvasKit) {
integrations.add(ScreenshotIntegration());
}

Expand Down
17 changes: 16 additions & 1 deletion flutter/lib/src/sentry_widget.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:meta/meta.dart';
import '../sentry_flutter.dart';
import 'utils/multi_view_helper.dart';

/// Key which is used to identify the [SentryWidget]
@internal
Expand All @@ -11,7 +12,13 @@
class SentryWidget extends StatefulWidget {
final Widget child;

const SentryWidget({super.key, required this.child});
SentryWidget({
super.key,
required this.child,
@internal Hub? hub,
});

final bool _isMultiViewEnabled = MultiViewHelper.isMultiViewEnabled();

@override
_SentryWidgetState createState() => _SentryWidgetState();
Expand All @@ -21,6 +28,14 @@
@override
Widget build(BuildContext context) {
Widget content = widget.child;
if (widget._isMultiViewEnabled) {
// ignore: invalid_use_of_internal_member
Sentry.currentHub.options.logger(

Check warning on line 33 in flutter/lib/src/sentry_widget.dart

View check run for this annotation

Codecov / codecov/patch

flutter/lib/src/sentry_widget.dart#L33

Added line #L33 was not covered by tests
SentryLevel.debug,
'`SentryScreenshotWidget` and `SentryUserInteractionWidget` is not available in multi-view applications.',
);
return content;
}
content = SentryScreenshotWidget(child: content);
content = SentryUserInteractionWidget(child: content);
return Container(
Expand Down
14 changes: 14 additions & 0 deletions flutter/lib/src/utils/multi_view_helper.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'dart:ui';
import 'package:meta/meta.dart';

@internal
class MultiViewHelper {
static bool isMultiViewEnabled() {
final dynamic uncheckedImplicitView = PlatformDispatcher.instance;
try {
return null == uncheckedImplicitView.implicitView;
} on NoSuchMethodError catch (_) {

Check warning on line 10 in flutter/lib/src/utils/multi_view_helper.dart

View check run for this annotation

Codecov / codecov/patch

flutter/lib/src/utils/multi_view_helper.dart#L10

Added line #L10 was not covered by tests
return false;
}
}
}
Loading