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

XCPreviewAgent crashed due to fatalError in TelemetryClient.swift at line 160 #73

Closed Jeehut closed 1 year ago

Jeehut commented 1 year ago

When working on my macOS application, which has some TelemetryDeck analytics events being sent on the TCA reducer layer, I received this error while trying to edit a SwiftUI view and tried to see the previews. Unfortunately, previews seem not to work due to TelemetryManage.initialize(...) not being called.

Given how common SwiftUI is and will become in the future, I think there should be a built-in solution that prevents this from happening. My SwiftUI previews are already all in an if DEBUG, so if this error didn't happen on debug builds for example, this would help. Or even better, maybe there's a way to detect when run in a preview, this could be auto-detected and some mocked version could be initialized.

Here's what I see: Screen Shot 2022-08-29 at 19 49 18

Note that my app is modularized using this approach, therefore I don't need to build the top-level App to see the preview of a component (this is by design for improved build performance). This might be why it's not happening in all projects.