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

Refactor BindingUtils to enable the use of custom bindings #1184

Merged
merged 18 commits into from
Jan 10, 2023

Conversation

ueman
Copy link
Collaborator

@ueman ueman commented Dec 12, 2022

📜 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

@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2022

Codecov Report

❗ No coverage uploaded for pull request base (v7.0.0@7967a0f). Click here to learn what that means.
Patch has no changes to coverable lines.

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           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ueman ueman marked this pull request as ready for review December 18, 2022 17:27
@marandaneto
Copy link
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
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
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.

@@ -26,9 +26,11 @@
- 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
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
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.

Copy link
Contributor

@marandaneto marandaneto left a comment

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