Skip to content

Commit

Permalink
feat: success and error callback sending stats
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-peruzzo committed Sep 9, 2022
1 parent 307bce3 commit 4cc76da
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ios/Plugin/CapacitorUpdater.swift
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,16 @@ extension CustomError: LocalizedError {
"plugin_version": self.pluginVersion,
"app_id": self.appId
]

DispatchQueue.global(qos: .background).async {
let _ = AF.request(self.statsUrl, method: .post,parameters: parameters, encoder: JSONParameterEncoder.default)
print("\(self.TAG) Stats send for \(action), version \(versionName)")
let request = AF.request(self.statsUrl, method: .post,parameters: parameters, encoder: JSONParameterEncoder.default)
request.responseData { response in
switch response.result {
case .success():
print("\(self.TAG) Stats send for \(action), version \(versionName)")
case .failure(error):
print("\(self.TAG) Error sending stats: ", error )
}
}
}
}

Expand Down

0 comments on commit 4cc76da

Please sign in to comment.