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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

* Fix: `sentry_logging` incorrectly setting SDK name (#725)

# 6.3.0-beta.4

* Feat: Support Attachment.addToTransactions (#709)
Expand Down
16 changes: 3 additions & 13 deletions logging/lib/src/logging_integration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -28,13 +29,13 @@ class LoggingIntegration extends Integration<SentryOptions> {
@override
FutureOr<void> 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');
}

Expand All @@ -44,17 +45,6 @@ class LoggingIntegration extends Integration<SentryOptions> {
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;
Expand Down
4 changes: 2 additions & 2 deletions logging/lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -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';
7 changes: 3 additions & 4 deletions logging/test/logging_integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down