From c9dee2a3b979f83512a27ea6b203d426aa965a55 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 15 Nov 2022 13:42:34 +0100 Subject: [PATCH 1/6] use sentryClientName instead of sdk.identifier --- dart/lib/src/protocol/sdk_version.dart | 2 -- dart/lib/src/sentry_options.dart | 8 ++++++-- dart/lib/src/transport/http_transport.dart | 4 ++-- dart/test/sentry_options_test.dart | 8 ++++++++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/dart/lib/src/protocol/sdk_version.dart b/dart/lib/src/protocol/sdk_version.dart index b69ca3c130..60ac75e0c3 100644 --- a/dart/lib/src/protocol/sdk_version.dart +++ b/dart/lib/src/protocol/sdk_version.dart @@ -61,8 +61,6 @@ class SdkVersion { /// An immutable list of packages that compose this SDK. List get packages => List.unmodifiable(_packages); - String get identifier => '$name/$version'; - /// Deserializes a [SdkVersion] from JSON [Map]. factory SdkVersion.fromJson(Map json) { final packagesJson = json['packages'] as List?; diff --git a/dart/lib/src/sentry_options.dart b/dart/lib/src/sentry_options.dart index 361486e1d6..a2dac7e14a 100644 --- a/dart/lib/src/sentry_options.dart +++ b/dart/lib/src/sentry_options.dart @@ -139,7 +139,7 @@ class SentryOptions { /// Sentry client name used for the HTTP authHeader and userAgent eg /// sentry.{language}.{platform}/{version} eg sentry.java.android/2.0.0 would be a valid case - String? sentryClientName; + late String sentryClientName; /// This function is called with an SDK specific event object and can return a modified event /// object or nothing to skip reporting the event @@ -318,13 +318,17 @@ class SentryOptions { platformChecker = checker; } + final name = sdkName(platformChecker.isWeb); sdk = SdkVersion(name: sdkName(platformChecker.isWeb), version: sdkVersion); sdk.addPackage('pub:sentry', sdkVersion); + sentryClientName = '$name/$sdkVersion'; } @internal SentryOptions.empty() { - sdk = SdkVersion(name: 'noop', version: sdkVersion); + final name = 'noop'; + sdk = SdkVersion(name: name, version: sdkVersion); + sentryClientName = '$name/$sdkVersion'; } /// Adds an event processor diff --git a/dart/lib/src/transport/http_transport.dart b/dart/lib/src/transport/http_transport.dart index 317070695a..1d9c35842d 100644 --- a/dart/lib/src/transport/http_transport.dart +++ b/dart/lib/src/transport/http_transport.dart @@ -41,11 +41,11 @@ class HttpTransport implements Transport { _recorder = _options.recorder, _headers = _buildHeaders( _options.platformChecker.isWeb, - _options.sdk.identifier, + _options.sentryClientName, ) { _credentialBuilder = _CredentialBuilder( _dsn, - _options.sdk.identifier, + _options.sentryClientName, _options.clock, ); } diff --git a/dart/test/sentry_options_test.dart b/dart/test/sentry_options_test.dart index 97a22c6f6a..22f1740f37 100644 --- a/dart/test/sentry_options_test.dart +++ b/dart/test/sentry_options_test.dart @@ -1,6 +1,7 @@ import 'package:http/http.dart'; import 'package:sentry/sentry.dart'; import 'package:sentry/src/noop_client.dart'; +import 'package:sentry/src/version.dart'; import 'package:test/test.dart'; import 'mocks.dart'; @@ -91,4 +92,11 @@ void main() { expect(options.tracePropagationTargets, ['.*']); }); + + test('SentryOptions has sentryClientName set', () { + final options = SentryOptions(dsn: fakeDsn); + + expect(options.sentryClientName, + '${sdkName(options.platformChecker.isWeb)}/$sdkVersion'); + }); } From 3cdace209638096b87be13cb1361b8742c09eba7 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 15 Nov 2022 13:45:18 +0100 Subject: [PATCH 2/6] add changelog entry --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59e2a436e4..a5937ffdcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 7.0.0 +### Fixes + - Fix: Remove `SentryOptions` related parameters from classes which also take `Hub` as a parameter (#816) ### Breaking Changes @@ -13,6 +15,7 @@ - screenResolution - theme - Removed isolate name from Dart context. It's now reported via the threads interface. It can be enabled via `options.attachThreads` +- Use `sentryClientName` instead of `sdk.identifier` ([#1135](https://github.com/getsentry/sentry-dart/pull/1135)) ## 6.11.1 From 1e9b6104f6b97a626e9f812a5b4873abac0ee004 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 15 Nov 2022 13:49:22 +0100 Subject: [PATCH 3/6] move changelog entry to unreleased secion for now --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5937ffdcf..8d47ebd3b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Breaking Changes + +- Use `sentryClientName` instead of `sdk.identifier` ([#1135](https://github.com/getsentry/sentry-dart/pull/1135)) + ## 7.0.0 ### Fixes @@ -15,7 +21,6 @@ - screenResolution - theme - Removed isolate name from Dart context. It's now reported via the threads interface. It can be enabled via `options.attachThreads` -- Use `sentryClientName` instead of `sdk.identifier` ([#1135](https://github.com/getsentry/sentry-dart/pull/1135)) ## 6.11.1 From 88c4c037f28051ba487a35981de3fec67da6da9e Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 15 Nov 2022 13:59:08 +0100 Subject: [PATCH 4/6] move to 7.0.0 section --- CHANGELOG.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d47ebd3b5..a5937ffdcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,5 @@ # Changelog -## Unreleased - -### Breaking Changes - -- Use `sentryClientName` instead of `sdk.identifier` ([#1135](https://github.com/getsentry/sentry-dart/pull/1135)) - ## 7.0.0 ### Fixes @@ -21,6 +15,7 @@ - screenResolution - theme - Removed isolate name from Dart context. It's now reported via the threads interface. It can be enabled via `options.attachThreads` +- Use `sentryClientName` instead of `sdk.identifier` ([#1135](https://github.com/getsentry/sentry-dart/pull/1135)) ## 6.11.1 From 959c3ea4fd372449a6f11d567bb4cf63dc3355d4 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 15 Nov 2022 14:19:39 +0100 Subject: [PATCH 5/6] change sentryClientName to computed property --- dart/lib/src/sentry_options.dart | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/dart/lib/src/sentry_options.dart b/dart/lib/src/sentry_options.dart index a2dac7e14a..3344919240 100644 --- a/dart/lib/src/sentry_options.dart +++ b/dart/lib/src/sentry_options.dart @@ -139,7 +139,8 @@ class SentryOptions { /// Sentry client name used for the HTTP authHeader and userAgent eg /// sentry.{language}.{platform}/{version} eg sentry.java.android/2.0.0 would be a valid case - late String sentryClientName; + String get sentryClientName => + '${sdkName(platformChecker.isWeb)}/$sdkVersion'; /// This function is called with an SDK specific event object and can return a modified event /// object or nothing to skip reporting the event @@ -317,18 +318,13 @@ class SentryOptions { if (checker != null) { platformChecker = checker; } - - final name = sdkName(platformChecker.isWeb); sdk = SdkVersion(name: sdkName(platformChecker.isWeb), version: sdkVersion); sdk.addPackage('pub:sentry', sdkVersion); - sentryClientName = '$name/$sdkVersion'; } @internal SentryOptions.empty() { - final name = 'noop'; - sdk = SdkVersion(name: name, version: sdkVersion); - sentryClientName = '$name/$sdkVersion'; + sdk = SdkVersion(name: 'noop', version: sdkVersion); } /// Adds an event processor From 0626ffe45d18020b5d03b76727da63abdb98c275 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 15 Nov 2022 16:27:02 +0100 Subject: [PATCH 6/6] red values from sdk --- dart/lib/src/sentry_options.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dart/lib/src/sentry_options.dart b/dart/lib/src/sentry_options.dart index 3344919240..2d817d5c07 100644 --- a/dart/lib/src/sentry_options.dart +++ b/dart/lib/src/sentry_options.dart @@ -139,8 +139,7 @@ class SentryOptions { /// Sentry client name used for the HTTP authHeader and userAgent eg /// sentry.{language}.{platform}/{version} eg sentry.java.android/2.0.0 would be a valid case - String get sentryClientName => - '${sdkName(platformChecker.isWeb)}/$sdkVersion'; + String get sentryClientName => '${sdk.name}/${sdk.version}'; /// This function is called with an SDK specific event object and can return a modified event /// object or nothing to skip reporting the event