Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add enable capture failed requests #585

Merged
merged 5 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Features

- Add option for iOS: enableCaptureFailedRequests. Allowing users to ignore native Http Request errors. ([#585](https://github.com/getsentry/sentry-capacitor/pull/585))

## 0.15.1

### Fixes
Expand Down
1 change: 1 addition & 0 deletions src/nativeOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ export function FilterNativeOptions(options: CapacitorOptions): CapacitorOptions
sessionTrackingIntervalMillis: options.sessionTrackingIntervalMillis,
tracesSampleRate: options.tracesSampleRate,
// tunnel: options.tunnel: Only handled on the JavaScript Layer.
enableCaptureFailedRequests: options.enableCaptureFailedRequests,
};
}
7 changes: 7 additions & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,11 @@ export interface CapacitorOptions
* @deprecated The method will be removed on a major update, instead, use enableWatchdogTerminationTracking for the same result.
* */
enableOutOfMemoryTracking?: boolean;

/**
* When enabled, Sentry will capture failed XHR/Fetch requests. This option also enabled HTTP Errors on iOS.
*
* @default false
*/
enableCaptureFailedRequests?: boolean;
}
1 change: 1 addition & 0 deletions src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function init<T>(
const finalOptions = {
enableAutoSessionTracking: true,
enableWatchdogTerminationTracking: true,
enableCaptureFailedRequests: false,
...passedOptions,
};
if (finalOptions.enabled === false ||
Expand Down
9 changes: 9 additions & 0 deletions test/nativeOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ describe('nativeOptions', () => {
expect(nativeOptions.enableWatchdogTerminationTracking).toBeTruthy();
});

test('enableCaptureFailedRequests is set when defined', async () => {
const nativeOptions = FilterNativeOptions(
{
enableCaptureFailedRequests: true
});
expect(nativeOptions.enableCaptureFailedRequests).toBeTruthy();
});

test('invalid types not included', async () => {
const nativeOptions = FilterNativeOptions(
{
Expand All @@ -52,6 +60,7 @@ describe('nativeOptions', () => {
enableNdkScopeSync: true,
enableOutOfMemoryTracking: true,
enableTracing: true,
enableCaptureFailedRequests: true,
environment: 'Prod',
ignoreErrors: ['test'],
ignoreTransactions: ['test'],
Expand Down
Loading