mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Bump posthog SDK version to 3.2.0 (#2788)
Co-authored-by: Mauro <34335419+Velin92@users.noreply.github.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user