Skip to content

Commit 2d45f6c

Browse files
romtsnlizokmbrustolingetsantry[bot]
authored
feat(getting-started): Switch from manual setup to sentry-wizard for Android and iOS in getting started (#7767)
Co-authored-by: Liza Mock <[email protected]> Co-authored-by: Dhiogo Brustolin <[email protected]> Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
1 parent 1e3953d commit 2d45f6c

File tree

8 files changed

+243
-61
lines changed

8 files changed

+243
-61
lines changed
Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
Configuration is done via the application `AndroidManifest.xml` Here's an example config which should get you started:
2-
3-
<SignInNote />
4-
5-
```xml {filename:AndroidManifest.xml}
6-
<application>
7-
<!-- Required: set your sentry.io project identifier (DSN) -->
8-
<meta-data android:name="io.sentry.dsn" android:value="___PUBLIC_DSN___" />
9-
10-
<!-- enable automatic breadcrumbs for user interactions (clicks, swipes, scrolls) -->
11-
<meta-data android:name="io.sentry.traces.user-interaction.enable" android:value="true" />
12-
<!-- enable screenshot for crashes -->
13-
<meta-data android:name="io.sentry.attach-screenshot" android:value="true" />
14-
<!-- enable view hierarchy for crashes -->
15-
<meta-data android:name="io.sentry.attach-view-hierarchy" android:value="true" />
16-
17-
<!-- enable the performance API by setting a sample-rate, adjust in production env -->
18-
<meta-data android:name="io.sentry.traces.sample-rate" android:value="1.0" />
19-
<!-- enable profiling when starting transactions, adjust in production env -->
20-
<meta-data android:name="io.sentry.traces.profiling.sample-rate" android:value="1.0" />
21-
</application>
22-
```
23-
24-
Under the hood Sentry uses a `ContentProvider` to initialize the SDK based on the values provided above. This way the SDK can capture important crashes and metrics right from the app start.
25-
261
Additional options can be found <PlatformLink to="/configuration/options/">on our dedicated options page</PlatformLink>.
272

28-
If you want to customize the SDK init behaviour, you can still use the <PlatformLink to="/configuration/manual-init/">Manual Initialization method</PlatformLink>.
3+
Here, you'll also be able to set context data, which includes data about the <PlatformLink to="/enriching-events/identify-user/">user</PlatformLink>, <PlatformLink to="/enriching-events/tags/">tags</PlatformLink>, or even <PlatformLink to="/enriching-events/context/">arbitrary data</PlatformLink>, all of which will be added to every event sent to Sentry.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Additional options can be found <PlatformLink to="/configuration/options/">on our dedicated options page</PlatformLink>.
2+
3+
Here, you'll also be able to set context data, which includes data about the <PlatformLink to="/enriching-events/identify-user/">user</PlatformLink>, <PlatformLink to="/enriching-events/tags/">tags</PlatformLink>, or even <PlatformLink to="/enriching-events/context/">arbitrary data</PlatformLink>, all of which will be added to every event sent to Sentry.
4+
5+
## Experimental Features
6+
7+
> Want to play with something new? Try out our experimental features for [View Hierarchy](/platforms/apple/guides/ios/enriching-events/viewhierarchy/), [Time to Full Display (TTFD)](/platforms/apple/guides/ios/performance/instrumentation/automatic-instrumentation/#time-to-full-display), [MetricKit](/platforms/apple/guides/watchos/configuration/metric-kit/), [Prewarmed App Start Tracing](/platforms/apple/performance/instrumentation/automatic-instrumentation/#prewarmed-app-start-tracing), and [Swift Async Stack Traces](/platforms/apple/guides/ios/#stitch-together-swift-concurrency-stack-traces). Experimental features are still a work-in-progress and may have bugs. We recognize the irony.
8+
>
9+
> Let us know if you have feedback through [GitHub issues](https://github.com/getsentry/sentry-cocoa/issues).
10+
11+
```swift {tabTitle:Swift}
12+
import Sentry
13+
14+
SentrySDK.start { options in
15+
// ...
16+
17+
// Enable all experimental features
18+
options.attachViewHierarchy = true
19+
options.enablePreWarmedAppStartTracing = true
20+
options.enableMetricKit = true
21+
options.enableTimeToFullDisplayTracing = true
22+
options.swiftAsyncStacktraces = true
23+
}
24+
```
25+
26+
```objc {tabTitle:Objective-C}
27+
@import Sentry;
28+
29+
[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
30+
// ...
31+
32+
// Enable all experimental features
33+
options.attachViewHierarchy = YES;
34+
options.enablePreWarmedAppStartTracing = YES;
35+
options.enableMetricKit = YES;
36+
options.enableTimeToFullDisplayTracing = YES;
37+
}];
38+
```
39+
40+
## Use Sentry with SwiftUI
41+
42+
If you want to find out the performance of your Views in a SwiftUI project, [try the SentrySwiftUI library](/platforms/apple/performance/instrumentation/swiftui-instrumentation).
Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
1-
The easiest way to get started is to install the Sentry Android Gradle plugin to your app module's `build.gradle` file.
1+
We recommend installing the SDK through our installation wizard by running the following command inside your project directory:
22

3-
```groovy {filename:app/build.gradle}
4-
buildscript {
5-
repositories {
6-
mavenCentral()
7-
}
8-
}
9-
10-
plugins {
11-
id "com.android.application"
12-
id "io.sentry.android.gradle" version "{{@inject packages.version('sentry.java.android.gradle-plugin', '3.0.0') }}"
13-
}
3+
```bash
4+
brew install getsentry/tools/sentry-wizard && sentry-wizard -i android
145
```
156

16-
```kotlin {filename:app/build.gradle.kts}
17-
buildscript {
18-
repositories {
19-
mavenCentral()
20-
}
21-
}
7+
The wizard will prompt you to log in to Sentry. It'll then automatically do the following steps for you:
228

23-
plugins {
24-
id("com.android.application")
25-
id("io.sentry.android.gradle") version "{{@inject packages.version('sentry.java.android.gradle-plugin', '3.0.0') }}"
26-
}
27-
```
9+
- update your app's `build.gradle` file with the Sentry Gradle plugin and configure it
10+
- update your `AndroidManifest.xml` with the default Sentry configuration
11+
- create `sentry.properties` with an auth token to upload proguard mappings (this file is automatically added to `.gitignore`)
12+
- add an example error to your app's Main Activity to verify your Sentry setup
13+
14+
After the wizard setup is completed, the SDK will automatically capture unhandled exceptions, and monitor performance.
15+
You can also <PlatformLink to="/usage/">manually capture errors</PlatformLink>.
16+
17+
<Note>
18+
19+
If the setup through the wizard doesn't work for you, you can also <PlatformLink to="/manual-setup/">set up the SDK manually</PlatformLink>.
2820

29-
The plugin version `{{@inject packages.version('sentry.java.android.gradle-plugin', '3.0.0') }}` will automatically add the Sentry Android SDK (version `{{@inject packages.version('sentry.java.android', '4.2.0') }}`) to your app.
21+
</Note>
Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
The minimum version for iOS is 9.0.
1+
We recommend installing the SDK through our installation wizard by running the following command inside your project directory:
22

3-
We recommend installing the SDK with CocoaPods, but we also support alternate [installation methods](install/). To integrate Sentry into your Xcode project, specify it in your `Podfile`:
3+
```bash
4+
brew install getsentry/tools/sentry-wizard && sentry-wizard -i ios
5+
```
46

5-
```ruby {filename:Podfile}
6-
platform :ios, '11.0'
7-
use_frameworks! # This is important
7+
The wizard will prompt you to log in to Sentry. It'll then automatically do the following steps for you:
88

9-
target 'YourApp' do
10-
pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '{{@inject packages.version('sentry.cocoa') }}'
11-
end
12-
```
9+
- install the Sentry SDK via Swift Package Manager or Cocoapods
10+
- update your `AppDelegate` or SwiftUI App Initializer with the default Sentry configuration and an example error
11+
- add a new `Upload Debug Symbols` phase to your `xcodebuild` build script
12+
- create `.sentryclirc` with an auth token to upload debug symbols (this file is automatically added to `.gitignore`)
13+
- when you're using Fastlane, it will add a Sentry lane for uploading debug symbols
14+
15+
After the wizard setup is completed, the SDK will automatically capture unhandled exceptions, and monitor performance.
16+
You can also <PlatformLink to="/usage/">manually capture errors</PlatformLink>.
17+
18+
<Note>
19+
20+
If the setup through the wizard doesn't work for you, you can also <PlatformLink to="/manual-setup/">set up the SDK manually</PlatformLink>.
1321

14-
Then run `pod install`.
22+
</Note>

src/platform-includes/getting-started-verify/android.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
<Note>
2+
3+
If you're using [automatic installation via the wizard](/platforms/android/#install), this step isn't necessary.
4+
5+
</Note>
6+
17
```java
28
import androidx.appcompat.app.AppCompatActivity;
39
import android.os.Bundle;
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: Manual Setup
3+
sidebar_order: 1
4+
description: "Learn how to set up the SDK manually."
5+
---
6+
7+
If you can't (or prefer not to) run the [automatic setup](/platforms/android/#install), you can follow the instructions below to configure your application manually.
8+
9+
## Installation
10+
11+
The easiest way to get started is to install the Sentry Android Gradle plugin to your app module's `build.gradle` file.
12+
13+
```groovy {filename:app/build.gradle}
14+
buildscript {
15+
repositories {
16+
mavenCentral()
17+
}
18+
}
19+
20+
plugins {
21+
id "com.android.application"
22+
id "io.sentry.android.gradle" version "{{@inject packages.version('sentry.java.android.gradle-plugin', '3.0.0') }}"
23+
}
24+
```
25+
26+
```kotlin {filename:app/build.gradle.kts}
27+
buildscript {
28+
repositories {
29+
mavenCentral()
30+
}
31+
}
32+
33+
plugins {
34+
id("com.android.application")
35+
id("io.sentry.android.gradle") version "{{@inject packages.version('sentry.java.android.gradle-plugin', '3.0.0') }}"
36+
}
37+
```
38+
39+
Version `{{@inject packages.version('sentry.java.android.gradle-plugin', '3.0.0') }}` of the plugin will automatically add the Sentry Android SDK (version `{{@inject packages.version('sentry.java.android', '4.2.0') }}`) to your app.
40+
41+
## Configuration
42+
43+
Configuration is done via the application `AndroidManifest.xml`. Here's an example config which should get you started:
44+
45+
<SignInNote />
46+
47+
```xml {filename:AndroidManifest.xml}
48+
<application>
49+
<!-- Required: set your sentry.io project identifier (DSN) -->
50+
<meta-data android:name="io.sentry.dsn" android:value="___PUBLIC_DSN___" />
51+
52+
<!-- enable automatic breadcrumbs for user interactions (clicks, swipes, scrolls) -->
53+
<meta-data android:name="io.sentry.traces.user-interaction.enable" android:value="true" />
54+
<!-- enable screenshot for crashes -->
55+
<meta-data android:name="io.sentry.attach-screenshot" android:value="true" />
56+
<!-- enable view hierarchy for crashes -->
57+
<meta-data android:name="io.sentry.attach-view-hierarchy" android:value="true" />
58+
59+
<!-- enable the performance API by setting a sample-rate, adjust in production env -->
60+
<meta-data android:name="io.sentry.traces.sample-rate" android:value="1.0" />
61+
<!-- enable profiling when starting transactions, adjust in production env -->
62+
<meta-data android:name="io.sentry.traces.profiling.sample-rate" android:value="1.0" />
63+
</application>
64+
```
65+
66+
Under the hood, Sentry uses a `ContentProvider` to initialize the SDK based on the values provided above. This way, the SDK can capture important crashes and metrics right from the app start.
67+
68+
Additional options can be found <PlatformLink to="/configuration/options/">on our dedicated options page</PlatformLink>.
69+
70+
If you want to customize the SDK init behaviour, you can still use the <PlatformLink to="/configuration/manual-init/">Manual Initialization method</PlatformLink>.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
title: Manual Setup
3+
sidebar_order: 1
4+
description: "Learn how to set up the SDK manually."
5+
---
6+
7+
If you can't (or prefer not to) run the [automatic setup](/platforms/apple/guides/ios/#install), you can follow the instructions below to configure your application manually.
8+
9+
## Installation
10+
11+
The minimum required version for iOS is 11.0.
12+
13+
We recommend installing the SDK with CocoaPods, but we also support alternate [installation methods](/platforms/apple/guides/ios/install/). To integrate Sentry into your Xcode project, specify it in your `Podfile`:
14+
15+
```ruby {filename:Podfile}
16+
platform :ios, '11.0'
17+
use_frameworks! # This is important
18+
19+
target 'YourApp' do
20+
pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '{{@inject packages.version('sentry.cocoa') }}'
21+
end
22+
```
23+
24+
Then run `pod install`.
25+
26+
## Configuration
27+
28+
We recommend initializing the SDK on the main thread as soon as possible – in your AppDelegate `application:didFinishLaunchingWithOptions` method, for example:
29+
30+
<SignInNote />
31+
32+
```swift {tabTitle:Swift}
33+
import Sentry // Make sure you import Sentry
34+
35+
// ....
36+
37+
func application(_ application: UIApplication,
38+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
39+
40+
SentrySDK.start { options in
41+
options.dsn = "___PUBLIC_DSN___"
42+
options.debug = true // Enabled debug when first installing is always helpful
43+
}
44+
45+
return true
46+
}
47+
```
48+
49+
```objc {tabTitle:Objective-C}
50+
@import Sentry;
51+
52+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
53+
54+
[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
55+
options.dsn = @"___PUBLIC_DSN___";
56+
options.debug = YES; // Enabled debug when first installing is always helpful
57+
58+
// Enable tracing to capture 100% of transactions for performance monitoring.
59+
// Use 'options.tracesSampleRate' to set the sampling rate.
60+
// We recommend setting a sample rate in production.
61+
options.enableTracing = YES;
62+
}];
63+
64+
return YES;
65+
}
66+
```
67+
68+
If you're using SwiftUI and your app doesn't implement an app delegate, initialize the SDK within the [App conformer's initializer](<https://developer.apple.com/documentation/swiftui/app/main()>):
69+
70+
<SignInNote />
71+
72+
```swift
73+
import Sentry
74+
75+
@main
76+
struct SwiftUIApp: App {
77+
init() {
78+
SentrySDK.start { options in
79+
options.dsn = "___PUBLIC_DSN___"
80+
options.debug = true // Enabled debug when first installing is always helpful
81+
82+
// Enable tracing to capture 100% of transactions for performance monitoring.
83+
// Use 'options.tracesSampleRate' to set the sampling rate.
84+
// We recommend setting a sample rate in production.
85+
options.enableTracing = true
86+
}
87+
}
88+
}
89+
```

src/platforms/common/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Sentry captures data by using an SDK within your application’s runtime.
2222

2323
## Configure
2424

25-
<PlatformSection notSupported={["android", "unity", "unreal", "javascript.nextjs"]}>
25+
<PlatformSection notSupported={["android", "unity", "unreal", "javascript.nextjs", "apple.ios"]}>
2626

2727
Configuration should happen as early as possible in your application's lifecycle.
2828

0 commit comments

Comments
 (0)