-
-
Notifications
You must be signed in to change notification settings - Fork 257
Feat: Record & Send Client Reports #813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 14 commits
2fd4203
e616525
92d235b
e1256ae
a25f5b4
d0dabd5
fc2ec5b
16aac16
4b01a0f
7bae0a3
29251ad
b680640
b5f1e2e
7ffca77
3c59330
c246be3
65efb0f
04b8f2d
4fc0db3
2079d9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,9 @@ import 'dart:convert'; | |
|
||
import 'package:http/http.dart'; | ||
|
||
import '../client_reports/client_report_recorder.dart'; | ||
import '../client_reports/discard_reason.dart'; | ||
import 'data_category.dart'; | ||
import 'noop_encode.dart' if (dart.library.io) 'encode.dart'; | ||
import '../noop_client.dart'; | ||
import '../protocol.dart'; | ||
|
@@ -19,19 +22,22 @@ class HttpTransport implements Transport { | |
|
||
final RateLimiter _rateLimiter; | ||
|
||
final ClientReportRecorder _clientReportRecorder; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't put dependencies / objects to the options in ObjC. I guess you should follow your SDKs conventions and you can answer best how to follow these I think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't really have a central object/place to init dependencies AFAIK, but we rather worked with singletons for now, or other objects construct their dependencies internally, like in this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the refactoring to not expose the new classes I moved the instance of |
||
|
||
late _CredentialBuilder _credentialBuilder; | ||
|
||
final Map<String, String> _headers; | ||
|
||
factory HttpTransport(SentryOptions options, RateLimiter rateLimiter) { | ||
factory HttpTransport(SentryOptions options, RateLimiter rateLimiter, | ||
ClientReportRecorder clientReportRecorder) { | ||
if (options.httpClient is NoOpClient) { | ||
options.httpClient = Client(); | ||
} | ||
|
||
return HttpTransport._(options, rateLimiter); | ||
return HttpTransport._(options, rateLimiter, clientReportRecorder); | ||
} | ||
|
||
HttpTransport._(this._options, this._rateLimiter) | ||
HttpTransport._(this._options, this._rateLimiter, this._clientReportRecorder) | ||
: _dsn = Dsn.parse(_options.dsn!), | ||
_headers = _buildHeaders( | ||
_options.platformChecker.isWeb, | ||
|
@@ -51,6 +57,9 @@ class HttpTransport implements Transport { | |
return SentryId.empty(); | ||
} | ||
|
||
final clientReport = _clientReportRecorder.flush(); | ||
filteredEnvelope.addClientReport(clientReport); | ||
|
||
final streamedRequest = await _createStreamedRequest(filteredEnvelope); | ||
final response = await _options.httpClient | ||
.send(streamedRequest) | ||
|
@@ -118,6 +127,11 @@ class HttpTransport implements Transport { | |
_rateLimiter.updateRetryAfterLimits( | ||
sentryRateLimitHeader, retryAfterHeader, response.statusCode); | ||
} | ||
|
||
@override | ||
void recordLostEvent(DiscardReason reason, DataCategory category) { | ||
_clientReportRecorder.recordLostEvent(reason, category); | ||
} | ||
} | ||
|
||
class _CredentialBuilder { | ||
|
Uh oh!
There was an error while loading. Please reload this page.