Project Setup
AnalyticsKit Setup

AnalyticsKit Setup

Create a PostHog Project

If you haven't already, create a PostHog Account (opens in a new tab)

After this, create a new Project in PostHog.

PostHog New Project

Next, select Product Analytics as the PostHog product.

PostHog Product Selection

Then in the iOS Section, write down the PostHog API Key and the PostHog Host. You will need this later.

PostHog API Keys Copy

Add PostHog to your App

Back in Xcode, select, go to Targets > AnalyticsKit > Config > PostHog-Info and paste the API Key into the value property of the key POSTHOG_API_KEY and the PostHog Host into POSTHOG_HOST.

Xcode Enter API Key

Run the App

Run your app on a real device or a simulator. Switch to the Settings View and back to the DB Example View. Back in PostHog, click on Continue. Disable Autocapture frontend interactions and press on Continue.

PostHog Suggestion to Autocapture

If you see a Payment Plan Selection Screen, select the Free Plan and press Continue (May also say "Skip for now").

In the Sidebar, click on People. You should see a screen similar to the one below. If everything is set up correctly, you should see a User in that list. Click on the User.

PostHog People Screen

In the Events Tab, you will see the Events that you have triggered after opening the App, such as View Changes, Authentication State changes, or others. You can learn more about different event types in the AnalyticsKit/Events.

PostHog Events Screen

Connect Crashlytics (To Detect Crashes, only when AuthKit & DBKit are selected)

Go to the Firebase Console and select your project. Click on Crashlytics in the left sidebar.

Firebase Console Crashlytics

If you've launched your app before, it will say "App Detected, waiting for a crash". Let's give it that.

Open the App (Not through Xcode, but a cold start on a real device), go to the Developer Tab, scroll down to the bottom, and press on Crash App. This will immidiately close the app.

App Crash Button

After a few seconds, re-open the app. You should see the following in-app notification:

App Crash Notif

Now, after a couple of minutes you should see the crash in the Firebase Console.

App Crash Crashlytics Dashboard

⚠️

You may see a warning about a missing dSYM file in the Crashlytics Dashboard. It's okay. It will appear a couple of minutes after the user opens the app after the crash.

Back in PostHog, it will also be displayed like this:

App Crash PostHog Dashboard