Skip to content

feat(getting-started): Switch from manual setup to sentry-wizard for Android and iOS in getting started #7767

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

Merged
merged 34 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
14228cd
feat(getting-started): Switch from manual setup to sentry-wizard for …
romtsn Sep 7, 2023
9d47148
Update src/platforms/apple/guides/ios/manual-setup.mdx
brustolin Sep 7, 2023
e5826b6
Update src/platform-includes/getting-started-config/android.mdx
romtsn Sep 8, 2023
7d229c5
Update src/platform-includes/getting-started-config/apple.ios.mdx
romtsn Sep 8, 2023
eb5533f
Update src/platform-includes/getting-started-config/apple.ios.mdx
romtsn Sep 8, 2023
eeda377
Update src/platform-includes/getting-started-config/apple.ios.mdx
romtsn Sep 8, 2023
2e15b6f
Update src/platform-includes/getting-started-config/apple.ios.mdx
romtsn Sep 8, 2023
2458e90
Update src/platform-includes/getting-started-install/android.mdx
romtsn Sep 8, 2023
8a25318
Update src/platform-includes/getting-started-install/android.mdx
romtsn Sep 8, 2023
19ff53c
Update src/platform-includes/getting-started-install/apple.ios.mdx
romtsn Sep 8, 2023
79bb51f
style(lint): Auto commit lint changes
getsantry[bot] Sep 8, 2023
8358404
style(lint): Auto commit lint changes
getsantry[bot] Sep 8, 2023
b02bd60
Update src/platform-includes/getting-started-install/apple.ios.mdx
romtsn Sep 8, 2023
63b7d1d
style(lint): Auto commit lint changes
getsantry[bot] Sep 8, 2023
c806a36
style(lint): Auto commit lint changes
getsantry[bot] Sep 8, 2023
8a8888c
style(lint): Auto commit lint changes
getsantry[bot] Sep 8, 2023
9a728bf
Update src/platform-includes/getting-started-verify/android.mdx
romtsn Sep 8, 2023
0c84c25
Update src/platforms/android/manual-setup.mdx
romtsn Sep 8, 2023
60298c1
style(lint): Auto commit lint changes
getsantry[bot] Sep 8, 2023
761fb4f
style(lint): Auto commit lint changes
getsantry[bot] Sep 8, 2023
2af592f
Update src/platforms/android/manual-setup.mdx
romtsn Sep 8, 2023
ac9dbe2
style(lint): Auto commit lint changes
getsantry[bot] Sep 8, 2023
54fd4dc
style(lint): Auto commit lint changes
getsantry[bot] Sep 8, 2023
f056fde
style(lint): Auto commit lint changes
getsantry[bot] Sep 8, 2023
87820d8
style(lint): Auto commit lint changes
getsantry[bot] Sep 8, 2023
6619075
style(lint): Auto commit lint changes
getsantry[bot] Sep 8, 2023
543468a
style(lint): Auto commit lint changes
getsantry[bot] Sep 8, 2023
20f9339
Update src/platforms/android/manual-setup.mdx
romtsn Sep 8, 2023
3503c08
Update src/platforms/apple/guides/ios/manual-setup.mdx
romtsn Sep 8, 2023
57063a8
Update src/platforms/apple/guides/ios/manual-setup.mdx
romtsn Sep 8, 2023
2301a72
Update src/platforms/apple/guides/ios/manual-setup.mdx
romtsn Sep 8, 2023
de19756
Update src/platforms/android/manual-setup.mdx
romtsn Sep 8, 2023
4fbff3f
Update src/platforms/apple/guides/ios/manual-setup.mdx
romtsn Sep 8, 2023
789a526
Remove async stacktraces section as it's already under experimental f…
romtsn Sep 8, 2023
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
27 changes: 1 addition & 26 deletions src/platform-includes/getting-started-config/android.mdx
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
Configuration is done via the application `AndroidManifest.xml` Here's an example config which should get you started:

<SignInNote />

