Skip to content

Commit

Permalink
feat(Android): update getting started and feature pages (#10290)
Browse files Browse the repository at this point in the history
* moves platform-includes into index page

* adds product selector, updates install/verify/next

* updates configure section, moves feature highlight

* adds info about perf/profiling selector

* performance->tracing

* apply changes from PR review
  • Loading branch information
kahest committed Jun 11, 2024
1 parent 80bf7e0 commit 10826db
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 88 deletions.
11 changes: 11 additions & 0 deletions docs/platforms/android/features/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ description: "Learn about the features of Sentry's Android SDK."

Sentry's Android SDK enables automatic reporting of errors and exceptions, and identifies performance issues in your application. The below, is a list of features that are available as part of this SDK.

<Expandable title="Already using Sentry for Android? Here are some recent highlights">

We released <PlatformLink to="/tracing/instrumentation/perf-v2/">Performance-V2</PlatformLink>,
a set of experimental features to give you more details about app start performance and frame delay on a span level.

We released <PlatformLink to="/enhance-errors/source-context">Source Context</PlatformLink>, which shows snippets of code around the location of stack frames.

Let us know if you have feedback through [GitHub issues](https://github.com/getsentry/sentry-java/issues/new?assignees=&labels=Platform%3A+Android%2CType%3A+Bug&template=bug_report_android.yml).

</Expandable>

- Native Development Kit (NDK), the set of tools that that allows you to use C and C++ with Android.
- Events [enriched with device data](/platforms/android/enriching-events/context/).
- Offline caching. (If a device is offline, we'll send a report once the application has been restarted.)
Expand Down
98 changes: 84 additions & 14 deletions docs/platforms/android/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,106 @@ keywords:
- ndk
---

<PlatformContent includePath="getting-started-primer" />
On this page, we get you up and running with Sentry's Android SDK, automatically reporting errors and exceptions in your application.

On this page, we get you up and running with Sentry's SDK.
<Note>

If you don't already have an account and Sentry project established, head over to [sentry.io](https://sentry.io/signup/), then return to this page.

Don't already have an account and Sentry project established? Head over to [sentry.io](https://sentry.io/signup/), then return to this page.
</Note>

## Install

Sentry captures data by using an SDK within your application's runtime.
<OnboardingOptionButtons
options={[
'error-monitoring',
'performance',
'profiling',
]}
/>

<PlatformContent includePath="getting-started-install" />
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.

## Configure
In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](https://docs.sentry.io/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](https://docs.sentry.io/product/explore/profiling/). To enable tracing and/or profiling, click the corresponding checkmarks to get the code snippets.

<PlatformContent includePath="getting-started-config" />
We recommend installing the SDK through our [Sentry Wizard](https://github.com/getsentry/sentry-wizard) by running the following command inside your project directory:

## Verify
```bash
brew install getsentry/tools/sentry-wizard && sentry-wizard -i android
```

This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.
This will patch your project and configure the SDK. You only need to patch the project once, then you can add the patched files to your version control system.
If you prefer, you can also <PlatformLink to="/manual-setup/">set up the SDK manually</PlatformLink> or follow the instructions below to adapt the [configuration](#configure).

<PlatformContent includePath="getting-started-verify" />
<Expandable title="The following tasks will be performed by the Sentry Wizard">

<Note>
The wizard will prompt you to log in to Sentry. It'll then automatically do the following steps for you:

Learn more about manually capturing an error or message in our <PlatformLink to="/usage/">Usage documentation</PlatformLink>.
- 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

</Note>
</Expandable>

## Configure

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

<SignInNote />

```xml {filename:AndroidManifest.xml} {"onboardingOptions": {"performance": "4-5", "profiling": "6-7"}}
<application>
<!-- Required: set your sentry.io project identifier (DSN) -->
<meta-data android:name="io.sentry.dsn" android:value="___PUBLIC_DSN___" />
<!-- 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>
```

## Verify

To view and resolve the recorded error, log into [sentry.io](https://sentry.io) and open your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.
Verify that your app is sending events to Sentry by adding the following snippet, which includes an intentional error. You should see the error reported in Sentry within a few minutes.

```java
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import java.lang.Exception;
import io.sentry.Sentry;

public class MyActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
throw new Exception("This is a test.");
} catch (Exception e) {
Sentry.captureException(e);
}
}
}
```

```kotlin
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import io.sentry.Sentry

class MyActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
try {
throw Exception("This is a test.")
} catch (e: Exception) {
Sentry.captureException(e)
}
}
}
```

## Next Steps

- <PlatformLink to="/features">Learn about the features of Sentry's Android SDK</PlatformLink>
- <PlatformLink to="/enhance-errors">Learn how to enhance stack traces of your Sentry errors</PlatformLink>
- <PlatformLink to="/enriching-events">Enrich events with additional context to make debugging simpler</PlatformLink>
3 changes: 0 additions & 3 deletions platform-includes/getting-started-config/android.mdx

This file was deleted.

21 changes: 0 additions & 21 deletions platform-includes/getting-started-install/android.mdx

This file was deleted.

10 changes: 0 additions & 10 deletions platform-includes/getting-started-primer/android.mdx

This file was deleted.

40 changes: 0 additions & 40 deletions platform-includes/getting-started-verify/android.mdx

This file was deleted.

0 comments on commit 10826db

Please sign in to comment.