Skip to content

Commit 7a2fc4a

Browse files
committed
Fix wrong SDK being reported when sentry_logging is used
1 parent 17894ef commit 7a2fc4a

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Unreleased
2+
* Fix: `sentry_logging` incorrectly setting SDK name
23

34
# 6.3.0-beta.4
45

logging/lib/src/logging_integration.dart

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import 'dart:async';
22

33
import 'package:logging/logging.dart';
44
import 'package:sentry/sentry.dart';
5-
import 'version.dart';
5+
66
import 'extension.dart';
7+
import 'version.dart';
78

89
/// An [Integration] which listens to all messages of the
910
/// [logging](https://pub.dev/packages/logging) package.
@@ -28,13 +29,13 @@ class LoggingIntegration extends Integration<SentryOptions> {
2829
@override
2930
FutureOr<void> call(Hub hub, SentryOptions options) {
3031
_hub = hub;
31-
_setSdkVersion(options);
3232
_subscription = Logger.root.onRecord.listen(
3333
_onLog,
3434
onError: (Object error, StackTrace stackTrace) async {
3535
await _hub.captureException(error, stackTrace: stackTrace);
3636
},
3737
);
38+
options.sdk.addPackage(packageName, sdkVersion);
3839
options.sdk.addIntegration('LoggingIntegration');
3940
}
4041

@@ -44,17 +45,6 @@ class LoggingIntegration extends Integration<SentryOptions> {
4445
await _subscription.cancel();
4546
}
4647

47-
void _setSdkVersion(SentryOptions options) {
48-
final sdk = SdkVersion(
49-
name: sdkName,
50-
version: sdkVersion,
51-
integrations: options.sdk.integrations,
52-
packages: options.sdk.packages,
53-
);
54-
sdk.addPackage('pub:sentry_logging', sdkVersion);
55-
options.sdk = sdk;
56-
}
57-
5848
bool _isLoggable(Level logLevel, Level minLevel) {
5949
if (logLevel == Level.OFF) {
6050
return false;

logging/lib/src/version.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// The SDK version reported to Sentry.io in the submitted events.
22
const String sdkVersion = '6.3.0-beta.5';
33

4-
/// The default SDK name reported to Sentry.io in the submitted events.
5-
const String sdkName = 'sentry.dart.logging';
4+
/// The package name reported to Sentry.io in the submitted events.
5+
const String packageName = 'pub:sentry_logging';

logging/test/logging_integration_test.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ void main() {
2828
await sut.call(fixture.hub, fixture.options);
2929
await sut.close();
3030

31-
expect(fixture.options.sdk.name, sdkName);
32-
final package = fixture.options.sdk.packages
33-
.firstWhere((it) => it.name == 'pub:sentry_logging');
34-
expect(package.name, 'pub:sentry_logging');
31+
final package =
32+
fixture.options.sdk.packages.firstWhere((it) => it.name == packageName);
33+
expect(package.name, packageName);
3534
expect(package.version, sdkVersion);
3635
});
3736

0 commit comments

Comments
 (0)