Skip to content
Open
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
61 changes: 58 additions & 3 deletions docs/platforms/apple/common/configuration/app-hangs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Because the app hang detection integration uses SentryCrashIntegration to captur

You can filter and modify app hang events in `beforeSend` by checking the event exception type:


```swift {tabTitle:Swift}
import Sentry

Expand Down Expand Up @@ -60,8 +59,21 @@ SentrySDK.start { options in
}];
```

Starting with version 8.0.0, this feature has been enabled by default. To disable it:
```objc {tabTitle:Objective-C (SentryObjC)}
#import <SentryObjC/SentryObjC.h>

[SentryObjCSDK startWithConfigureOptions:^(SentryObjCOptions *options) {
options.dsn = @"___PUBLIC_DSN___";
options.beforeSend = ^SentryObjCEvent * _Nullable(SentryObjCEvent * _Nonnull event) {
if (event.exceptions.count == 1 && [event.exceptions.firstObject.type isEqualToString:@"App Hanging"]) {
// modify event here or return nil to discard the event
}
return event;
}
}];
```

Starting with version 8.0.0, this feature has been enabled by default. To disable it:

```swift {tabTitle:Swift}
import Sentry
Expand All @@ -79,12 +91,19 @@ SentrySDK.start { options in
options.dsn = @"___PUBLIC_DSN___";
options.enableAppHangTracking = NO;
}];
```

```objc {tabTitle:Objective-C (SentryObjC)}
#import <SentryObjC/SentryObjC.h>

[SentryObjCSDK startWithConfigureOptions:^(SentryObjCOptions *options) {
options.dsn = @"___PUBLIC_DSN___";
options.enableAppHangTracking = NO;
}];
```

You can change the timeout by changing the `appHangTimeoutInterval` option:


```swift {tabTitle:Swift}
import Sentry

Expand All @@ -101,7 +120,15 @@ SentrySDK.start { options in
options.dsn = @"___PUBLIC_DSN___";
options.appHangTimeoutInterval = 1;
}];
```

```objc {tabTitle:Objective-C (SentryObjC)}
#import <SentryObjC/SentryObjC.h>

[SentryObjCSDK startWithConfigureOptions:^(SentryObjCOptions *options) {
options.dsn = @"___PUBLIC_DSN___";
options.appHangTimeoutInterval = 1;
}];
```

### Pause and Resume App Hang Tracking
Expand Down Expand Up @@ -129,7 +156,17 @@ SentrySDK.resumeAppHangTracking()
// and you don't want the Cocoa SDK to report it.

[SentrySDK resumeAppHangTracking];
```

```objc {tabTitle:Objective-C (SentryObjC)}
#import <SentryObjC/SentryObjC.h>

[SentryObjCSDK pauseAppHangTracking];

// Do something that might cause the app to hang,
// and you don't want the Cocoa SDK to report it.

[SentryObjCSDK resumeAppHangTracking];
```

### App Hangs V2
Expand Down Expand Up @@ -160,6 +197,15 @@ SentrySDK.start { options in
}];
```

```objc {tabTitle:Objective-C (SentryObjC)}
#import <SentryObjC/SentryObjC.h>

[SentryObjCSDK startWithConfigureOptions:^(SentryObjCOptions *options) {
options.dsn = @"___PUBLIC_DSN___";
options.enableAppHangTrackingV2 = YES; // Only available in 8.50.0–8.x
}];
```

#### Fatal App Hangs

Starting with version 8.50.0, the SDK automatically detects and reports fatal app hangs. If the user or the [system watchdog](https://developer.apple.com/documentation/xcode/addressing-watchdog-terminations) terminates your app during an app hang, the SDK reports it as a fatal app hang on the next startup.
Expand Down Expand Up @@ -188,6 +234,15 @@ SentrySDK.start { options in
}];
```

```objc {tabTitle:Objective-C (SentryObjC)}
#import <SentryObjC/SentryObjC.h>

[SentryObjCSDK startWithConfigureOptions:^(SentryObjCOptions *options) {
options.dsn = @"___PUBLIC_DSN___";
options.enableReportNonFullyBlockingAppHangs = NO;
}];
```

## App Hang Rate

<Alert level="info">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ SentrySDK.start { options in
}];
```

```objc {tabTitle:Objective-C (SentryObjC)}
#import <SentryObjC/SentryObjC.h>

[SentryObjCSDK startWithConfigureOptions:^(SentryObjCOptions *options) {
options.dsn = @"___PUBLIC_DSN___";
options.enableGraphQLOperationTracking = YES;
}];
```

## How It Works

The SDK automatically detects GraphQL requests by checking:
Expand Down
55 changes: 50 additions & 5 deletions docs/platforms/apple/common/configuration/http-client-errors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ description: "This feature, once enabled, automatically captures HTTP client err

Once enabled, this feature automatically captures HTTP client errors, like bad response codes, as error events and reports them to Sentry. The error event will contain the `request` and `response` data, such as `url`, `status_code`, and so on. Depending on your HTTP request setup, it can happen that the stacktrace of these events doesn't pinpoint the exact location of the HTTP request in your code. If that's the case, you can look at the HTTP request info of the issue, which contains things like URL and HTTP headers.


Since 8.0.0, this feature has been enabled by default. To disable it:


```swift {tabTitle:Swift}
import Sentry

Expand All @@ -28,8 +26,16 @@ SentrySDK.start { options in
}];
```

By default, only HTTP client errors with a response code between `500` and `599` are captured as error events, but you can change this behavior by setting the `failedRequestStatusCodes` option:
```objc {tabTitle:Objective-C (SentryObjC)}
#import <SentryObjC/SentryObjC.h>

[SentryObjCSDK startWithConfigureOptions:^(SentryObjCOptions *options) {
options.dsn = @"___PUBLIC_DSN___";
options.enableCaptureFailedRequests = NO;
}];
```

