Bump posthog SDK version to 3.2.0 (#2788)

Co-authored-by: Mauro <34335419+Velin92@users.noreply.github.com>
This commit is contained in:
Valere
2024-05-06 17:07:05 +02:00
committed by GitHub
parent c398338335
commit 176abd5841
10 changed files with 91 additions and 60 deletions
@@ -38,19 +38,23 @@ class PostHogAnalyticsClient: AnalyticsClientProtocol {
/// Not persisted for now, should be set on start.
private var superProperties: AnalyticsEvent.SuperProperties?
var isRunning: Bool { postHog?.enabled ?? false }
var isRunning: Bool { postHog != nil }
func start(analyticsConfiguration: AnalyticsConfiguration) {
// Only start if analytics have been configured in BuildSettings
guard let configuration = PHGPostHogConfiguration.standard(analyticsConfiguration: analyticsConfiguration) else { return }
guard let configuration = PostHogConfig.standard(analyticsConfiguration: analyticsConfiguration) else { return }
if postHog == nil {
postHog = posthogFactory.createPostHog(config: configuration)
if postHog != nil {
// start has been called twice in a row without calling stop()?
// Anyhow it's no-op if it's the case, but log for sanity
MXLog.failure("Posthog should always be nil when it's being started")
}
postHog = posthogFactory.createPostHog(config: configuration)
// Add super property cryptoSDK to the captured events, to allow easy
// filtering of events across different client by using same filter.
superProperties = AnalyticsEvent.SuperProperties(appPlatform: nil, cryptoSDK: .Rust, cryptoSDKVersion: nil)
postHog?.enable()
postHog?.optIn()
}
func reset() {
@@ -59,10 +63,8 @@ class PostHogAnalyticsClient: AnalyticsClientProtocol {
}
func stop() {
postHog?.disable()
// As of PostHog 1.4.4, setting the client to nil here doesn't release
// it. Keep it around to avoid having multiple instances if the user re-enables
postHog?.optOut()
postHog = nil
}
func capture(_ event: AnalyticsEventProtocol) {