Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
ref: hint is passed across Sentry static class, Hub and Client
  • Loading branch information
marandaneto committed Oct 22, 2020
commit 81575d1925b07104c15a28df2e3c8cf71f324264
7 changes: 5 additions & 2 deletions dart/lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ abstract class SentryClient {
SentryEvent event, {
StackFrameFilter stackFrameFilter,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope scope,
dynamic hint,
}) async {
final now = options.clock();
var authHeader = 'Sentry sentry_version=6, sentry_client=$clientId, '
Expand Down Expand Up @@ -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]
Expand All @@ -171,6 +173,7 @@ abstract class SentryClient {
String template,
List<dynamic> params,
Scope scope,
dynamic hint,
}) {
final event = SentryEvent(
message: Message(
Expand All @@ -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<void> close() async {
Expand Down
19 changes: 15 additions & 4 deletions dart/lib/src/hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Hub {
SentryId get lastEventId => _lastEventId;

/// Captures the event.
Future<SentryId> captureEvent(SentryEvent event) async {
Future<SentryId> captureEvent(SentryEvent event, {dynamic hint}) async {
var sentryId = SentryId.empty();

if (!_isEnabled) {
Expand All @@ -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,
Expand All @@ -94,6 +98,7 @@ class Hub {
Future<SentryId> captureException(
dynamic throwable, {
dynamic stackTrace,
dynamic hint,
}) async {
var sentryId = SentryId.empty();

Expand All @@ -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,
Expand All @@ -138,6 +147,7 @@ class Hub {
SentryLevel level = SentryLevel.info,
String template,
List<dynamic> params,
dynamic hint,
}) async {
var sentryId = SentryId.empty();

Expand All @@ -161,6 +171,7 @@ class Hub {
template: template,
params: params,
scope: item.scope,
hint: hint,
);
} catch (err) {
_options.logger(
Expand Down
28 changes: 19 additions & 9 deletions dart/lib/src/noop_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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._();
Expand Down Expand Up @@ -34,21 +35,30 @@ class NoOpSentryClient implements SentryClient {
Map<String, String> buildHeaders(String authHeader) => {};

@override
Future<SentryId> captureEvent(SentryEvent event, {stackFrameFilter, scope}) =>
Future<SentryId> captureEvent(
SentryEvent event, {
StackFrameFilter stackFrameFilter,
Scope scope,
dynamic hint,
}) =>
Future.value(SentryId.empty());

@override
Future<SentryId> captureException(throwable, {stackTrace, scope}) =>
Future<SentryId> captureException(
dynamic throwable, {
dynamic stackTrace,
Scope scope,
dynamic hint,
}) =>
Future.value(SentryId.empty());

@override
Future<SentryId> captureMessage(
String message, {
SentryLevel level = SentryLevel.info,
String template,
List<dynamic> params,
Scope scope,
}) =>
Future<SentryId> captureMessage(String message,
{SentryLevel level = SentryLevel.info,
String template,
List<dynamic> params,
Scope scope,
dynamic hint}) =>
Future.value(SentryId.empty());

@override
Expand Down
19 changes: 11 additions & 8 deletions dart/lib/src/noop_hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,23 @@ class NoOpHub implements Hub {
void bindClient(SentryClient client) {}

@override
Future<SentryId> captureEvent(SentryEvent event) =>
Future<SentryId> captureEvent(SentryEvent event, {dynamic hint}) =>
Future.value(SentryId.empty());

@override
Future<SentryId> captureException(throwable, {stackTrace}) =>
Future<SentryId> captureException(
dynamic throwable, {
dynamic stackTrace,
dynamic hint,
}) =>
Future.value(SentryId.empty());

@override
Future<SentryId> captureMessage(
String message, {
SentryLevel level = SentryLevel.info,
String template,
List params,
}) =>
Future<SentryId> captureMessage(String message,
{SentryLevel level = SentryLevel.info,
String template,
List params,
dynamic hint}) =>
Future.value(SentryId.empty());

@override
Expand Down
28 changes: 13 additions & 15 deletions dart/lib/src/sentry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,28 @@ class Sentry {
}

/// Reports an [event] to Sentry.io.
static Future<SentryId> captureEvent(SentryEvent event) async {
return currentHub.captureEvent(event);
static Future<SentryId> captureEvent(SentryEvent event,
{dynamic hint}) async {
return currentHub.captureEvent(event, hint: hint);
}

/// Reports the [exception] and optionally its [stackTrace] to Sentry.io.
static Future<SentryId> captureException(
dynamic error, {
dynamic stackTrace,
dynamic hint,
}) async {
return currentHub.captureException(error, stackTrace: stackTrace);
return currentHub.captureException(error,
stackTrace: stackTrace, hint: hint);
}

Future<SentryId> captureMessage(
String message, {
SentryLevel level,
String template,
List<dynamic> params,
}) async {
return currentHub.captureMessage(
message,
level: level,
template: template,
params: params,
);
Future<SentryId> captureMessage(String message,
{SentryLevel level,
String template,
List<dynamic> params,
dynamic hint}) async {
return currentHub.captureMessage(message,
level: level, template: template, params: params, hint: hint);
}

/// Close the client SDK
Expand Down