Skip to content

Commit 2cc1d78

Browse files
authored
Ref: Hint is passed across Sentry static class, Hub and Client (#124)
1 parent 3fa0b79 commit 2cc1d78

File tree

6 files changed

+55
-13
lines changed

6 files changed

+55
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- Ref: SentryId generates UUID #119
2828
- Ref: Event now is SentryEvent and added GPU #121
2929
- Feat: before breadcrumb and scope ref. #122
30+
- Ref: Hint is passed across Sentry static class, Hub and Client #124
3031

3132
# `package:sentry` changelog
3233

dart/lib/src/client.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ abstract class SentryClient {
9999
SentryEvent event, {
100100
StackFrameFilter stackFrameFilter,
101101
Scope scope,
102+
dynamic hint,
102103
}) async {
103104
final now = options.clock();
104105
var authHeader = 'Sentry sentry_version=6, sentry_client=$clientId, '
@@ -155,13 +156,14 @@ abstract class SentryClient {
155156
dynamic throwable, {
156157
dynamic stackTrace,
157158
Scope scope,
159+
dynamic hint,
158160
}) {
159161
final event = SentryEvent(
160162
exception: throwable,
161163
stackTrace: stackTrace,
162164
timestamp: options.clock(),
163165
);
164-
return captureEvent(event, scope: scope);
166+
return captureEvent(event, scope: scope, hint: hint);
165167
}
166168

167169
/// Reports the [template]
@@ -171,6 +173,7 @@ abstract class SentryClient {
171173
String template,
172174
List<dynamic> params,
173175
Scope scope,
176+
dynamic hint,
174177
}) {
175178
final event = SentryEvent(
176179
message: Message(
@@ -181,7 +184,7 @@ abstract class SentryClient {
181184
level: level,
182185
timestamp: options.clock(),
183186
);
184-
return captureEvent(event, scope: scope);
187+
return captureEvent(event, scope: scope, hint: hint);
185188
}
186189

187190
Future<void> close() async {

dart/lib/src/hub.dart

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Hub {
5454
SentryId get lastEventId => _lastEventId;
5555

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

6060
if (!_isEnabled) {
@@ -71,7 +71,11 @@ class Hub {
7171
final item = _peek();
7272
if (item != null) {
7373
try {
74-
sentryId = await item.client.captureEvent(event, scope: item.scope);
74+
sentryId = await item.client.captureEvent(
75+
event,
76+
scope: item.scope,
77+
hint: hint,
78+
);
7579
} catch (err) {
7680
_options.logger(
7781
SentryLevel.error,
@@ -94,6 +98,7 @@ class Hub {
9498
Future<SentryId> captureException(
9599
dynamic throwable, {
96100
dynamic stackTrace,
101+
dynamic hint,
97102
}) async {
98103
var sentryId = SentryId.empty();
99104

@@ -111,8 +116,12 @@ class Hub {
111116
final item = _peek();
112117
if (item != null) {
113118
try {
114-
sentryId = await item.client.captureException(throwable,
115-
stackTrace: stackTrace, scope: item.scope);
119+
sentryId = await item.client.captureException(
120+
throwable,
121+
stackTrace: stackTrace,
122+
scope: item.scope,
123+
hint: hint,
124+
);
116125
} catch (err) {
117126
_options.logger(
118127
SentryLevel.error,
@@ -138,6 +147,7 @@ class Hub {
138147
SentryLevel level = SentryLevel.info,
139148
String template,
140149
List<dynamic> params,
150+
dynamic hint,
141151
}) async {
142152
var sentryId = SentryId.empty();
143153

@@ -161,6 +171,7 @@ class Hub {
161171
template: template,
162172
params: params,
163173
scope: item.scope,
174+
hint: hint,
164175
);
165176
} catch (err) {
166177
_options.logger(

dart/lib/src/noop_client.dart

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'client.dart';
44
import 'protocol.dart';
55
import 'scope.dart';
66
import 'sentry_options.dart';
7+
import 'stack_trace.dart';
78

89
class NoOpSentryClient implements SentryClient {
910
NoOpSentryClient._();
@@ -34,11 +35,21 @@ class NoOpSentryClient implements SentryClient {
3435
Map<String, String> buildHeaders(String authHeader) => {};
3536

3637
@override
37-
Future<SentryId> captureEvent(SentryEvent event, {stackFrameFilter, scope}) =>
38+
Future<SentryId> captureEvent(
39+
SentryEvent event, {
40+
StackFrameFilter stackFrameFilter,
41+
Scope scope,
42+
dynamic hint,
43+
}) =>
3844
Future.value(SentryId.empty());
3945

4046
@override
41-
Future<SentryId> captureException(throwable, {stackTrace, scope}) =>
47+
Future<SentryId> captureException(
48+
dynamic throwable, {
49+
dynamic stackTrace,
50+
Scope scope,
51+
dynamic hint,
52+
}) =>
4253
Future.value(SentryId.empty());
4354

4455
@override
@@ -48,6 +59,7 @@ class NoOpSentryClient implements SentryClient {
4859
String template,
4960
List<dynamic> params,
5061
Scope scope,
62+
dynamic hint,
5163
}) =>
5264
Future.value(SentryId.empty());
5365

dart/lib/src/noop_hub.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ class NoOpHub implements Hub {
1919
void bindClient(SentryClient client) {}
2020

2121
@override
22-
Future<SentryId> captureEvent(SentryEvent event) =>
22+
Future<SentryId> captureEvent(SentryEvent event, {dynamic hint}) =>
2323
Future.value(SentryId.empty());
2424

2525
@override
26-
Future<SentryId> captureException(throwable, {stackTrace}) =>
26+
Future<SentryId> captureException(
27+
dynamic throwable, {
28+
dynamic stackTrace,
29+
dynamic hint,
30+
}) =>
2731
Future.value(SentryId.empty());
2832

2933
@override
@@ -32,6 +36,7 @@ class NoOpHub implements Hub {
3236
SentryLevel level = SentryLevel.info,
3337
String template,
3438
List params,
39+
dynamic hint,
3540
}) =>
3641
Future.value(SentryId.empty());
3742

dart/lib/src/sentry.dart

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,39 @@ class Sentry {
4545
}
4646

4747
/// Reports an [event] to Sentry.io.
48-
static Future<SentryId> captureEvent(SentryEvent event) async {
49-
return currentHub.captureEvent(event);
48+
static Future<SentryId> captureEvent(
49+
SentryEvent event, {
50+
dynamic hint,
51+
}) async {
52+
return currentHub.captureEvent(event, hint: hint);
5053
}
5154

5255
/// Reports the [exception] and optionally its [stackTrace] to Sentry.io.
5356
static Future<SentryId> captureException(
5457
dynamic error, {
5558
dynamic stackTrace,
59+
dynamic hint,
5660
}) async {
57-
return currentHub.captureException(error, stackTrace: stackTrace);
61+
return currentHub.captureException(
62+
error,
63+
stackTrace: stackTrace,
64+
hint: hint,
65+
);
5866
}
5967

6068
Future<SentryId> captureMessage(
6169
String message, {
6270
SentryLevel level,
6371
String template,
6472
List<dynamic> params,
73+
dynamic hint,
6574
}) async {
6675
return currentHub.captureMessage(
6776
message,
6877
level: level,
6978
template: template,
7079
params: params,
80+
hint: hint,
7181
);
7282
}
7383

0 commit comments

Comments
 (0)