Swiftpack.co - Package - AppTelemetry/SwiftClient

TelemetryClient

It's recommended you create an enum of signal types:

enum TelemetrySignalType: String {
    case appLaunchedRegularly
    case appLaunchedFromNotification
    case pizzaModeActivated
}

Init the Telemetry Manager at app startup, so it knows your App ID (you can retrieve the App ID in the Telemetry Viewer app, under App Settings)

let configuration = TelemetryManagerConfiguration(appID: "<YOUR-APP-ID>")
TelemetryManager.initialize(with: configuration)

For example, if you're building a scene based app, in the init() function for your App:

import SwiftUI
import TelemetryClient

@main
struct TelemetryTestApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
    
    init() {
        // Note: Do not add this code to `WindowGroup.onAppear`, which will be called 
        //       *after* your window has been initialized, and might lead to out initialization
        //       occurring too late.
        let configuration = TelemetryManagerConfiguration(appID: "<YOUR-APP-ID>")
        TelemetryManager.initialize(with: configuration)
    }
}

Then send signals like so:

TelemetryManager.send("appOpenedRegularly")

Telemetry Manager will create a user identifier for you user that is specific to app installation and device. If you have a better user identifier available, you can use that instead: (the identifier will be hashed before sending it)

TelemetryManager.send("userLoggedIn", for: "email")

You can also send additional payload data with each signal:

TelemetryManager.send("databaseUpdated", with: ["numberOfDatabaseEntries": "3831"])

Telemetry Manager will automatically send a base payload with these keys:

  • platform
  • systemVersion
  • appVersion
  • buildNumber
  • isSimulator
  • isTestFlight
  • isAppStore

NOTE: Telemetry Manager will not send any signals if you are in DEBUG Mode, or if you are running on a simulator.

Github

link
Stars: 1

Dependencies

Used By

Total: 0

Releases

1.0.6 - 2020-10-12 08:38:39

1.0.5 - 2020-10-07 08:01:08

1.0.4 - 2020-10-06 18:05:07

1.0.3 - 2020-10-06 18:03:39

1.0.1 - 2020-10-06 17:56:19

1.0.0 - 2020-10-06 15:15:20

First Version of Telemetry Swift Client ♥️