diff --git a/CHANGELOG.md b/CHANGELOG.md index 71ab865ab..5c215dddb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Next +- chore: expose session id ([#165](https://github.com/PostHog/posthog-ios/pull/165)) and ([#170](https://github.com/PostHog/posthog-ios/pull/170)) + ## 3.7.2 - 2024-08-16 - recording: improve ios session recording performance by avoiding redrawing after screen updates ([#166](https://github.com/PostHog/posthog-ios/pull/166)) diff --git a/PostHog/PostHogSDK.swift b/PostHog/PostHogSDK.swift index 47c4f04c8..9d2691b90 100644 --- a/PostHog/PostHogSDK.swift +++ b/PostHog/PostHogSDK.swift @@ -176,6 +176,18 @@ private let sessionChangeThreshold: TimeInterval = 60 * 30 return sessionManager?.getAnonymousId() ?? "" } + @objc public func getSessionId() -> String? { + if !isEnabled() { + return nil + } + + var tempSessionId: String? + sessionLock.withLock { + tempSessionId = sessionId + } + return tempSessionId + } + // EVENT CAPTURE private func dynamicContext() -> [String: Any] {