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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
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
16 changes: 14 additions & 2 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,11 +35,21 @@ 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
Expand All @@ -48,6 +59,7 @@ class NoOpSentryClient implements SentryClient {
String template,
List<dynamic> params,
Scope scope,
dynamic hint,
}) =>
Future.value(SentryId.empty());

Expand Down
9 changes: 7 additions & 2 deletions dart/lib/src/noop_hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ 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
Expand All @@ -32,6 +36,7 @@ class NoOpHub implements Hub {
SentryLevel level = SentryLevel.info,
String template,
List params,
dynamic hint,
}) =>
Future.value(SentryId.empty());

Expand Down
16 changes: 13 additions & 3 deletions dart/lib/src/sentry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,39 @@ 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,
dynamic hint,
}) async {
return currentHub.captureMessage(
message,
level: level,
template: template,
params: params,
hint: hint,
);
}

Expand Down