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

Report version of Dart and Flutter

Open bruno-garcia opened this issue 4 years ago • 10 comments
trafficstars

Came up on: https://github.com/flutter/flutter/issues/61814

The goal is to include the 'runtime' interface with the Dart and/or Flutter version. If there's still no API for this, perhaps we can get this at compile time

bruno-garcia avatar Apr 13 '21 20:04 bruno-garcia

The only way I see to archive this currently is to advise the user to include the pubspec.yaml file as an asset and read the dart and flutter version constraints at runtime from it. Like this This is a Flutter only solution.

We could add compile time code generation but that requires the user to add a sentry dev dependency, execute the code generation and somehow notify Sentry of the generated code (because there's no reflection in Flutter). Code generation would work for pure Dart and Flutter though.

ueman avatar Apr 13 '21 21:04 ueman

also for context https://github.com/flutter/flutter/issues/11481

marandaneto avatar Apr 14 '21 07:04 marandaneto

We could add compile time code generation but that requires the user to add a sentry dev dependency, execute the code generation and somehow notify Sentry of the generated code (because there's no reflection in Flutter). Code generation would work for pure Dart and Flutter though.

Having some code of ours running at part of the build is required for uploading proguard mapping files for Android and debug files for iOS. On Flutter right now it's not a requirement, unless split-debug-info which I assume can become more widely adopted (since folks want smaller apps at the end of the day).

Given that, it doesn't sound unreasonable for us to have a dart tool of sorts that ppl can add to their Flutter builds. And with this tool we could hook into the build to say: Get the Flutter version and replace it on a placeholder variable in a .dart file before compilation. And also do things such as automate debug file upload.

bruno-garcia avatar Apr 14 '21 19:04 bruno-garcia

yeah the idea is that we have some code that is run during the build time that can inject some values either as code generation or env. var. that could be read at runtime, I'd be fine either way, this is ideally done along with the automatization of uploading debug files automatically as it'd be pretty much the same plugin.

marandaneto avatar Apr 15 '21 12:04 marandaneto

If there were some kind of generation, maybe this could also help with https://github.com/getsentry/sentry-dart/issues/265

kuhnroyal avatar Apr 15 '21 12:04 kuhnroyal

Dart issue for exposing more information at runtime: https://github.com/dart-lang/sdk/issues/46347

ueman avatar Jun 13 '21 20:06 ueman

We'd need a plugin that does flutter -version and parse the output during compile time or even before, and later generate code with the metadata to be set at runtime.

marandaneto avatar Apr 28 '22 12:04 marandaneto

Screenshot 2022-04-28 at 14 25 58

We already have this btw.

marandaneto avatar Apr 28 '22 12:04 marandaneto

As a work around for as long as querying the Flutter version is not officially supported, we could offer to read it from a dart define and document the key.

So when the app is build with flutter build apk --dart-define flutterVersion=3.7.7 Sentry automatically attaches that version to the runtime.

ueman avatar Mar 12 '23 19:03 ueman

True, it's a small baby step, you can do that yourself already actually using the beforeSend or an event processor, but yeah automatic would be better.

marandaneto avatar Mar 13 '23 07:03 marandaneto