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 @@ -54,8 +54,21 @@ class IoEnricherEventProcessor implements EnricherEventProcessor {
List<SentryRuntime> _getRuntimes(List<SentryRuntime>? runtimes) {
// Pure Dart doesn't have specific runtimes per build mode
// like Flutter: https://flutter.dev/docs/testing/build-modes
final dartRuntime = SentryRuntime(

// Extracts the semantic version and channel from the full version string.
// 3.5.0-180.3.beta (beta) (Wed Jun 5 15:06:15 2024 +0000) on "android_arm64"
// turns into 3.5.0-180.3.beta (beta)
String version = Platform.version;
RegExp channelRegex = RegExp(r'\((stable|beta|dev)\)');
vaind marked this conversation as resolved.
Show resolved Hide resolved
Match? match = channelRegex.firstMatch(version);

if (match != null) {
version = version.substring(0, match.end);
}

SentryRuntime dartRuntime = SentryRuntime(
name: 'Dart',
version: version,
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() != Platform.version, true);
expect(Platform.version.contains(dartRuntime.version.toString()), true);
buenaflor marked this conversation as resolved.
Show resolved Hide resolved
});

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