feat: anonymous analytics with PostHog (#3)

This commit is contained in:
Owen Gretzinger
2025-07-13 20:38:18 -04:00
committed by GitHub
parent 73945cba0f
commit 2e57871793
7 changed files with 51 additions and 3 deletions
+17
View File
@@ -7,6 +7,7 @@
import SwiftUI
import Sparkle
import PostHog
@main
struct MeetingnotesApp: App {
@@ -14,6 +15,22 @@ struct MeetingnotesApp: App {
init() {
updaterController = SPUStandardUpdaterController(updaterDelegate: nil, userDriverDelegate: nil)
// Setup PostHog analytics for anonymous tracking
let posthogAPIKey = "phc_Wt8sWUzUF7YPF50aQ0B1qbfA5SJWWR341zmXCaIaIRJ"
let posthogHost = "https://us.i.posthog.com"
let config = PostHogConfig(apiKey: posthogAPIKey, host: posthogHost)
// Only capture anonymous events
config.personProfiles = .never
// Enable lifecycle and screen view autocapture
config.captureApplicationLifecycleEvents = true
config.captureScreenViews = true
PostHogSDK.shared.setup(config)
// Register environment as a super property
#if DEBUG
PostHogSDK.shared.register(["environment": "dev"] )
#else
PostHogSDK.shared.register(["environment": "prod"] )
#endif
}
var body: some Scene {