@@ -81,15 +81,12 @@ final class WatchDependenciesSynchronizer: NSObject, WCSessionDelegate {
8181 let configurationDependencies = Publishers . CombineLatest ( $enablesCrashReports, $account)
8282
8383 let watchDependencies = Publishers . CombineLatest ( requiredDependencies, configurationDependencies)
84- . map { [ weak self ] ( required, configuration) -> WatchDependencies ? in
84+ . map { ( required, configuration) -> WatchDependencies ? in
8585
8686 let ( storeID, storeName, credentials, currencySettings) = required
8787 let ( enablesCrashReports, account) = configuration
8888
89- guard let storeID, let storeName, let credentials else {
90- self ? . analytics. track ( . watchSyncingFailed, withError: SyncError . missingStoreDetailsOrCredentials)
91- return nil
92- }
89+ guard let storeID, let storeName, let credentials else { return nil }
9390
9491 return . init( storeID: storeID,
9592 storeName: storeName,
@@ -107,7 +104,15 @@ final class WatchDependenciesSynchronizer: NSObject, WCSessionDelegate {
107104
108105 // Do not update the context if the session is not active, the watch is not paired or the watch app is not installed.
109106 guard isSessionActive, watchSession. isPaired, watchSession. isWatchAppInstalled else {
110- self ? . analytics. track ( . watchSyncingFailed, withError: SyncError . watchSessionInactiveOrNotPaired)
107+ self ? . analytics. track (
108+ . watchSyncingFailed,
109+ properties: [
110+ " session_active " : isSessionActive,
111+ " session_paired " : watchSession. isPaired,
112+ " watch_app_installed " : watchSession. isWatchAppInstalled
113+ ] ,
114+ error: SyncError . watchSessionInactiveOrNotPaired
115+ )
111116 return
112117 }
113118
@@ -140,11 +145,6 @@ final class WatchDependenciesSynchronizer: NSObject, WCSessionDelegate {
140145 . store ( in: & subscriptions)
141146 }
142147
143- func session( _ session: WCSession , activationDidCompleteWith activationState: WCSessionActivationState , error: Error ? ) {
144- DDLogInfo ( " 🔵 WatchSession activated \( activationState) " )
145- self . isSessionActive = activationState == . activated
146- }
147-
148148 func sessionDidBecomeInactive( _ session: WCSession ) {
149149 // No op
150150 }
@@ -162,7 +162,6 @@ extension WatchDependenciesSynchronizer {
162162 /// This is in order to not duplicate tracks configuration which involve quite a lot of information to be transmitted to the watch.
163163 ///
164164 func session( _ session: WCSession , didReceiveUserInfo userInfo: [ String : Any ] = [ : ] ) {
165-
166165 // The user info could contain a track event. Send it if we found one.
167166 guard let rawEvent = userInfo [ WooConstants . watchTracksKey] as? String ,
168167 let analyticEvent = WooAnalyticsStat ( rawValue: rawEvent) else {
@@ -183,11 +182,14 @@ extension WatchDependenciesSynchronizer {
183182 /// When one is identified we should try to re-sync credentials.
184183 ///
185184 func session( _ session: WCSession , didReceiveMessage message: [ String : Any ] ) {
186- guard message [ WooConstants . watchSyncKey] as? Bool == true else {
185+ if message [ WooConstants . watchSyncKey] as? Bool == true {
186+ syncTrigger. toggle ( )
187+ } else if message [ WooConstants . watchSessionActivatedKey] as? Bool == true {
188+ self . isSessionActive = true
189+ DDLogInfo ( " 🔵 WatchSession activated) " )
190+ } else {
187191 return DDLogError ( " ⛔️ Unsupported sync request message: \( message) " )
188192 }
189-
190- syncTrigger. toggle ( )
191193 }
192194}
193195
0 commit comments