```xml {filename:AndroidManifest.xml}
<application>
<!-- Required: set your sentry.io project identifier (DSN) -->
<meta-data android:name="io.sentry.dsn" android:value="___PUBLIC_DSN___" />

<!-- enable automatic breadcrumbs for user interactions (clicks, swipes, scrolls) -->
<meta-data android:name="io.sentry.traces.user-interaction.enable" android:value="true" />
<!-- enable screenshot for crashes -->
<meta-data android:name="io.sentry.attach-screenshot" android:value="true" />
<!-- enable view hierarchy for crashes -->
<meta-data android:name="io.sentry.attach-view-hierarchy" android:value="true" />

<!-- enable the performance API by setting a sample-rate, adjust in production env -->
<meta-data android:name="io.sentry.traces.sample-rate" android:value="1.0" />
<!-- enable profiling when starting transactions, adjust in production env -->
<meta-data android:name="io.sentry.traces.profiling.sample-rate" android:value="1.0" />
</application>
```

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.

Additional options can be found <PlatformLink to="/configuration/options/">on our dedicated options page</PlatformLink>.

If you want to customize the SDK init behaviour, you can still use the <PlatformLink to="/configuration/manual-init/">Manual Initialization method</PlatformLink>.
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.
42 changes: 42 additions & 0 deletions src/platform-includes/getting-started-config/apple.ios.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Additional options can be found <PlatformLink to="/configuration/options/">on our dedicated options page</PlatformLink>.

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.

## Experimental Features

> 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.
>
> Let us know if you have feedback through [GitHub issues](https://github.com/getsentry/sentry-cocoa/issues).

```swift {tabTitle:Swift}
import Sentry

SentrySDK.start { options in
// ...

// Enable all experimental features
options.attachViewHierarchy = true
options.enablePreWarmedAppStartTracing = true
options.enableMetricKit = true
options.enableTimeToFullDisplayTracing = true
options.swiftAsyncStacktraces = true
}
```

```objc {tabTitle:Objective-C}
@import Sentry;

[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
// ...

// Enable all experimental features
options.attachViewHierarchy = YES;
options.enablePreWarmedAppStartTracing = YES;
options.enableMetricKit = YES;
options.enableTimeToFullDisplayTracing = YES;
}];
```

## Use Sentry with SwiftUI

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).
40 changes: 16 additions & 24 deletions src/platform-includes/getting-started-install/android.mdx
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
The easiest way to get started is to install the Sentry Android Gradle plugin to your app module's `build.gradle` file.
We recommend installing the SDK through our installation wizard by running the following command inside your project directory:

```groovy {filename:app/build.gradle}
buildscript {
repositories {
mavenCentral()
}
}

plugins {
id "com.android.application"
id "io.sentry.android.gradle" version "{{@inject packages.version('sentry.java.android.gradle-plugin', '3.0.0') }}"
}
```bash
brew install getsentry/tools/sentry-wizard && sentry-wizard -i android
```

```kotlin {filename:app/build.gradle.kts}
buildscript {
repositories {
mavenCentral()
}
}
The wizard will prompt you to log in to Sentry. It'll then automatically do the following steps for you:

plugins {
id("com.android.application")
id("io.sentry.android.gradle") version "{{@inject packages.version('sentry.java.android.gradle-plugin', '3.0.0') }}"
}
```
- update your app's `build.gradle` file with the Sentry Gradle plugin and configure it
- update your `AndroidManifest.xml` with the default Sentry configuration
- create `sentry.properties` with an auth token to upload proguard mappings (this file is automatically added to `.gitignore`)
- add an example error to your app's Main Activity to verify your Sentry setup

After the wizard setup is completed, the SDK will automatically capture unhandled exceptions, and monitor performance.
You can also <PlatformLink to="/usage/">manually capture errors</PlatformLink>.

<Note>

If the setup through the wizard doesn't work for you, you can also <PlatformLink to="/manual-setup/">set up the SDK manually</PlatformLink>.

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.
</Note>
28 changes: 18 additions & 10 deletions src/platform-includes/getting-started-install/apple.ios.mdx
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
The minimum version for iOS is 9.0.
We recommend installing the SDK through our installation wizard by running the following command inside your project directory:

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`:
```bash
brew install getsentry/tools/sentry-wizard && sentry-wizard -i ios
```

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

