Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))

### Dependencies

- Bump Cocoa SDK from v8.30.0 to v8.30.1 ([#2155](https://github.com/getsentry/sentry-dart/pull/2155))
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