From 7ac3729a72a5622ceba5053f5390ab55e7698a13 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Fri, 12 Jul 2024 15:18:18 +0800 Subject: [PATCH] Make sure posthog runs on main thread --- .../Sources/Services/Authentication/GoogleAuth.swift | 1 + .../Sources/Services/DataService/Queries/ViewerFetcher.swift | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apple/OmnivoreKit/Sources/Services/Authentication/GoogleAuth.swift b/apple/OmnivoreKit/Sources/Services/Authentication/GoogleAuth.swift index 89324e140..651e5d66e 100644 --- a/apple/OmnivoreKit/Sources/Services/Authentication/GoogleAuth.swift +++ b/apple/OmnivoreKit/Sources/Services/Authentication/GoogleAuth.swift @@ -10,6 +10,7 @@ public enum GoogleAuthResponse { } extension Authenticator { + @MainActor public func handleGoogleAuth(presentingVC: PlatformViewController?) async -> GoogleAuthResponse { let idToken = await withCheckedContinuation { continuation in googleSignIn(presenting: presentingVC) { continuation.resume(returning: $0) } diff --git a/apple/OmnivoreKit/Sources/Services/DataService/Queries/ViewerFetcher.swift b/apple/OmnivoreKit/Sources/Services/DataService/Queries/ViewerFetcher.swift index c386b991d..38223fe41 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/Queries/ViewerFetcher.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/Queries/ViewerFetcher.swift @@ -82,7 +82,6 @@ public struct ViewerInternal { do { try context.save() - EventTracker.registerUser(userID: userID) logger.debug("Viewer saved succesfully") } catch { context.rollback() @@ -90,5 +89,8 @@ public struct ViewerInternal { throw error } } + DispatchQueue.main.async { + EventTracker.registerUser(userID: userID) + } } }