-
-
Notifications
You must be signed in to change notification settings - Fork 277
Add Flutter runtime information #2742
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
Merged
+148
−1
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d3b2989
Add Flutter runtime
ueman 1fa65d3
add explaining comment
ueman 65496d4
add changelog
ueman ce305a1
Update CHANGELOG.md
ueman c8b4793
make things const
ueman 760c175
Merge branch 'main' into flutter-runtime
ueman 04006fb
Merge branch 'flutter-runtime' of github.com:ueman/sentry-dart into f…
ueman 0fa7d7b
fix changelog
ueman feecc70
more doc comments
ueman 1c20261
Fix formatting
ueman 8095f99
Merge branch 'main' into flutter-runtime
ueman d54096c
add test and requested changes
ueman 1a1584b
Merge branch 'main' into flutter-runtime
denrase 6e32339
move tests to flutter package
ueman 9638c11
skip if environment is missing
denrase 81fd25c
add ignore
denrase e5e0425
Merge branch 'main' into flutter-runtime
ueman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
dart/lib/src/event_processor/enricher/flutter_runtime.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import '../../protocol/sentry_runtime.dart'; | ||
|
|
||
| // The Flutter version information can be fetched via Dart defines, | ||
| // see | ||
| // - https://github.com/flutter/flutter/pull/140783 | ||
| // - https://github.com/flutter/flutter/pull/163761 | ||
| // | ||
| // This code lives in the Dart only Sentry code, since the code | ||
| // doesn't require any Flutter dependency. | ||
| // Additionally, this makes it work on background isolates in | ||
| // Flutter, where one may not initialize the whole Flutter Sentry | ||
| // SDK. | ||
| // The const-ness of the properties below ensure that the code | ||
| // is tree shaken in a non-Flutter environment. | ||
|
|
||
| const _isFlutterRuntimeInformationAbsent = FlutterVersion.version == null || | ||
| FlutterVersion.channel == null || | ||
| FlutterVersion.frameworkRevision == null; | ||
|
|
||
| const SentryRuntime? flutterRuntime = _isFlutterRuntimeInformationAbsent | ||
| ? null | ||
| : SentryRuntime( | ||
| name: 'Flutter', | ||
| version: '${FlutterVersion.version} (${FlutterVersion.channel})', | ||
| build: FlutterVersion.frameworkRevision, | ||
| rawDescription: '${FlutterVersion.version} (${FlutterVersion.channel}) ' | ||
| '- Git hash ${FlutterVersion.frameworkRevision} ' | ||
| '- Git URL ${FlutterVersion.gitUrl}', | ||
| ); | ||
|
|
||
| const SentryRuntime? dartFlutterRuntime = FlutterVersion.dartVersion == null | ||
| ? null | ||
| : SentryRuntime(name: 'Dart', version: FlutterVersion.dartVersion); | ||
|
|
||
| /// Details about the Flutter version this app was compiled with, | ||
| /// corresponding to the output of `flutter --version`. | ||
| /// | ||
| /// When this Flutter version was build from a fork, or when Flutter runs in a | ||
| /// custom embedder, these values might be unreliable. | ||
| abstract class FlutterVersion { | ||
| const FlutterVersion._(); | ||
|
|
||
| /// The Flutter version used to compile the app. | ||
| static const String? version = bool.hasEnvironment('FLUTTER_VERSION') | ||
| ? String.fromEnvironment('FLUTTER_VERSION') | ||
| : null; | ||
|
|
||
| /// The Flutter channel used to compile the app. | ||
| static const String? channel = bool.hasEnvironment('FLUTTER_CHANNEL') | ||
| ? String.fromEnvironment('FLUTTER_CHANNEL') | ||
| : null; | ||
|
|
||
| /// The URL of the Git repository from which Flutter was obtained. | ||
| static const String? gitUrl = bool.hasEnvironment('FLUTTER_GIT_URL') | ||
| ? String.fromEnvironment('FLUTTER_GIT_URL') | ||
| : null; | ||
|
Comment on lines
+53
to
+56
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be included in a context somewhere? |
||
|
|
||
| /// The Flutter framework revision, as a (short) Git commit ID. | ||
| static const String? frameworkRevision = | ||
| bool.hasEnvironment('FLUTTER_FRAMEWORK_REVISION') | ||
| ? String.fromEnvironment('FLUTTER_FRAMEWORK_REVISION') | ||
| : null; | ||
|
|
||
| /// The Flutter engine revision. | ||
| static const String? engineRevision = | ||
| bool.hasEnvironment('FLUTTER_ENGINE_REVISION') | ||
| ? String.fromEnvironment('FLUTTER_ENGINE_REVISION') | ||
| : null; | ||
|
|
||
| // This is included since [Platform.version](https://api.dart.dev/stable/dart-io/Platform/version.html) | ||
| // is not included on web platforms. | ||
| /// The Dart version used to compile the app. | ||
| static const String? dartVersion = bool.hasEnvironment('FLUTTER_DART_VERSION') | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's slightly different than
|
||
| ? String.fromEnvironment('FLUTTER_DART_VERSION') | ||
| : null; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:sentry/src/event_processor/enricher/flutter_runtime.dart'; | ||
|
|
||
| void main() { | ||
| group(FlutterVersion, () { | ||
| test('FlutterVersion.version contains the current version', () { | ||
| expect(FlutterVersion.version, | ||
| const String.fromEnvironment('FLUTTER_VERSION')); | ||
| }); | ||
|
|
||
| test('FlutterVersion.channel contains the current channel', () { | ||
| expect(FlutterVersion.channel, | ||
| const String.fromEnvironment('FLUTTER_CHANNEL')); | ||
| }); | ||
|
|
||
| test('FlutterVersion.gitUrl contains the current git URL', () { | ||
| expect(FlutterVersion.gitUrl, | ||
| const String.fromEnvironment('FLUTTER_GIT_URL')); | ||
| }); | ||
|
|
||
| test( | ||
| 'FlutterVersion.frameworkRevision contains the current framework revision', | ||
| () { | ||
| expect( | ||
| FlutterVersion.frameworkRevision, | ||
| const String.fromEnvironment('FLUTTER_FRAMEWORK_REVISION'), | ||
| ); | ||
| }); | ||
|
|
||
| test('FlutterVersion.engineRevision contains the current engine revision', | ||
| () { | ||
| expect(FlutterVersion.engineRevision, | ||
| const String.fromEnvironment('FLUTTER_ENGINE_REVISION')); | ||
| }); | ||
|
|
||
| test('FlutterVersion.dartVersion contains the current Dart version', () { | ||
| expect(FlutterVersion.dartVersion, | ||
| const String.fromEnvironment('FLUTTER_DART_VERSION')); | ||
| }); | ||
| }, skip: !(const bool.hasEnvironment('FLUTTER_VERSION'))); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Since this is code from your Flutter PR, would it also make sense to bring the corresponding tests over?