Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing is enabled checks #196

Merged
merged 3 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Next

- fix: some public APIs such as unregister weren't checking for isEnabled ([#196](https://github.com/PostHog/posthog-ios/pull/196))

## 3.12.1 - 2024-09-12

- recording: missing import for url session extensions ([#194](https://github.com/PostHog/posthog-ios/pull/194))
Expand Down
16 changes: 14 additions & 2 deletions PostHog/PostHogSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ let maxRetryDelay = 30.0

@objc(unregisterProperties:)
public func unregister(_ key: String) {
if !isEnabled() {
return
}

personPropsLock.withLock {
var props = getRegisteredProperties()
props.removeValue(forKey: key)
Expand Down Expand Up @@ -1080,12 +1084,20 @@ let maxRetryDelay = 30.0
}

func isSessionActive() -> Bool {
PostHogSessionManager.shared.isSessionActive()
if !isEnabled() {
return false
}

return PostHogSessionManager.shared.isSessionActive()
}

#if os(iOS)
func isSessionReplayActive() -> Bool {
config.sessionReplay && isSessionActive() && (featureFlags?.isSessionReplayFlagActive() ?? false)
if !isEnabled() {
return false
}

return config.sessionReplay && isSessionActive() && (featureFlags?.isSessionReplayFlagActive() ?? false)
}
#endif
}
Expand Down
Loading