mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-10 02:08:38 +09:00
Dactyloidae iOS initial commit
This commit is contained in:
parent
daa6179d22
commit
7154a0497e
2123 changed files with 197052 additions and 0 deletions
53
mobile/ios/Sync/BookmarkTelemetryPing.swift
Normal file
53
mobile/ios/Sync/BookmarkTelemetryPing.swift
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
import SwiftyJSON
|
||||
import Shared
|
||||
|
||||
public func makeAdHocBookmarkMergePing(_ bundle: Bundle, clientID: String, attempt: Int32, bufferRows: Int?, valid: [String: Bool], clientCount: Int) -> JSON {
|
||||
let anyFailed = valid.reduce(false, { $0 || $1.1 })
|
||||
|
||||
var out: [String: Any] = [
|
||||
"v": 1,
|
||||
"appV": AppInfo.appVersion,
|
||||
"build": AppInfo.buildNumber,
|
||||
"id": clientID,
|
||||
"attempt": Int(attempt),
|
||||
"success": !anyFailed,
|
||||
"date": Date().description,
|
||||
"clientCount": clientCount,
|
||||
]
|
||||
|
||||
if let bufferRows = bufferRows {
|
||||
out["rows"] = bufferRows
|
||||
}
|
||||
|
||||
if anyFailed {
|
||||
valid.forEach { key, value in
|
||||
out[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
return JSON(out)
|
||||
}
|
||||
|
||||
public func makeAdHocSyncStatusPing(_ bundle: Bundle, clientID: String, statusObject: [String: String]?, engineResults: [String: String]?, resultsFailure: MaybeErrorType?, clientCount: Int) -> JSON {
|
||||
|
||||
let statusObject: Any = statusObject ?? JSON.null
|
||||
let engineResults: Any = engineResults ?? JSON.null
|
||||
let resultsFailure: Any = resultsFailure?.description ?? JSON.null
|
||||
|
||||
let out: [String: Any] = [
|
||||
"v": 1,
|
||||
"appV": AppInfo.appVersion,
|
||||
"build": AppInfo.buildNumber,
|
||||
"id": clientID,
|
||||
"date": Date().description,
|
||||
"clientCount": clientCount,
|
||||
"statusObject": statusObject,
|
||||
"engineResults": engineResults,
|
||||
"resultsFailure": resultsFailure
|
||||
]
|
||||
|
||||
return JSON(out)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue