TelemetryDeck / SwiftSDK

Swift SDK for TelemetryDeck, a privacy-conscious analytics service for apps and websites.
https://telemetrydeck.com/
Other
149 stars 30 forks source link

Don't crash application if invoked too early #112

Closed Cykelero closed 3 weeks ago

Cykelero commented 11 months ago

When the host application attempts to send a telemetry event, but hasn't yet initialized the TelemetryManager, the manager calls fatalError():

public static var shared: TelemetryManager {
    if let telemetryManager = initializedTelemetryManager {
    /* […] */
    } else {
        fatalError("Please call TelemetryManager.initialize(...) before accessing the shared telemetryManager instance.")
    }

}

As a result, if in a released app, a rarely occurring code path unexpectedly calls TelemetryManager.send() too early, the app will crash. This is not good! A failure to send a telemetry event is not a fatal event, and the SDK should not make this crashing choice on the behalf of the host app. In my opinion, an assertionFailure call would be much more appropriate.

Cykelero commented 3 weeks ago

Fixed by #146.