By default, only HTTP client errors with a response code between `500` and `599` are captured as error events, but you can change this behavior by setting the `failedRequestStatusCodes` option:

```swift {tabTitle:Swift}
import Sentry
Expand All @@ -52,8 +58,18 @@ SentrySDK.start { options in
}];
```

HTTP client errors from every target (`.*` regular expression) are automatically captured, but you can change this behavior by setting the `failedRequestTargets` option with either a regular expression or a plain `String`. A plain string must contain at least one of the items from the list. Plain strings don't have to be full matches, meaning the URL of a request is matched when it contains a string provided through the option:
```objc {tabTitle:Objective-C (SentryObjC)}
#import <SentryObjC/SentryObjC.h>

[SentryObjCSDK startWithConfigureOptions:^(SentryObjCOptions *options) {
options.dsn = @"___PUBLIC_DSN___";
SentryObjCHttpStatusCodeRange *httpStatusCodeRange =
[[SentryObjCHttpStatusCodeRange alloc] initWithMin:400 max:599];
options.failedRequestStatusCodes = @[ httpStatusCodeRange ];
}];
```

HTTP client errors from every target (`.*` regular expression) are automatically captured, but you can change this behavior by setting the `failedRequestTargets` option with either a regular expression or a plain `String`. A plain string must contain at least one of the items from the list. Plain strings don't have to be full matches, meaning the URL of a request is matched when it contains a string provided through the option:

```swift {tabTitle:Swift}
import Sentry
Expand All @@ -73,6 +89,15 @@ SentrySDK.start { options in
}];
```

```objc {tabTitle:Objective-C (SentryObjC)}
#import <SentryObjC/SentryObjC.h>

[SentryObjCSDK startWithConfigureOptions:^(SentryObjCOptions *options) {
options.dsn = @"___PUBLIC_DSN___";
options.failedRequestTargets = @[ @"www.example.com" ];
}];
```

### GraphQL Operation Tracking

When the <PlatformLink to="/configuration/options/#enableGraphQLOperationTracking">`enableGraphQLOperationTracking`</PlatformLink> option is enabled (disabled by default), the SDK extracts the GraphQL operation name from HTTP requests that have `Content-Type: application/json` and contain a JSON body with an `operationName` field. The operation name is then included in the error event's context as `graphql.operation_name`, making it easier to identify which GraphQL operation failed. Learn more in the <PlatformLink to="/configuration/graphql-operation-tracking/">GraphQL Operation Tracking</PlatformLink> documentation.
Expand All @@ -95,6 +120,15 @@ SentrySDK.start { options in
}];
```

```objc {tabTitle:Objective-C (SentryObjC)}
#import <SentryObjC/SentryObjC.h>

[SentryObjCSDK startWithConfigureOptions:^(SentryObjCOptions *options) {
options.dsn = @"___PUBLIC_DSN___";
options.enableGraphQLOperationTracking = YES;
}];
```

When enabled, GraphQL operation names are also added to HTTP breadcrumbs as `graphql_operation_name` (when network breadcrumbs are enabled).

Error events may contain PII data, such as `Headers` and `Cookies`. Sentry already does data scrubbing by default, but you can scrub any data before it is sent. Learn more in [Scrubbing Sensitive Data](/platforms/apple/guides/ios/data-management/sensitive-data/).
Expand All @@ -105,7 +139,6 @@ These events are searchable and you can set alerts on them if you use the `http.

The captured error event can be customized or dropped with a `beforeSend`:


```swift {tabTitle:Swift}
import Sentry

Expand All @@ -129,3 +162,15 @@ SentrySDK.start { options in
}
}];
```

```objc {tabTitle:Objective-C (SentryObjC)}
#import <SentryObjC/SentryObjC.h>

[SentryObjCSDK startWithConfigureOptions:^(SentryObjCOptions *options) {
options.dsn = @"___PUBLIC_DSN___";
options.beforeSend = ^SentryObjCEvent * _Nullable(SentryObjCEvent * _Nonnull event) {
// modify event here or return nil to discard the event
return event;
}
}];
```
20 changes: 19 additions & 1 deletion docs/platforms/apple/common/configuration/metric-kit.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ You can identify MetricKit events by looking at the `mx_hang_diagnostic`, `mx_cp

Enable this feature by setting the `enableMetricKit` option to `true`:


```swift {tabTitle:Swift}
import Sentry

Expand All @@ -34,6 +33,15 @@ SentrySDK.start { options in
}];
```

```objc {tabTitle:Objective-C (SentryObjC)}
#import <SentryObjC/SentryObjC.h>

[SentryObjCSDK startWithConfigureOptions:^(SentryObjCOptions *options) {
options.dsn = @"___PUBLIC_DSN___";
options.enableMetricKit = YES;
}];
```

You can enable `enableMetricKitRawPayload` to view the raw MetricKit diagnostic payload in JSON format as an attachment on the converted event in Sentry. This feature is available on Cocoa 8.29.0 and up.

```swift {tabTitle:Swift}
Expand All @@ -55,3 +63,13 @@ SentrySDK.start { options in
options.enableMetricKitRawPayload = YES;
}];
```

```objc {tabTitle:Objective-C (SentryObjC)}
#import <SentryObjC/SentryObjC.h>

[SentryObjCSDK startWithConfigureOptions:^(SentryObjCOptions *options) {
options.dsn = @"___PUBLIC_DSN___";
options.enableMetricKit = YES;
options.enableMetricKitRawPayload = YES;
}];
```
Loading
Loading