target 'YourApp' do
pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '{{@inject packages.version('sentry.cocoa') }}'
end
```
- install the Sentry SDK via Swift Package Manager or Cocoapods
- update your `AppDelegate` or SwiftUI App Initializer with the default Sentry configuration and an example error
- add a new `Upload Debug Symbols` phase to your `xcodebuild` build script
- create `.sentryclirc` with an auth token to upload debug symbols (this file is automatically added to `.gitignore`)
- when you're using Fastlane, it will add a Sentry lane for uploading debug symbols

After the wizard setup is completed, the SDK will automatically capture unhandled exceptions, and monitor performance.
You can also <PlatformLink to="/usage/">manually capture errors</PlatformLink>.

<Note>

If the setup through the wizard doesn't work for you, you can also <PlatformLink to="/manual-setup/">set up the SDK manually</PlatformLink>.

Then run `pod install`.
</Note>
6 changes: 6 additions & 0 deletions src/platform-includes/getting-started-verify/android.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<Note>

If you're using [automatic installation via the wizard](/platforms/android/#install), this step isn't necessary.

</Note>

```java
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
Expand Down
70 changes: 70 additions & 0 deletions src/platforms/android/manual-setup.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
title: Manual Setup
sidebar_order: 1
description: "Learn how to set up the SDK manually."
---

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.

## Installation

The easiest way to get started is to install the Sentry Android Gradle plugin to your app module's `build.gradle` file.

```groovy {filename:app/build.gradle}
buildscript {
repositories {
mavenCentral()
}
}

plugins {
id "com.android.application"
id "io.sentry.android.gradle" version "{{@inject packages.version('sentry.java.android.gradle-plugin', '3.0.0') }}"
}
```

```kotlin {filename:app/build.gradle.kts}
buildscript {
repositories {
mavenCentral()
}
}

plugins {
id("com.android.application")
id("io.sentry.android.gradle") version "{{@inject packages.version('sentry.java.android.gradle-plugin', '3.0.0') }}"
}
```

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.

## Configuration

Configuration is done via the application `AndroidManifest.xml`. Here's an example config which should get you started:

<SignInNote />

```xml {filename:AndroidManifest.xml}
<application>
<!-- Required: set your sentry.io project identifier (DSN) -->
<meta-data android:name="io.sentry.dsn" android:value="___PUBLIC_DSN___" />

<!-- enable automatic breadcrumbs for user interactions (clicks, swipes, scrolls) -->
<meta-data android:name="io.sentry.traces.user-interaction.enable" android:value="true" />
<!-- enable screenshot for crashes -->
<meta-data android:name="io.sentry.attach-screenshot" android:value="true" />
<!-- enable view hierarchy for crashes -->
<meta-data android:name="io.sentry.attach-view-hierarchy" android:value="true" />

<!-- enable the performance API by setting a sample-rate, adjust in production env -->
<meta-data android:name="io.sentry.traces.sample-rate" android:value="1.0" />
<!-- enable profiling when starting transactions, adjust in production env -->
<meta-data android:name="io.sentry.traces.profiling.sample-rate" android:value="1.0" />
</application>
```

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.

Additional options can be found <PlatformLink to="/configuration/options/">on our dedicated options page</PlatformLink>.

If you want to customize the SDK init behaviour, you can still use the <PlatformLink to="/configuration/manual-init/">Manual Initialization method</PlatformLink>.
89 changes: 89 additions & 0 deletions src/platforms/apple/guides/ios/manual-setup.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
title: Manual Setup
sidebar_order: 1
description: "Learn how to set up the SDK manually."
---

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.

## Installation

The minimum required version for iOS is 11.0.

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`:

```ruby {filename:Podfile}
platform :ios, '11.0'
use_frameworks! # This is important

target 'YourApp' do
pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '{{@inject packages.version('sentry.cocoa') }}'
end
```

Then run `pod install`.

## Configuration

We recommend initializing the SDK on the main thread as soon as possible – in your AppDelegate `application:didFinishLaunchingWithOptions` method, for example:

<SignInNote />

```swift {tabTitle:Swift}
import Sentry // Make sure you 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
}

return true
}
```

```objc {tabTitle:Objective-C}
@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

// Enable tracing to capture 100% of transactions for performance monitoring.
// Use 'options.tracesSampleRate' to set the sampling rate.
// We recommend setting a sample rate in production.
options.enableTracing = YES;
}];

return YES;
}
```

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()>):

<SignInNote />

```swift
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

// Enable tracing to capture 100% of transactions for performance monitoring.
// Use 'options.tracesSampleRate' to set the sampling rate.
// We recommend setting a sample rate in production.
options.enableTracing = true
}
}
}
```
2 changes: 1 addition & 1 deletion src/platforms/common/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Sentry captures data by using an SDK within your application’s runtime.

## Configure

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

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

Expand Down