Skip to content

Commit

Permalink
Add missing SDK integrations (#1145)
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto authored Nov 18, 2022
1 parent 6d7a391 commit 134c9f8
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 7 deletions.
6 changes: 5 additions & 1 deletion dart/lib/src/http_client/failed_request_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ class FailedRequestClient extends BaseClient {
Client? client,
Hub? hub,
}) : _hub = hub ?? HubAdapter(),
_client = client ?? Client();
_client = client ?? Client() {
if (captureFailedRequests) {
_hub.options.sdk.addIntegration('HTTPClientError');
}
}

final Client _client;
final Hub _hub;
Expand Down
1 change: 1 addition & 0 deletions dart/lib/src/http_client/sentry_http_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class SentryHttpClient extends BaseClient {

if (networkTracing) {
innerClient = TracingClient(client: innerClient, hub: _hub);
_hub.options.sdk.addIntegration('HTTPNetworkTracing');
}

// The ordering here matters.
Expand Down
5 changes: 4 additions & 1 deletion dart/lib/src/protocol/sdk_version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ class SdkVersion {
_packages.add(package);
}

// Adds an integration
// Adds an integration if not already added
void addIntegration(String integration) {
if (_integrations.contains(integration)) {
return;
}
_integrations.add(integration);
}

Expand Down
2 changes: 2 additions & 0 deletions dio/lib/src/sentry_dio_client_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class SentryDioClientAdapter extends HttpClientAdapter {

if (networkTracing) {
innerClient = TracingClientAdapter(client: innerClient, hub: _hub);
// ignore: invalid_use_of_internal_member
_hub.options.sdk.addIntegration('DioNetworkTracing');
}

// The ordering here matters.
Expand Down
2 changes: 2 additions & 0 deletions dio/lib/src/sentry_dio_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ extension SentryDioExtension on Dio {
// Add FailedRequestInterceptor at index 0, so it's the first interceptor.
// This ensures that it is called and not skipped by any previous interceptor.
interceptors.insert(0, FailedRequestInterceptor());
// ignore: invalid_use_of_internal_member
hub.options.sdk.addIntegration('DioHTTPClientError');
}

// intercept http requests
Expand Down
4 changes: 1 addition & 3 deletions flutter/lib/src/integrations/load_contexts_integration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ class _LoadContextsIntegrationEventProcessor extends EventProcessor {
final sdk = event.sdk ?? _options.sdk;

for (final integration in integrations) {
if (!sdk.integrations.contains(integration)) {
sdk.addIntegration(integration);
}
sdk.addIntegration(integration);
}

event = event.copyWith(sdk: sdk);
Expand Down
7 changes: 6 additions & 1 deletion flutter/lib/src/navigation/sentry_navigator_observer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
_setRouteNameAsTransaction = setRouteNameAsTransaction,
_routeNameExtractor = routeNameExtractor,
_additionalInfoProvider = additionalInfoProvider,
_native = SentryNative();
_native = SentryNative() {
if (enableAutoTransactions) {
// ignore: invalid_use_of_internal_member
_hub.options.sdk.addIntegration('UINavigationTracing');
}
}

final Hub _hub;
final bool _enableAutoTransactions;
Expand Down
9 changes: 8 additions & 1 deletion flutter/lib/src/sentry_asset_bundle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ class SentryAssetBundle implements AssetBundle {
bool enableStructuredDataTracing = false,
}) : _hub = hub ?? HubAdapter(),
_bundle = bundle ?? rootBundle,
_enableStructuredDataTracing = enableStructuredDataTracing;
_enableStructuredDataTracing = enableStructuredDataTracing {
// ignore: invalid_use_of_internal_member
_hub.options.sdk.addIntegration('AssetBundleTracing');
if (_enableStructuredDataTracing) {
// ignore: invalid_use_of_internal_member
_hub.options.sdk.addIntegration('StructuredDataTracing');
}
}

final Hub _hub;
final AssetBundle _bundle;
Expand Down

0 comments on commit 134c9f8

Please sign in to comment.