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

Make `isWeb` check compatible with WASM

Open ueman opened this issue 3 years ago • 2 comments
trafficstars

Description

This check here

https://github.com/getsentry/sentry-dart/blob/ab3023814195ce35814d3c87ed0fb09a2e255d7e/dart/lib/src/platform_checker.dart#L8

needs to be made compatible with WASM. Otherwise, it might report the wrong value.

See also https://github.com/flutter/flutter/pull/112122

I guess something like the following code might work while keeping it backwards compatible with earlier Dart/Flutter versions:

bool isWeb() {
  if(bool.hasEnvironment('dart.library.js_util')) {
    return bool.fromEnvironment('dart.library.js_util');
  }
  return identical(0, 0.0);
}

ueman avatar Sep 29 '22 09:09 ueman

@ueman damn, what's about the conditional html import, is this a problem to WASM as well or just the isWeb check?

marandaneto avatar Sep 29 '22 09:09 marandaneto

That's actually a very good question. I'm guessing it's just about the isWeb check for now. But when WASM for Dart/Flutter eventually gets rolled out, it should definitely be tested.

ueman avatar Sep 29 '22 09:09 ueman