Skip to content

Refactor BindingUtils to enable the use of custom bindings#1184

Merged
marandaneto merged 18 commits into
getsentry:v7.0.0from
ueman:binding-cleanup
Jan 10, 2023
Merged

Refactor BindingUtils to enable the use of custom bindings#1184
marandaneto merged 18 commits into
getsentry:v7.0.0from
ueman:binding-cleanup

Conversation

@ueman

@ueman ueman commented Dec 12, 2022

Copy link
Copy Markdown
Collaborator

📜 Description

This change enables the use of a custom WidgetsBinding. It doesn't introduce a custom binding though.

This change is done for the v7 branch, since this could be considered a breaking change.

💡 Motivation and Context

I'm experimenting with initializing a custom widgets binding to add even more observability. Currently, that's not really supported. That's why I propose the following refactoring.

The new interface is modelled after the methods of the WidgetsBinding Sentry needs. By using a custom implementation of the BindingWrapper and assigning it to the options, you can make use of a custom binding. The custom binding then gets correctly initialized and used by Sentry.

💚 How did you test it?

This is covered by existing tests.

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • I updated the docs if needed
  • All tests passing
  • No breaking changes

🔮 Next steps

Comment thread flutter/lib/src/sentry_flutter_options.dart Outdated
Comment thread flutter/lib/src/binding_wrapper.dart Outdated
@codecov-commenter

codecov-commenter commented Dec 12, 2022

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (v7.0.0@7967a0f). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff            @@
##             v7.0.0    #1184   +/-   ##
=========================================
  Coverage          ?   87.97%           
=========================================
  Files             ?      120           
  Lines             ?     3784           
  Branches          ?        0           
=========================================
  Hits              ?     3329           
  Misses            ?      455           
  Partials          ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ueman
ueman marked this pull request as ready for review December 18, 2022 17:27
@marandaneto

Copy link
Copy Markdown
Contributor

@ueman I will review that after the holidays, thank you for doing this btw.

Comment on lines -34 to -36
if (binding == null) {
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should stay, otherwise, it won't work anyway, so bail out early.

Comment on lines +12 to +13
late SentryWidgetsBindingObserver _observer;
late SentryFlutterOptions _options;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to keep it nullable, so if close is called before call which is wrong, wouldn't throw, it's defensive programming against API misusing.

Comment thread flutter/lib/src/sentry_flutter_options.dart
Comment thread CHANGELOG.md
- theme
- Removed isolate name from Dart context. It's now reported via the threads interface. It can be enabled via `options.attachThreads`
- Use `sentryClientName` instead of `sdk.identifier` ([#1135](https://github.com/getsentry/sentry-dart/pull/1135))
- Refactor `BindingUtils` to `BindingWrapper` to enable the use of custom bindings ([#1184](https://github.com/getsentry/sentry-dart/pull/1184))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a refactor, we don't need an entry here, it's more about user-facing changes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intend this to be user facing, although maybe it shouldn't be advertised.

Comment thread flutter/lib/src/binding_wrapper.dart Outdated
Comment thread flutter/lib/src/binding_wrapper.dart Outdated
Comment thread flutter/test/integrations/not_initialized_widgets_binding_test.dart
Comment thread flutter/test/integrations/on_error_integration_no_binding_test.dart

@marandaneto marandaneto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ueman

@marandaneto
marandaneto merged commit 9b102e0 into getsentry:v7.0.0 Jan 10, 2023
@ueman
ueman deleted the binding-cleanup branch January 10, 2023 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants