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

Set dart runtime version with parsed Platform.version #2156

Merged
merged 11 commits into from
Jul 10, 2024
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
- Time out for app start info retrieval has been reduced to 10s
- If `autoAppStarts` is `false` and `setAppStartEnd` has not been called, the app start event processor will now return early instead of waiting for `getAppStartInfo` to finish

### Improvements

- Set dart runtime version with parsed `Platform.version` ([#2156](https://github.com/getsentry/sentry-dart/pull/2156))

## 8.4.0-beta.1

### Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ class IoEnricherEventProcessor implements EnricherEventProcessor {
IoEnricherEventProcessor(this._options);

final SentryOptions _options;
late final String _dartVersion = _extractDartVersion(Platform.version);

/// Extracts the semantic version and channel from the full version string.
///
/// Example:
/// Input: "3.5.0-180.3.beta (beta) (Wed Jun 5 15:06:15 2024 +0000) on "android_arm64""
/// Output: "3.5.0-180.3.beta (beta)"
///
/// Falls back to the full version if the matching fails.
String _extractDartVersion(String fullVersion) {
RegExp channelRegex = RegExp(r'\((stable|beta|dev)\)');
Match? match = channelRegex.firstMatch(fullVersion);
// if match is null this will return the full version
return fullVersion.substring(0, match?.end);
}

@override
SentryEvent? apply(SentryEvent event, Hint hint) {
Expand Down Expand Up @@ -56,6 +71,7 @@ class IoEnricherEventProcessor implements EnricherEventProcessor {
// like Flutter: https://flutter.dev/docs/testing/build-modes
final dartRuntime = SentryRuntime(
name: 'Dart',
version: _dartVersion,
rawDescription: Platform.version,
);
if (runtimes == null) {
Expand Down
4 changes: 4 additions & 0 deletions dart/test/event_processor/enricher/io_enricher_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@TestOn('vm')
library dart_test;

import 'dart:io';

import 'package:sentry/sentry.dart';
import 'package:sentry/src/event_processor/enricher/io_enricher_event_processor.dart';
import 'package:test/test.dart';
Expand All @@ -25,6 +27,8 @@ void main() {
.firstWhere((element) => element.name == 'Dart');
expect(dartRuntime?.name, 'Dart');
expect(dartRuntime?.rawDescription, isNotNull);
expect(dartRuntime!.version.toString(), isNot(Platform.version));
expect(Platform.version, contains(dartRuntime.version.toString()));
});

test('does add to existing runtimes', () {
Expand Down
Loading