From 7a2fc4ad8ba9129afd73ec1cb2eb205f92b651ff Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Sat, 29 Jan 2022 02:07:28 +0100 Subject: [PATCH 1/2] Fix wrong SDK being reported when sentry_logging is used --- CHANGELOG.md | 1 + logging/lib/src/logging_integration.dart | 16 +++------------- logging/lib/src/version.dart | 4 ++-- logging/test/logging_integration_test.dart | 7 +++---- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8d9d0a78a..560d4d6187 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # Unreleased +* Fix: `sentry_logging` incorrectly setting SDK name # 6.3.0-beta.4 diff --git a/logging/lib/src/logging_integration.dart b/logging/lib/src/logging_integration.dart index c0327f7763..12fb83613b 100644 --- a/logging/lib/src/logging_integration.dart +++ b/logging/lib/src/logging_integration.dart @@ -2,8 +2,9 @@ import 'dart:async'; import 'package:logging/logging.dart'; import 'package:sentry/sentry.dart'; -import 'version.dart'; + import 'extension.dart'; +import 'version.dart'; /// An [Integration] which listens to all messages of the /// [logging](https://pub.dev/packages/logging) package. @@ -28,13 +29,13 @@ class LoggingIntegration extends Integration { @override FutureOr call(Hub hub, SentryOptions options) { _hub = hub; - _setSdkVersion(options); _subscription = Logger.root.onRecord.listen( _onLog, onError: (Object error, StackTrace stackTrace) async { await _hub.captureException(error, stackTrace: stackTrace); }, ); + options.sdk.addPackage(packageName, sdkVersion); options.sdk.addIntegration('LoggingIntegration'); } @@ -44,17 +45,6 @@ class LoggingIntegration extends Integration { await _subscription.cancel(); } - void _setSdkVersion(SentryOptions options) { - final sdk = SdkVersion( - name: sdkName, - version: sdkVersion, - integrations: options.sdk.integrations, - packages: options.sdk.packages, - ); - sdk.addPackage('pub:sentry_logging', sdkVersion); - options.sdk = sdk; - } - bool _isLoggable(Level logLevel, Level minLevel) { if (logLevel == Level.OFF) { return false; diff --git a/logging/lib/src/version.dart b/logging/lib/src/version.dart index 8a62155707..d125144c32 100644 --- a/logging/lib/src/version.dart +++ b/logging/lib/src/version.dart @@ -1,5 +1,5 @@ /// The SDK version reported to Sentry.io in the submitted events. const String sdkVersion = '6.3.0-beta.5'; -/// The default SDK name reported to Sentry.io in the submitted events. -const String sdkName = 'sentry.dart.logging'; +/// The package name reported to Sentry.io in the submitted events. +const String packageName = 'pub:sentry_logging'; diff --git a/logging/test/logging_integration_test.dart b/logging/test/logging_integration_test.dart index 23c006650f..2597c4065a 100644 --- a/logging/test/logging_integration_test.dart +++ b/logging/test/logging_integration_test.dart @@ -28,10 +28,9 @@ void main() { await sut.call(fixture.hub, fixture.options); await sut.close(); - expect(fixture.options.sdk.name, sdkName); - final package = fixture.options.sdk.packages - .firstWhere((it) => it.name == 'pub:sentry_logging'); - expect(package.name, 'pub:sentry_logging'); + final package = + fixture.options.sdk.packages.firstWhere((it) => it.name == packageName); + expect(package.name, packageName); expect(package.version, sdkVersion); }); From 81915694a01ea5b1d04fe34be7c639ea47664bcd Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto <5731772+marandaneto@users.noreply.github.com> Date: Sun, 30 Jan 2022 08:42:35 +0100 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 560d4d6187..8761369c61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Unreleased -* Fix: `sentry_logging` incorrectly setting SDK name + +* Fix: `sentry_logging` incorrectly setting SDK name (#725) # 6.3.0-beta.4