diff --git a/CHANGELOG.md b/CHANGELOG.md index bbcd28ab28..790ffdd688 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - Ref: SentryId generates UUID #119 - Ref: Event now is SentryEvent and added GPU #121 - Feat: before breadcrumb and scope ref. #122 +- Ref: Hint is passed across Sentry static class, Hub and Client #124 # `package:sentry` changelog diff --git a/dart/lib/src/client.dart b/dart/lib/src/client.dart index 12ff28b3b1..cfc05058d7 100644 --- a/dart/lib/src/client.dart +++ b/dart/lib/src/client.dart @@ -99,6 +99,7 @@ abstract class SentryClient { SentryEvent event, { StackFrameFilter stackFrameFilter, Scope scope, + dynamic hint, }) async { final now = options.clock(); var authHeader = 'Sentry sentry_version=6, sentry_client=$clientId, ' @@ -155,13 +156,14 @@ abstract class SentryClient { dynamic throwable, { dynamic stackTrace, Scope scope, + dynamic hint, }) { final event = SentryEvent( exception: throwable, stackTrace: stackTrace, timestamp: options.clock(), ); - return captureEvent(event, scope: scope); + return captureEvent(event, scope: scope, hint: hint); } /// Reports the [template] @@ -171,6 +173,7 @@ abstract class SentryClient { String template, List params, Scope scope, + dynamic hint, }) { final event = SentryEvent( message: Message( @@ -181,7 +184,7 @@ abstract class SentryClient { level: level, timestamp: options.clock(), ); - return captureEvent(event, scope: scope); + return captureEvent(event, scope: scope, hint: hint); } Future close() async { diff --git a/dart/lib/src/hub.dart b/dart/lib/src/hub.dart index a93b09aa71..2244149fe3 100644 --- a/dart/lib/src/hub.dart +++ b/dart/lib/src/hub.dart @@ -54,7 +54,7 @@ class Hub { SentryId get lastEventId => _lastEventId; /// Captures the event. - Future captureEvent(SentryEvent event) async { + Future captureEvent(SentryEvent event, {dynamic hint}) async { var sentryId = SentryId.empty(); if (!_isEnabled) { @@ -71,7 +71,11 @@ class Hub { final item = _peek(); if (item != null) { try { - sentryId = await item.client.captureEvent(event, scope: item.scope); + sentryId = await item.client.captureEvent( + event, + scope: item.scope, + hint: hint, + ); } catch (err) { _options.logger( SentryLevel.error, @@ -94,6 +98,7 @@ class Hub { Future captureException( dynamic throwable, { dynamic stackTrace, + dynamic hint, }) async { var sentryId = SentryId.empty(); @@ -111,8 +116,12 @@ class Hub { final item = _peek(); if (item != null) { try { - sentryId = await item.client.captureException(throwable, - stackTrace: stackTrace, scope: item.scope); + sentryId = await item.client.captureException( + throwable, + stackTrace: stackTrace, + scope: item.scope, + hint: hint, + ); } catch (err) { _options.logger( SentryLevel.error, @@ -138,6 +147,7 @@ class Hub { SentryLevel level = SentryLevel.info, String template, List params, + dynamic hint, }) async { var sentryId = SentryId.empty(); @@ -161,6 +171,7 @@ class Hub { template: template, params: params, scope: item.scope, + hint: hint, ); } catch (err) { _options.logger( diff --git a/dart/lib/src/noop_client.dart b/dart/lib/src/noop_client.dart index c5f5c7d438..06a2a2e8af 100644 --- a/dart/lib/src/noop_client.dart +++ b/dart/lib/src/noop_client.dart @@ -4,6 +4,7 @@ import 'client.dart'; import 'protocol.dart'; import 'scope.dart'; import 'sentry_options.dart'; +import 'stack_trace.dart'; class NoOpSentryClient implements SentryClient { NoOpSentryClient._(); @@ -34,11 +35,21 @@ class NoOpSentryClient implements SentryClient { Map buildHeaders(String authHeader) => {}; @override - Future captureEvent(SentryEvent event, {stackFrameFilter, scope}) => + Future captureEvent( + SentryEvent event, { + StackFrameFilter stackFrameFilter, + Scope scope, + dynamic hint, + }) => Future.value(SentryId.empty()); @override - Future captureException(throwable, {stackTrace, scope}) => + Future captureException( + dynamic throwable, { + dynamic stackTrace, + Scope scope, + dynamic hint, + }) => Future.value(SentryId.empty()); @override @@ -48,6 +59,7 @@ class NoOpSentryClient implements SentryClient { String template, List params, Scope scope, + dynamic hint, }) => Future.value(SentryId.empty()); diff --git a/dart/lib/src/noop_hub.dart b/dart/lib/src/noop_hub.dart index 30dbb422fe..f8e528430e 100644 --- a/dart/lib/src/noop_hub.dart +++ b/dart/lib/src/noop_hub.dart @@ -19,11 +19,15 @@ class NoOpHub implements Hub { void bindClient(SentryClient client) {} @override - Future captureEvent(SentryEvent event) => + Future captureEvent(SentryEvent event, {dynamic hint}) => Future.value(SentryId.empty()); @override - Future captureException(throwable, {stackTrace}) => + Future captureException( + dynamic throwable, { + dynamic stackTrace, + dynamic hint, + }) => Future.value(SentryId.empty()); @override @@ -32,6 +36,7 @@ class NoOpHub implements Hub { SentryLevel level = SentryLevel.info, String template, List params, + dynamic hint, }) => Future.value(SentryId.empty()); diff --git a/dart/lib/src/sentry.dart b/dart/lib/src/sentry.dart index 3778b56b3d..31409f156a 100644 --- a/dart/lib/src/sentry.dart +++ b/dart/lib/src/sentry.dart @@ -45,16 +45,24 @@ class Sentry { } /// Reports an [event] to Sentry.io. - static Future captureEvent(SentryEvent event) async { - return currentHub.captureEvent(event); + static Future captureEvent( + SentryEvent event, { + dynamic hint, + }) async { + return currentHub.captureEvent(event, hint: hint); } /// Reports the [exception] and optionally its [stackTrace] to Sentry.io. static Future captureException( dynamic error, { dynamic stackTrace, + dynamic hint, }) async { - return currentHub.captureException(error, stackTrace: stackTrace); + return currentHub.captureException( + error, + stackTrace: stackTrace, + hint: hint, + ); } Future captureMessage( @@ -62,12 +70,14 @@ class Sentry { SentryLevel level, String template, List params, + dynamic hint, }) async { return currentHub.captureMessage( message, level: level, template: template, params: params, + hint: hint, ); }