getsentry / getsentry/sentry-dart

Support custom client and transport for the Flutter SDK

Open
#975 5 comments 0 reactions 0 assignees View on GitHub
Dart Errors Improvement
Dominant language
Dart
Stars
873
Forks
299
Avg merge
2d 7h
Merged PRs (30d)
30

Description

Hi, Currently we are using the self-hosting Sentry back-end.

Due to security concerns, our devOps asked me to add some extra properties to request headers.

Im tried implements a `BaseClient` and pass it to the option, but it doesn't work.

```dart
if (kReleaseMode) {
await SentryFlutter.init(
(options) {
options.dsn =
'http://##########dnsLink########/2';
// Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
// We recommend adjusting this value in production.
options.httpClient = MySentryHttpClient;
options.tracesSampleRate = 1.0;
},
appRunner: () => runApp(const MyApp()),
);
} else {
runApp(
const MyApp(),
);
}
```

`my_sentry_http_client.dart`
```dart
class MySentryHttpClient extends BaseClient {
final Client _httpClient = Client();

MySentryHttpClient();

@override
Future send(BaseRequest request) {
var defaultHeaders = {
'Content-Type': 'application/json; charset=UTF-8',
"Extra-Property": "tokenABC",
};
request.headers.addAll(defaultHeaders);
return _httpClient.send(request);
}
}
```

Sorry for my broken english and thank you for everything....

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.