Telemetry
public class Telemetry
A class designed for configuring and accessing the Telemetry Store, serving as the primary utility for Telemetry Service.
-
The default id for storing telemetry data in store
Declaration
Swift
public static let defaultTargetID: String
-
Telemtry Store ID
Declaration
Swift
public static let telemetryStorageID: String
-
Returns a shared singleton telemetry object.
Declaration
Swift
public class var shared: Telemetry { get }
-
Returns the store object associated with the telemetry object. It is used to save the data until it is uploaded to a server. Also used by the uploader components to access the data.
Declaration
Swift
public var store: UsageStoring? { get }
-
Configures the telemetry instance with the given UsageStoring.
Declaration
Swift
public func configure(with store: UsageStoring, retainLastStoreData: Bool = true)
Parameters
store
the UsageStoring used to store the Records
retainLastStoreData
if true, data stored in current store will be injected into new store.
-
Returns a TelemetryReporter instance for the given target identifier. If the reporter doesn’t exist a new one will be created automatically. All other calls will return the same reporter instance. Uses
Telemetry.defaultTargetID
by default.Declaration
Swift
public func reporter(for targetID: String = defaultTargetID) -> TelemetryReporter
Parameters
targetID
the target identifier where to reporter will report to
Return Value
TelemetryReporter associated with the given target identifier
-
Registers a custom created TelemetryReporter instance. Custom TelemetryReporters can be created by subclassing the TelemetryReporter class. TelemetryReporters created this way must be registered to Telemetry through this register method, otherwise they can not report to the store. If there was a reporter with this ID that will be replaced with the new instance.
Declaration
Swift
public func register(reporter: TelemetryReporter, for targetID: String = defaultTargetID)
Parameters
reporter
custom created TelemetryReporter
targetID
the target identifier which will be associated with the reporter
-
Unregisters and invalidates a previously registered or created reporter and removes it from Telemetry. After unregistering a reporter it can no longer report to the store and must be re-registered to use again.
Declaration
Swift
public func unregisterReporter(from targetID: String)
Parameters
targetID
the target identifier which identifies the reporter