sentry-dart icon indicating copy to clipboard operation
sentry-dart copied to clipboard

add multiview helper to make the sentry multiview aware.

Open martinhaintz opened this issue 4 months ago • 4 comments

:scroll: Description

Currently, the Sentry Dart Plugin does not completely support the new multi-view feature for the web. Especially the SentryScreenshotWidget,SentryUserInteractionWidget and the WidgetsBindingIntegrationare incompatible. Therefore we deactivate these features if we detect a multi-view application.

To find out if multiViewEnabled is set in the flutter_bootstrap.js I check the PlatformDispatcher.instance.implicitView return value. In a regular non multiview app PlatformDispatcher.instance.implicitView returns a FlutterView object. If you try to call PlatformDispatcher.instance.implicitView you receive null. This is also explained here in the Flutter Docs

An alternative approach I found out, could be accessing the __flutterState object and look at the elements. In a regular non multiview application the first element is always a meta event. image For a MultiView App the __flutterState only contains flutter-view elements for the number of active views. In this example, there were two active views: image

:bulb: Motivation and Context

Based on the discussion here I added a MultiViewHelper, which is only active for the Web Platform.

:green_heart: How did you test it?

local

:pencil: Checklist

  • [x] I reviewed submitted code
  • [ ] I added tests to verify changes
  • [x] No new PII added or SDK only sends newly added PII if sendDefaultPii is enabled
  • [x] I updated the docs if needed
  • [x] All tests passing
  • [x] No breaking changes

:crystal_ball: Next steps

martinhaintz avatar Oct 21 '24 11:10 martinhaintz