File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed
Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import 'sentry_options.dart';
1616import 'sentry_stack_trace_factory.dart' ;
1717import 'transport/http_transport.dart' ;
1818import 'transport/noop_transport.dart' ;
19+ import 'transport/spotlight_http_transport.dart' ;
1920import 'utils/isolate_utils.dart' ;
2021import 'version.dart' ;
2122import 'sentry_envelope.dart' ;
@@ -49,6 +50,9 @@ class SentryClient {
4950 final rateLimiter = RateLimiter (options);
5051 options.transport = HttpTransport (options, rateLimiter);
5152 }
53+ if (options.enableSpotlight) {
54+ options.transport = SpotlightHttpTransport (options, options.transport);
55+ }
5256 return SentryClient ._(options);
5357 }
5458
Original file line number Diff line number Diff line change @@ -374,6 +374,12 @@ class SentryOptions {
374374 /// Settings this to `false` will set the `level` to [SentryLevel.error] .
375375 bool markAutomaticallyCollectedErrorsAsFatal = true ;
376376
377+ /// Whether to enable Spotlight for local development.
378+ bool enableSpotlight = false ;
379+
380+ /// The Spotlight URL. Defaults to http://localhost:8969/stream
381+ String spotlightUrl = 'http://localhost:8969/stream' ;
382+
377383 SentryOptions ({this .dsn, PlatformChecker ? checker}) {
378384 if (checker != null ) {
379385 platformChecker = checker;
Original file line number Diff line number Diff line change 1+ import 'package:http/http.dart' ;
2+
3+ import '../../sentry.dart' ;
4+
5+ /// Spotlight HTTP transport class that sends Sentry envelopes to both Sentry and Spotlight.
6+ class SpotlightHttpTransport extends Transport {
7+ final SentryOptions _options;
8+ final Transport _transport;
9+
10+ SpotlightHttpTransport (this ._options, this ._transport);
11+
12+ @override
13+ Future <SentryId ?> send (SentryEnvelope envelope) async {
14+ await _sendToSpotlight (envelope);
15+ return _transport.send (envelope);
16+ }
17+
18+ Future <void > _sendToSpotlight (SentryEnvelope envelope) async {
19+ final Uri spotlightUri = Uri .parse (_options.spotlightUrl);
20+ final StreamedRequest spotlightRequest =
21+ StreamedRequest ('POST' , spotlightUri);
22+
23+ try {
24+ await _options.httpClient.send (spotlightRequest);
25+ } catch (e) {
26+ // Handle any exceptions.
27+ }
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments