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 <noreply@anthropic.com>
This commit is contained in:
@@ -67,10 +67,12 @@ final class AnalyticsManager {
|
|||||||
// enabling accurate unique user counts without requiring identify() calls
|
// enabling accurate unique user counts without requiring identify() calls
|
||||||
config.personProfiles = .always
|
config.personProfiles = .always
|
||||||
|
|
||||||
// Auto-capture
|
// Auto-capture — disabled for SwiftUI (PostHog docs recommend manual tracking)
|
||||||
config.captureElementInteractions = true
|
// captureElementInteractions: UIKit-only, generates noisy $autocapture events
|
||||||
|
// captureScreenViews: produces meaningless SwiftUI internal names, duplicates manual trackScreen()
|
||||||
|
config.captureElementInteractions = false
|
||||||
config.captureApplicationLifecycleEvents = true
|
config.captureApplicationLifecycleEvents = true
|
||||||
config.captureScreenViews = true
|
config.captureScreenViews = false
|
||||||
|
|
||||||
// Session replay
|
// Session replay
|
||||||
config.sessionReplay = sessionReplayEnabled
|
config.sessionReplay = sessionReplayEnabled
|
||||||
@@ -85,8 +87,7 @@ final class AnalyticsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
config.debug = true
|
config.optOut = true // Prevent debug/test data from polluting production analytics
|
||||||
config.flushAt = 1
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PostHogSDK.shared.setup(config)
|
PostHogSDK.shared.setup(config)
|
||||||
|
|||||||
Reference in New Issue
Block a user