What problem does it solve?
This skill streamlines adding PostHog analytics to Swift iOS and macOS applications so engineers can track events, identify users, and capture errors without guessing integration patterns or breaking app sandboxing and dependency management.
Core Features & Use Cases
- SDK initialization: Clear guidance to configure PostHogConfig and initialize PostHogSDK in SwiftUI or UIKit app entry points.
- User identification & correlation: Best-practice patterns for calling identify on login, passing distinct IDs between client and backend, and resetting on logout.
- Event capture & error tracking: Examples for capturing key product events and exceptions (e.g., dashboard_viewed, user_logged_in, test_error_triggered) and where to place them.
- Integration details: Advice for adding the posthog-ios Swift Package Manager dependency, using environment variables for POSTHOG_PROJECT_TOKEN and POSTHOG_HOST, and respecting macOS App Sandbox network rules.
- Use case: Instrument a login flow to identify users, track conversion events, and capture errors to correlate frontend behavior with backend events.
Quick Start
Add the PostHog Swift package to your Xcode project, set POSTHOG_PROJECT_TOKEN and POSTHOG_HOST in your Xcode scheme environment variables, and initialize PostHogConfig in your App initializer to begin capturing events and identifying users.