From a1340b4deb2fe378edec0d251e1206257335969e Mon Sep 17 00:00:00 2001 From: Trey t Date: Tue, 10 Mar 2026 22:40:27 -0500 Subject: [PATCH] Disable autocapture and debug analytics per PostHog SwiftUI best practices - Disable captureElementInteractions (UIKit-only, duplicates manual events) - Disable captureScreenViews (meaningless SwiftUI names, duplicates trackScreen()) - Opt out entirely in DEBUG builds to prevent test data polluting production Co-Authored-By: Claude Opus 4.6 --- Shared/Analytics.swift | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Shared/Analytics.swift b/Shared/Analytics.swift index 884ef73..822e2ff 100644 --- a/Shared/Analytics.swift +++ b/Shared/Analytics.swift @@ -67,10 +67,12 @@ final class AnalyticsManager { // enabling accurate unique user counts without requiring identify() calls config.personProfiles = .always - // Auto-capture - config.captureElementInteractions = true + // Auto-capture — disabled for SwiftUI (PostHog docs recommend manual tracking) + // captureElementInteractions: UIKit-only, generates noisy $autocapture events + // captureScreenViews: produces meaningless SwiftUI internal names, duplicates manual trackScreen() + config.captureElementInteractions = false config.captureApplicationLifecycleEvents = true - config.captureScreenViews = true + config.captureScreenViews = false // Session replay config.sessionReplay = sessionReplayEnabled @@ -85,8 +87,7 @@ final class AnalyticsManager { } #if DEBUG - config.debug = true - config.flushAt = 1 + config.optOut = true // Prevent debug/test data from polluting production analytics #endif PostHogSDK.shared.setup(config)