Skip to content

Commit c107ffb

Browse files
committed
update
1 parent 3cc09ec commit c107ffb

File tree

12 files changed

+58
-17
lines changed

12 files changed

+58
-17
lines changed

dart/lib/src/sentry_client.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ class SentryClient {
6363
final rateLimiter = RateLimiter(options);
6464
options.transport = HttpTransport(options, rateLimiter);
6565
}
66-
if (options.spotlight.enabled) {
66+
// TODO: Web might change soon to use the JS SDK so we can remove it here later on
67+
final enableSpotlight = (options.spotlight.enabled &&
68+
(options.platformChecker.isWeb ||
69+
options.platformChecker.platform.isLinux ||
70+
options.platformChecker.platform.isWindows));
71+
if (enableSpotlight) {
6772
options.transport = SpotlightHttpTransport(options, options.transport);
6873
}
6974
return SentryClient._(options);

dart/lib/src/spotlight.dart

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,7 @@ class Spotlight {
88
/// The Spotlight Sidecar URL.
99
/// Defaults to http://10.0.2.2:8969/stream due to Emulator on Android.
1010
/// Otherwise defaults to http://localhost:8969/stream.
11-
String url;
11+
String? url;
1212

13-
Spotlight({required this.enabled, String? url})
14-
: url = url ?? _defaultSpotlightUrl();
15-
}
16-
17-
String _defaultSpotlightUrl() {
18-
return (PlatformChecker().platform.isAndroid
19-
? 'http://10.0.2.2:8969/stream'
20-
: 'http://localhost:8969/stream');
13+
Spotlight({required this.enabled, this.url});
2114
}

dart/lib/src/transport/spotlight_http_transport.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import '../http_client/client_provider.dart'
88
if (dart.library.io) '../http_client/io_client_provider.dart';
99

1010
/// Spotlight HTTP transport decorator that sends Sentry envelopes to both Sentry and Spotlight.
11+
/// This will be used on platforms that do not have native SDK support.
12+
/// Platforms with native SDK support will configure spotlight directly in the native SDK options.
1113
class SpotlightHttpTransport extends Transport {
1214
final SentryOptions _options;
1315
final Transport _transport;
@@ -21,8 +23,8 @@ class SpotlightHttpTransport extends Transport {
2123
}
2224

2325
SpotlightHttpTransport._(this._options, this._transport)
24-
: _requestHandler = HttpTransportRequestHandler(
25-
_options, Uri.parse(_options.spotlight.url));
26+
: _requestHandler = HttpTransportRequestHandler(_options,
27+
Uri.parse(_options.spotlight.url ?? _defaultSpotlightUrl()));
2628

2729
@override
2830
Future<SentryId?> send(SentryEnvelope envelope) async {
@@ -48,3 +50,7 @@ class SpotlightHttpTransport extends Transport {
4850
target: 'Spotlight');
4951
}
5052
}
53+
54+
String _defaultSpotlightUrl() {
55+
return 'http://localhost:8969/stream';
56+
}

flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutter.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ class SentryFlutter(
8181
data.getIfNotNull<String>("proguardUuid") {
8282
options.proguardUuid = it
8383
}
84+
data.getIfNotNull<Boolean>("enableSpotlight") {
85+
options.isEnableSpotlight = it
86+
}
87+
data.getIfNotNull<String>("spotlightUrl") {
88+
options.spotlightConnectionUrl = it
89+
}
8490

8591
val nativeCrashHandling = (data["enableNativeCrashHandling"] as? Boolean) ?: true
8692
// nativeCrashHandling has priority over anrEnabled
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## This file must *NOT* be checked into Version Control Systems,
2+
# as it contains information specific to your local configuration.
3+
#
4+
# Location of the SDK. This is only used by Gradle.
5+
# For customization when using a Version Control System, please read the
6+
# header note.
7+
#Tue Sep 10 17:20:30 CEST 2024
8+
sdk.dir=/Users/giancarlobuenaflor/Library/Android/sdk

flutter/example/android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
android:allowBackup="false"
99
android:label="sentry_flutter_example"
1010
android:icon="@mipmap/ic_launcher"
11-
android:extractNativeLibs="true">
11+
android:extractNativeLibs="true"
12+
android:networkSecurityConfig="@xml/network">
1213
<activity
1314
android:name=".MainActivity"
1415
android:launchMode="singleTop"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<network-security-config>
3+
<domain-config cleartextTrafficPermitted="true">
4+
<!-- Allow cleartext traffic from the emulator to the host machine -->
5+
<!-- See https://developer.android.com/studio/run/emulator-networking for more details -->
6+
<domain includeSubdomains="true">10.0.2.2</domain>
7+
</domain-config>
8+
</network-security-config>

flutter/example/ios/Runner/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import UIKit
22
import Flutter
33
import Sentry
44

5-
@UIApplicationMain
5+
@main
66
@objc class AppDelegate: FlutterAppDelegate {
77
private let _channel = "example.flutter.sentry.io"
88

flutter/example/lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ Future<void> setupSentry(
9090
options.maxResponseBodySize = MaxResponseBodySize.always;
9191
options.navigatorKey = navigatorKey;
9292

93-
options.experimental.replay.sessionSampleRate = 1.0;
94-
options.experimental.replay.onErrorSampleRate = 1.0;
93+
// options.experimental.replay.sessionSampleRate = 1.0;
94+
// options.experimental.replay.onErrorSampleRate = 1.0;
9595

9696
_isIntegrationTest = isIntegrationTest;
9797
if (_isIntegrationTest) {

flutter/ios/Classes/SentryFlutter.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ public final class SentryFlutter {
7070
if let appHangTimeoutIntervalMillis = data["appHangTimeoutIntervalMillis"] as? NSNumber {
7171
options.appHangTimeoutInterval = appHangTimeoutIntervalMillis.doubleValue / 1000
7272
}
73+
if let spotlightUrl = data["spotlightUrl"] as? String {
74+
options.spotlightUrl = spotlightUrl
75+
}
76+
if let enableSpotlight = data["enableSpotlight"] as? Bool {
77+
options.enableSpotlight = enableSpotlight
78+
}
7379
if let proxy = data["proxy"] as? [String: Any] {
7480
guard let host = proxy["host"] as? String,
7581
let port = proxy["port"] as? Int,

0 commit comments

Comments
 (0)