From 81575d1925b07104c15a28df2e3c8cf71f324264 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 22 Oct 2020 10:10:14 +0200 Subject: [PATCH 1/4] ref: hint is passed across Sentry static class, Hub and Client --- dart/lib/src/client.dart | 7 +++++-- dart/lib/src/hub.dart | 19 +++++++++++++++---- dart/lib/src/noop_client.dart | 28 +++++++++++++++++++--------- dart/lib/src/noop_hub.dart | 19 +++++++++++-------- dart/lib/src/sentry.dart | 28 +++++++++++++--------------- 5 files changed, 63 insertions(+), 38 deletions(-) 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..10511dbc9e 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,21 +35,30 @@ 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 - Future captureMessage( - String message, { - SentryLevel level = SentryLevel.info, - String template, - List params, - Scope scope, - }) => + Future captureMessage(String message, + {SentryLevel level = SentryLevel.info, + String template, + List params, + Scope scope, + dynamic hint}) => Future.value(SentryId.empty()); @override diff --git a/dart/lib/src/noop_hub.dart b/dart/lib/src/noop_hub.dart index 30dbb422fe..5137f473b7 100644 --- a/dart/lib/src/noop_hub.dart +++ b/dart/lib/src/noop_hub.dart @@ -19,20 +19,23 @@ 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 - Future captureMessage( - String message, { - SentryLevel level = SentryLevel.info, - String template, - List params, - }) => + Future captureMessage(String message, + {SentryLevel level = SentryLevel.info, + String template, + List params, + dynamic hint}) => Future.value(SentryId.empty()); @override diff --git a/dart/lib/src/sentry.dart b/dart/lib/src/sentry.dart index 3778b56b3d..edfe81ab03 100644 --- a/dart/lib/src/sentry.dart +++ b/dart/lib/src/sentry.dart @@ -45,30 +45,28 @@ 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( - String message, { - SentryLevel level, - String template, - List params, - }) async { - return currentHub.captureMessage( - message, - level: level, - template: template, - params: params, - ); + Future captureMessage(String message, + {SentryLevel level, + String template, + List params, + dynamic hint}) async { + return currentHub.captureMessage(message, + level: level, template: template, params: params, hint: hint); } /// Close the client SDK From d04990ca9238ae925554028c0fd0c7bacfeb557c Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 22 Oct 2020 10:10:56 +0200 Subject: [PATCH 2/4] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4917265a24..0437fe85a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ - Feature: sentry options #116 - Ref: SentryId generates UUID - Ref: Event now is SentryEvent and added GPU +- Ref: Hint is passed across Sentry static class, Hub and Client # `package:sentry` changelog From 067af136a7e89369087d432bb20212b7569c853b Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 22 Oct 2020 12:10:23 +0200 Subject: [PATCH 3/4] added trailling comma --- dart/lib/src/noop_client.dart | 14 ++++++++------ dart/lib/src/noop_hub.dart | 12 +++++++----- dart/lib/src/sentry.dart | 12 +++++++----- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/dart/lib/src/noop_client.dart b/dart/lib/src/noop_client.dart index 10511dbc9e..06a2a2e8af 100644 --- a/dart/lib/src/noop_client.dart +++ b/dart/lib/src/noop_client.dart @@ -53,12 +53,14 @@ class NoOpSentryClient implements SentryClient { Future.value(SentryId.empty()); @override - Future captureMessage(String message, - {SentryLevel level = SentryLevel.info, - String template, - List params, - Scope scope, - dynamic hint}) => + Future captureMessage( + String message, { + SentryLevel level = SentryLevel.info, + String template, + List params, + Scope scope, + dynamic hint, + }) => Future.value(SentryId.empty()); @override diff --git a/dart/lib/src/noop_hub.dart b/dart/lib/src/noop_hub.dart index 5137f473b7..f8e528430e 100644 --- a/dart/lib/src/noop_hub.dart +++ b/dart/lib/src/noop_hub.dart @@ -31,11 +31,13 @@ class NoOpHub implements Hub { Future.value(SentryId.empty()); @override - Future captureMessage(String message, - {SentryLevel level = SentryLevel.info, - String template, - List params, - dynamic hint}) => + Future captureMessage( + String message, { + SentryLevel level = SentryLevel.info, + String template, + List params, + dynamic hint, + }) => Future.value(SentryId.empty()); @override diff --git a/dart/lib/src/sentry.dart b/dart/lib/src/sentry.dart index edfe81ab03..fff74093db 100644 --- a/dart/lib/src/sentry.dart +++ b/dart/lib/src/sentry.dart @@ -60,11 +60,13 @@ class Sentry { stackTrace: stackTrace, hint: hint); } - Future captureMessage(String message, - {SentryLevel level, - String template, - List params, - dynamic hint}) async { + Future captureMessage( + String message, { + SentryLevel level, + String template, + List params, + dynamic hint, + }) async { return currentHub.captureMessage(message, level: level, template: template, params: params, hint: hint); } From 1f8c5e2884ca2710e7bb7fdf1fb1f1d1cc1cefeb Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 22 Oct 2020 12:14:10 +0200 Subject: [PATCH 4/4] added trailling comma --- dart/lib/src/sentry.dart | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/dart/lib/src/sentry.dart b/dart/lib/src/sentry.dart index fff74093db..31409f156a 100644 --- a/dart/lib/src/sentry.dart +++ b/dart/lib/src/sentry.dart @@ -45,8 +45,10 @@ class Sentry { } /// Reports an [event] to Sentry.io. - static Future captureEvent(SentryEvent event, - {dynamic hint}) async { + static Future captureEvent( + SentryEvent event, { + dynamic hint, + }) async { return currentHub.captureEvent(event, hint: hint); } @@ -56,8 +58,11 @@ class Sentry { dynamic stackTrace, dynamic hint, }) async { - return currentHub.captureException(error, - stackTrace: stackTrace, hint: hint); + return currentHub.captureException( + error, + stackTrace: stackTrace, + hint: hint, + ); } Future captureMessage( @@ -67,8 +72,13 @@ class Sentry { List params, dynamic hint, }) async { - return currentHub.captureMessage(message, - level: level, template: template, params: params, hint: hint); + return currentHub.captureMessage( + message, + level: level, + template: template, + params: params, + hint: hint, + ); } /// Close the client SDK