-
-
Notifications
You must be signed in to change notification settings - Fork 223
/
hub_adapter.dart
199 lines (171 loc) · 4.74 KB
/
hub_adapter.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
import 'dart:async';
import 'package:meta/meta.dart';
import 'hint.dart';
import 'hub.dart';
import 'metrics/metric.dart';
import 'metrics/metrics_aggregator.dart';
import 'metrics/metrics_api.dart';
import 'profiling.dart';
import 'protocol.dart';
import 'scope.dart';
import 'sentry.dart';
import 'sentry_client.dart';
import 'sentry_user_feedback.dart';
import 'sentry_options.dart';
import 'tracing.dart';
/// Hub adapter to make Integrations testable
class HubAdapter implements Hub {
const HubAdapter._();
static final HubAdapter _instance = HubAdapter._();
@override
@internal
SentryOptions get options => Sentry.currentHub.options;
@override
@internal
MetricsApi get metricsApi => Sentry.currentHub.metricsApi;
factory HubAdapter() {
return _instance;
}
@override
Future<void> addBreadcrumb(Breadcrumb crumb, {Hint? hint}) async =>
await Sentry.addBreadcrumb(crumb, hint: hint);
@override
void bindClient(SentryClient client) => Sentry.bindClient(client);
@override
Future<SentryId> captureEvent(
SentryEvent event, {
dynamic stackTrace,
Hint? hint,
ScopeCallback? withScope,
}) =>
Sentry.captureEvent(
event,
stackTrace: stackTrace,
hint: hint,
withScope: withScope,
);
@override
Future<SentryId> captureException(
dynamic throwable, {
dynamic stackTrace,
Hint? hint,
ScopeCallback? withScope,
}) =>
Sentry.captureException(
throwable,
stackTrace: stackTrace,
hint: hint,
withScope: withScope,
);
@override
Future<SentryId> captureMessage(
String? message, {
SentryLevel? level,
String? template,
List? params,
Hint? hint,
ScopeCallback? withScope,
}) =>
Sentry.captureMessage(
message,
level: level,
template: template,
params: params,
hint: hint,
withScope: withScope,
);
@override
Hub clone() => Sentry.clone();
@override
Future<void> close() => Sentry.close();
@override
FutureOr<void> configureScope(ScopeCallback callback) =>
Sentry.configureScope(callback);
@override
bool get isEnabled => Sentry.isEnabled;
@override
SentryId get lastEventId => Sentry.lastEventId;
@override
Future<SentryId> captureTransaction(
SentryTransaction transaction, {
SentryTraceContextHeader? traceContext,
}) =>
Sentry.currentHub.captureTransaction(
transaction,
traceContext: traceContext,
);
@override
ISentrySpan? getSpan() => Sentry.currentHub.getSpan();
@override
Future<void> captureUserFeedback(SentryUserFeedback userFeedback) =>
Sentry.captureUserFeedback(userFeedback);
@override
ISentrySpan startTransactionWithContext(
SentryTransactionContext transactionContext, {
Map<String, dynamic>? customSamplingContext,
DateTime? startTimestamp,
bool? bindToScope,
bool? waitForChildren,
Duration? autoFinishAfter,
bool? trimEnd,
OnTransactionFinish? onFinish,
}) =>
Sentry.startTransactionWithContext(
transactionContext,
customSamplingContext: customSamplingContext,
startTimestamp: startTimestamp,
bindToScope: bindToScope,
waitForChildren: waitForChildren,
autoFinishAfter: autoFinishAfter,
trimEnd: trimEnd,
onFinish: onFinish,
);
@override
ISentrySpan startTransaction(
String name,
String operation, {
String? description,
DateTime? startTimestamp,
bool? bindToScope,
bool? waitForChildren,
Duration? autoFinishAfter,
bool? trimEnd,
OnTransactionFinish? onFinish,
Map<String, dynamic>? customSamplingContext,
}) =>
Sentry.startTransaction(
name,
operation,
description: description,
startTimestamp: startTimestamp,
bindToScope: bindToScope,
waitForChildren: waitForChildren,
autoFinishAfter: autoFinishAfter,
trimEnd: trimEnd,
onFinish: onFinish,
customSamplingContext: customSamplingContext,
);
@override
void setSpanContext(
dynamic throwable,
ISentrySpan span,
String transaction,
) =>
Sentry.currentHub.setSpanContext(throwable, span, transaction);
@internal
@override
set profilerFactory(SentryProfilerFactory? value) =>
Sentry.currentHub.profilerFactory = value;
@internal
@override
SentryProfilerFactory? get profilerFactory =>
Sentry.currentHub.profilerFactory;
@override
Scope get scope => Sentry.currentHub.scope;
@override
Future<SentryId> captureMetrics(Map<int, Iterable<Metric>> metricsBuckets) =>
Sentry.currentHub.captureMetrics(metricsBuckets);
@override
MetricsAggregator? get metricsAggregator =>
Sentry.currentHub.metricsAggregator;
}