Skip to content

Commit

Permalink
chore(Apple): Show Profiling only on supported platforms' landing pag…
Browse files Browse the repository at this point in the history
…es (#12192)

* fixes duplicate feature descriptions

* fix snippets, show profiling only where supported
  • Loading branch information
kahest authored Dec 19, 2024
1 parent e687544 commit 649dcd9
Showing 1 changed file with 101 additions and 25 deletions.
126 changes: 101 additions & 25 deletions docs/platforms/apple/common/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,34 @@ The support for [visionOS](https://developer.apple.com/visionos/) is currently e

## Features

<PlatformSection notSupported={["apple.tvos", "apple.watchos", "apple.visionos"]}>

In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/).

</PlatformSection>

<PlatformSection notSupported={["apple.ios", "apple.macos"]}>

In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/).

</PlatformSection>

Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.

## Install

<OnboardingOptionButtons
options={[
'error-monitoring',
'performance',
'profiling',
]}
/>
<PlatformSection notSupported={["apple.tvos", "apple.watchos", "apple.visionos"]}>

<OnboardingOptionButtons options={['error-monitoring', 'performance', 'profiling']}/>

</PlatformSection>

<PlatformSection notSupported={["apple.ios", "apple.macos"]}>

<OnboardingOptionButtons options={['error-monitoring', 'performance']}/>

</PlatformSection>


Sentry captures data by using an SDK within your application's runtime. These are platform-specific and allow Sentry to have a deep understanding of how your application works.

Expand Down Expand Up @@ -70,8 +85,9 @@ If you prefer, you can also [set up the SDK manually](/platforms/apple/guides/io

To capture all errors, initialize the SDK as soon as possible, such as in your `AppDelegate` `application:didFinishLaunchingWithOptions` method:

<PlatformSection notSupported={["apple.tvos", "apple.watchos", "apple.visionos"]}>

```swift {tabTitle:Swift} {"onboardingOptions": {"performance": "9-12", "profiling": "13-16"}}
```swift {tabTitle:Swift} {"onboardingOptions": {"performance": "9-12", "profiling": "14-24"}}
import Sentry

func application(_ application: UIApplication,
Expand All @@ -86,22 +102,22 @@ func application(_ application: UIApplication,
options.tracesSampleRate = 1.0
}

// Manually call startProfiler and stopProfiler to profile any code that runs in between.
SentrySDK.startProfiler()
// Manually call startProfiler and stopProfiler to profile any code that runs in between.
SentrySDK.startProfiler()

//
// ...anything here will be profiled...
//
//
// ...anything here will be profiled...
//

// Calls to stopProfiler are optional - if you don't stop the profiler, it will keep profiling
// your application until the process exits, the app goes to the background, or stopProfiling is called.
SentrySDK.stopProfiler()
// Calls to stopProfiler are optional - if you don't stop the profiler, it will keep profiling
// your application until the process exits, the app goes to the background, or stopProfiling is called.
SentrySDK.stopProfiler()

return true
}
```

```objc {tabTitle:Objective-C} {"onboardingOptions": {"performance": "8-11", "profiling": "12-15"}}
```objc {tabTitle:Objective-C} {"onboardingOptions": {"performance": "8-11", "profiling": "13-23"}}
@import Sentry;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
Expand All @@ -115,16 +131,16 @@ func application(_ application: UIApplication,
options.tracesSampleRate = @1.0;
}];

// Manually call startProfiler and stopProfiler to profile any code that runs in between.
[SentrySDK startProfiler];
// Manually call startProfiler and stopProfiler to profile any code that runs in between.
[SentrySDK startProfiler];

//
// ...anything here will be profiled...
//
//
// ...anything here will be profiled...
//

// Calls to stopProfiler are optional - if you don't stop the profiler, it will keep profiling
// your application until the process exits, the app goes to the background, or stopProfiling is called.
[SentrySDK stopProfiler];
// Calls to stopProfiler are optional - if you don't stop the profiler, it will keep profiling
// your application until the process exits, the app goes to the background, or stopProfiling is called.
[SentrySDK stopProfiler];

return YES;
}
Expand All @@ -151,6 +167,66 @@ struct SwiftUIApp: App {
}
}
```
</PlatformSection>

<PlatformSection notSupported={["apple.ios", "apple.macos"]}>

```swift {tabTitle:Swift} {"onboardingOptions": {"performance": "9-12"}}
import Sentry

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

SentrySDK.start { options in
options.dsn = "___PUBLIC_DSN___"
options.debug = true // Enabled debug when first installing is always helpful

// Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
// We recommend adjusting this value in production.
options.tracesSampleRate = 1.0
}

return true
}
```

```objc {tabTitle:Objective-C} {"onboardingOptions": {"performance": "8-11"}}
@import Sentry;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
options.dsn = @"___PUBLIC_DSN___";
options.debug = YES; // Enabled debug when first installing is always helpful

// Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
// We recommend adjusting this value in production.
options.tracesSampleRate = @1.0;
}];

return YES;
}
```

```swift {tabTitle:SwiftUI with App conformer} {"onboardingOptions": {"performance": "9-12"}}
import Sentry

@main
struct SwiftUIApp: App {
init() {
SentrySDK.start { options in
options.dsn = "___PUBLIC_DSN___"
options.debug = true // Enabled debug when first installing is always helpful

// Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
// We recommend adjusting this value in production.
options.tracesSampleRate = 1.0
}
}
}
```

</PlatformSection>

## Verify

Expand Down

0 comments on commit 649dcd9

Please sign in to comment.