-
-
Notifications
You must be signed in to change notification settings - Fork 238
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
POC: Move package:web
access to separate package
#2110
Conversation
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
- Move `package:web` access to separate package ([#2110](https://github.com/getsentry/sentry-dart/pull/2110)) If none of the above apply, you can opt out of this check by adding |
|
||
try { | ||
final config = optionsConfiguration(sentryOptions); | ||
if (config is Future) { | ||
await config; | ||
} | ||
await _initDefaultValues(sentryOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing this order probably breaks stuff in unpredictable ways...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have to change the ordering?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok nvm I understand.
We'll have to think further about this. Like you said this might break stuff / have side effects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can have a static setWindow()
function which sets an internal window and then assign that to options when calling init.
Window _window = NoopWindow();
void setWindow(Window window) {
if (!PlatformChecker().isWeb) {
return;
}
_window = window;
}
// and then inside init()
final sentryOptions = options ?? SentryOptions();
options?.window = _window;
The user just needs to call the setWindow function before SentryFlutter.init if they wanna do wasm
Sentry.setWindow(...)
SentryFlutter.init(...)
at least that way we can keep the ordering. maybe there's better ways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still a breaking change, isn't it? As in, things that worked before for users won't work anymore unless they change their code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still a breaking change, isn't it? As in, things that worked before for users won't work anymore unless they change their code.
tbh I'm not sure, wasm compilation only works on the latest stable channel so they all have to upgrade flutter afaik and it's not working right now for them anyway.
non-wasm users won't have to care about this stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant is that it would be breaking for existing users targeting web? Or am I missing something.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2110 +/- ##
=======================================
Coverage 95.25% 95.25%
=======================================
Files 54 54
Lines 1791 1791
=======================================
Hits 1706 1706
Misses 85 85 ☔ View full report in Codecov by Sentry. |
Android Performance metrics 🚀
|
Revision | Plain | With Sentry | Diff |
---|---|---|---|
e893df5 | 310.60 ms | 380.58 ms | 69.98 ms |
6aab859 | 306.27 ms | 377.92 ms | 71.65 ms |
50bdfad | 395.22 ms | 461.21 ms | 65.98 ms |
5cc82a0 | 400.35 ms | 474.52 ms | 74.17 ms |
0f067d3 | 359.56 ms | 431.28 ms | 71.72 ms |
1a93825 | 347.31 ms | 424.54 ms | 77.23 ms |
b8562d0 | 362.31 ms | 437.27 ms | 74.96 ms |
3e5ee37 | 317.56 ms | 366.84 ms | 49.28 ms |
3a69405 | 334.34 ms | 369.19 ms | 34.85 ms |
379d7a8 | 327.10 ms | 355.39 ms | 28.29 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
e893df5 | 6.06 MiB | 7.09 MiB | 1.03 MiB |
6aab859 | 6.15 MiB | 7.13 MiB | 999.97 KiB |
50bdfad | 6.33 MiB | 7.30 MiB | 987.47 KiB |
5cc82a0 | 6.34 MiB | 7.28 MiB | 966.66 KiB |
0f067d3 | 6.33 MiB | 7.30 MiB | 992.08 KiB |
1a93825 | 6.27 MiB | 7.20 MiB | 956.36 KiB |
b8562d0 | 6.35 MiB | 7.33 MiB | 1005.53 KiB |
3e5ee37 | 5.94 MiB | 6.92 MiB | 1001.19 KiB |
3a69405 | 5.94 MiB | 6.95 MiB | 1.01 MiB |
379d7a8 | 5.94 MiB | 6.95 MiB | 1.01 MiB |
@buenaflor This might just work, i build with WebAssembly and triggered an issue. Before, I set some sample values in the separate package. Dummy values in package: Code Removed all dependencies that hindered building for WebAssembly in the sample app. Removed a flutter event processor so that the web values would be taken as fallback. flutter build web --wasm
flutter pub global activate dhttpd
cd build/web
dart pub global run dhttpd '--headers=Cross-Origin-Embedder-Policy=credentialless;Cross-Origin-Opener-Policy=same-origin' Result |
did some quick tests and works well on dart 3.2.0 and flutter 16.0 |
|
||
// Get window from options or noop | ||
Window createWindow(SentryOptions options) { | ||
return options.window() ?? NoopWindow(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We create the versions.dart
that contains the package version and name and add it to the options like here
since we don't use the options inside the sentry_web
package, maybe we can set it here?
technically the user could provide their own Window implementation but I don't think it's likely that they do that
|
||
try { | ||
final config = optionsConfiguration(sentryOptions); | ||
if (config is Future) { | ||
await config; | ||
} | ||
await _initDefaultValues(sentryOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok nvm I understand.
We'll have to think further about this. Like you said this might break stuff / have side effects
|
||
try { | ||
final config = optionsConfiguration(sentryOptions); | ||
if (config is Future) { | ||
await config; | ||
} | ||
await _initDefaultValues(sentryOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can have a static setWindow()
function which sets an internal window and then assign that to options when calling init.
Window _window = NoopWindow();
void setWindow(Window window) {
if (!PlatformChecker().isWeb) {
return;
}
_window = window;
}
// and then inside init()
final sentryOptions = options ?? SentryOptions();
options?.window = _window;
The user just needs to call the setWindow function before SentryFlutter.init if they wanna do wasm
Sentry.setWindow(...)
SentryFlutter.init(...)
at least that way we can keep the ordering. maybe there's better ways
📜 Description
package:web
access to it's own library💡 Motivation and Context
Provide a path to support compilation via WASM without bumping Dart/Flutter SDKs in main sentry package
Relates to #2104
💚 How did you test it?
📝 Checklist
sendDefaultPii
is enabled🔮 Next steps