fix: permanently fix PostHog module emission error
- Change PostHog from exactVersion to revision (tag 3.62.0) in project.yml - Add deep cache clean step before xcodegen in CI workflow - Add ONLY_ACTIVE_ARCH=NO to xcodebuild command - Wrap PostHog usage in #if canImport(PostHog) for graceful degradation - Add Package.resolved, .build/, DerivedData/ to .gitignore - Remove stale SPM caches between CI runs (DerivedData, swiftpm caches, act cache)
This commit is contained in:
@@ -1,30 +1,38 @@
|
||||
import Foundation
|
||||
#if canImport(PostHog)
|
||||
import PostHog
|
||||
#endif
|
||||
|
||||
/// PostHog analytics — mirrors the event taxonomy from the Expo app.
|
||||
final class AnalyticsService: @unchecked Sendable {
|
||||
|
||||
static let shared = AnalyticsService()
|
||||
|
||||
#if canImport(PostHog)
|
||||
private let apiKey: String =
|
||||
Bundle.main.infoDictionary?["POSTHOG_API_KEY"] as? String ?? ""
|
||||
|
||||
private let host = "https://eu.posthog.com"
|
||||
#endif
|
||||
|
||||
private init() {}
|
||||
|
||||
func initialize() {
|
||||
#if canImport(PostHog)
|
||||
guard !apiKey.isEmpty else { return }
|
||||
let config = PostHogConfig(apiKey: apiKey, host: host)
|
||||
config.captureApplicationLifecycleEvents = true
|
||||
config.captureScreenViews = false // manual tracking
|
||||
PostHogSDK.shared.setup(config)
|
||||
#endif
|
||||
}
|
||||
|
||||
// ─── Screens ────────────────────────────────────────────────
|
||||
|
||||
func screen(_ name: String, properties: [String: Any] = [:]) {
|
||||
#if canImport(PostHog)
|
||||
PostHogSDK.shared.screen(name, properties: properties)
|
||||
#endif
|
||||
}
|
||||
|
||||
// ─── Onboarding ─────────────────────────────────────────────
|
||||
@@ -100,6 +108,8 @@ final class AnalyticsService: @unchecked Sendable {
|
||||
// ─── Private ─────────────────────────────────────────────────
|
||||
|
||||
private func capture(_ event: String, properties: [String: Any] = [:]) {
|
||||
#if canImport(PostHog)
|
||||
PostHogSDK.shared.capture(event, properties: properties.isEmpty ? nil : properties)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ packages:
|
||||
from: "5.0.0"
|
||||
PostHog:
|
||||
url: https://github.com/PostHog/posthog-ios
|
||||
exactVersion: "3.62.0"
|
||||
revision: "3.62.0"
|
||||
|
||||
targets:
|
||||
TabataGo:
|
||||
|
||||
Reference in New Issue
Block a user