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
30 changes: 30 additions & 0 deletions context/docs-snapshots/legacy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@ and the legacy variants must keep describing the majors they install.
Refresh a copy only to pick up a fix to the legacy page itself, never from a
page that already describes a v1 major. The v1 variants point at the live pages.

`feature-flags/` holds the two feature flag pages the Android variants read,
taken on 2026-11-04 while they still described posthog-android 3.x. The
`adding-feature-flag-code` page is a group `shared_docs` entry that every other
variant keeps reading live: a variant's own `shared_docs` entry replaces the
group's one with the same file name.

The iOS pages in `feature-flags/`, `error-tracking/` and `logs-installation/`
were taken on 2026-11-05 while they still described posthog-ios 3.x
(CocoaPods, `from: "3.56.0"`, `"3.59.3"` for logs). The iOS flag variants also read the
`adding-feature-flag-code` snapshot, which still has the 3.x
`reloadFeatureFlags` block and the `didReceiveFeatureFlags` fallback. The logs
folder isn't named `logs/` because `.gitignore` ignores that name.

The Android error tracking, logs and upload mappings pages and the Flutter
feature flag, error tracking and logs install pages were taken on 2026-11-06
while they still described posthog-android 3.x (`posthog-android:3.+`, `apiKey`)
and posthog_flutter 5.x (`^5.x`). They reuse the product analytics onboarding
steps that the 4.0 and 6.0 onboarding changes rewrite.

| File | Source |
| --- | --- |
| `python.md` | https://posthog.com/docs/libraries/python.md |
Expand All @@ -26,3 +45,14 @@ page that already describes a v1 major. The v1 variants point at the live pages.
| `flutter.md` | https://posthog.com/docs/libraries/flutter.md |
| `django.md` | https://posthog.com/docs/libraries/django.md |
| `flask.md` | https://posthog.com/docs/libraries/flask.md |
| `feature-flags/android.md` | https://posthog.com/docs/feature-flags/installation/android.md |
| `feature-flags/adding-feature-flag-code.md` | https://posthog.com/docs/feature-flags/adding-feature-flag-code.md |
| `feature-flags/ios.md` | https://posthog.com/docs/feature-flags/installation/ios.md |
| `error-tracking/ios.md` | https://posthog.com/docs/error-tracking/installation/ios.md |
| `logs-installation/ios.md` | https://posthog.com/docs/logs/installation/ios.md |
| `error-tracking/android.md` | https://posthog.com/docs/error-tracking/installation/android.md |
| `logs-installation/android.md` | https://posthog.com/docs/logs/installation/android.md |
| `upload-mappings/android.md` | https://posthog.com/docs/error-tracking/upload-mappings/android.md |
| `feature-flags/flutter.md` | https://posthog.com/docs/feature-flags/installation/flutter.md |
| `error-tracking/flutter.md` | https://posthog.com/docs/error-tracking/installation/flutter.md |
| `logs-installation/flutter.md` | https://posthog.com/docs/logs/installation/flutter.md |
173 changes: 173 additions & 0 deletions context/docs-snapshots/legacy/error-tracking/android.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt

# Android Error Tracking installation

Canonical URL: https://posthog.com/docs/error-tracking/installation/android

> **Cloud region:** This page uses US Cloud hosts. For an EU Cloud project, use `https://eu.i.posthog.com` instead of `https://us.i.posthog.com` (ingestion host), and use `https://eu.posthog.com` instead of `https://app.posthog.com` (app host for links).

## On this page

- [Install with the wizard](#install-with-the-wizard)
- [Install the dependency](#install-the-dependency)
- [Configure PostHog](#configure-posthog)
- [Send events](#send-events)
- [Set up exception autocapture](#set-up-exception-autocapture)
- [Manually capture exceptions](#manually-capture-exceptions)
- [Verify error tracking](#verify-error-tracking)
- [Upload mapping files](#upload-mapping-files)

## Install with the wizard

Run this command in your project directory to add PostHog to your Android project. The wizard detects your framework, installs the SDK, and sets up your first events.

`npx @posthog/wizard`

Or set it up manually by following the rest of this guide.

1. 1

## Install the dependency

Required

Add the PostHog Android SDK to your `build.gradle` dependencies:

build.gradle

```kotlin
dependencies {
implementation("com.posthog:posthog-android:3.+")
}
```

2. 2

## Configure PostHog

Required

Initialize PostHog in your Application class:

SampleApp.kt

```kotlin
class SampleApp : Application() {

companion object {
const val POSTHOG_PROJECT_TOKEN = "<ph_project_token>"
const val POSTHOG_HOST = "https://us.i.posthog.com"
}

override fun onCreate() {
super.onCreate()

// Create a PostHog Config with the given project token and host
val config = PostHogAndroidConfig(
apiKey = POSTHOG_PROJECT_TOKEN,
host = POSTHOG_HOST
)

// Setup PostHog with the given Context and Config
PostHogAndroid.setup(this, config)
}
}
```

3. 3

## Send events

Recommended

Once installed, PostHog will automatically start capturing events. You can also manually send events to test your integration:

Kotlin

```kotlin
import com.posthog.PostHog

PostHog.capture(
event = "button_clicked",
properties = mapOf(
"button_name" to "signup"
)
)
```

4. 4

## Set up exception autocapture

Recommended

**Client-side configuration only**

Support for remote configuration in the [error tracking settings](https://app.posthog.com/settings/project-error-tracking#exception-autocapture) requires SDK version 3.32.0 or higher.

You can autocapture exceptions by setting the `errorTrackingConfig.autoCapture` argument to `true` when initializing the PostHog SDK.

Kotlin

```kotlin
import com.posthog.android.PostHogAndroidConfig
val config = PostHogAndroidConfig(
apiKey = POSTHOG_PROJECT_TOKEN,
host = POSTHOG_HOST
).apply {
...
errorTrackingConfig.autoCapture = true
}
...
```

When enabled, this automatically captures `$exception` events when errors are thrown by wrapping the `Thread.UncaughtExceptionHandler` listener.

**Planned features**

We currently don't support [source code context](https://posthog.com/docs/error-tracking/stack-traces.md) associated with an exception.

These features will be added in a future release.

5. 5

## Manually capture exceptions

Optional

It is also possible to manually capture exceptions using the `captureException` method:

Kotlin

```kotlin
PostHog.captureException(
exception,
properties = additionalProperties
)
```

This is helpful if you've built your own error handling logic or want to capture exceptions that are handled by your application code.

6. ## Verify error tracking

Recommended

*Confirm events are being sent to PostHog*

Before proceeding, let's make sure exception events are being captured and sent to PostHog. You should see events appear in the activity feed.

![Activity feed with events](https://res.cloudinary.com/dmukukwp6/image/upload/SCR_20250729_ouxl_f788dd8cd2.png)

[Check for exceptions in PostHog](https://app.posthog.com/activity/explore)

7. 6

## Upload mapping files

Required

Great, you're capturing exceptions! The next step is to upload ProGuard/R8 mapping files so PostHog can deobfuscate your stack traces.

Let's continue to the next section.

[Upload mapping files](https://posthog.com/docs/error-tracking/upload-mappings/android.md)
Loading
Loading