TelemetryDeck Swift Client Reference
The TelemetryDeck Swift Client is a Swift Package to include in your app
Include the Swift Client in your Xcode Project
See the Swift Guide on how to set up your app to use the TelemetryDeck Swift Client.
Initialization
Init the TelemetryDeck at app startup, so it knows your App ID (you can retrieve the App ID in the TelemetryDeck Viewer app, under App Settings)
let config = TelemetryDeck.Config(appID: "<YOUR-APP-ID>")
TelemetryDeck.initialize(config: config)For example, if you’re building a scene based app, in the init() function for your App:
import SwiftUI
import TelemetryDeck
@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 config = TelemetryDeck.Config(appID: "<YOUR-APP-ID>")
TelemetryDeck.initialize(config: config)
}
}Sending Signals
Once you’ve included the TelemetryDeck Swift Client, send signals like so:
TelemetryDeck.signal"appLaunchedRegularly")TelemetryDeck will create a user identifier for your 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)
let email = MyConfiguration.User.Email
TelemetryDeck.signal"userLoggedIn", customUserID: email)Payload Data
You can also send additional parameters with each signal:
TelemetryDeck.signal("databaseUpdated", parameters: ["numberOfDatabaseEntries": "3831"])TelemetryDeck will automatically send base parameters with these keys:
TelemetryDeck.AppInfo.buildNumberTelemetryDeck.AppInfo.dartVersionTelemetryDeck.AppInfo.versionTelemetryDeck.AppInfo.versionAndBuildNumberTelemetryDeck.Device.architectureTelemetryDeck.Device.brandTelemetryDeck.Device.modelNameTelemetryDeck.Device.operatingSystemTelemetryDeck.Device.orientationTelemetryDeck.Device.platformTelemetryDeck.Device.screenResolutionWidthTelemetryDeck.Device.screenResolutionHeightTelemetryDeck.Device.systemMajorVersionTelemetryDeck.Device.systemMajorMinorVersionTelemetryDeck.Device.systemVersionTelemetryDeck.Device.timeZoneTelemetryDeck.RunContext.extensionIdentifierTelemetryDeck.RunContext.isAppStoreTelemetryDeck.RunContext.isDebugTelemetryDeck.RunContext.isSimulatorTelemetryDeck.RunContext.isTestFlightTelemetryDeck.RunContext.languageTelemetryDeck.RunContext.localeTelemetryDeck.RunContext.targetEnvironmentTelemetryDeck.SDK.nameTelemetryDeck.SDK.nameAndVersionTelemetryDeck.SDK.versionTelemetryDeck.UserPreference.regionTelemetryDeck.UserPreference.language
Debug Mode
TelemetryDeck will not send any signals if you are in DEBUG Mode. You can override this by setting configuration.telemetryAllowDebugBuilds = true on your TelemetryDeck.Configuration instance.