Skip to content

Commit 2ca35c5

Browse files
committed
poc
1 parent 9d7e862 commit 2ca35c5

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

dart/lib/src/sentry_client.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import 'sentry_options.dart';
1616
import 'sentry_stack_trace_factory.dart';
1717
import 'transport/http_transport.dart';
1818
import 'transport/noop_transport.dart';
19+
import 'transport/spotlight_http_transport.dart';
1920
import 'utils/isolate_utils.dart';
2021
import 'version.dart';
2122
import '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

dart/lib/src/sentry_options.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
}

0 commit comments

Comments
 (0)