Skip to content

Commit 4ef0f79

Browse files
marandanetoeakurnikov
authored andcommitted
recording: do not rotate the session id for hybrid SDKs (PostHog#253)
1 parent bb3181e commit 4ef0f79

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Next
22

3+
- recording: do not rotate the session id for hybrid SDKs ([#253](https://github.com/PostHog/posthog-ios/pull/253))
4+
35
## 3.15.2 - 2024-11-13
46

57
- fix: allow changing person properties after identify ([#249](https://github.com/PostHog/posthog-ios/pull/249))

PostHog/PostHogSessionManager.swift

+20
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,17 @@ import Foundation
4646
timeNow - sessionLastTimestamp > sessionChangeThreshold
4747
}
4848

49+
private func isiOSNativeSdk() -> Bool {
50+
// postHogSdkName will be set to eg posthog-react-native if not
51+
postHogSdkName == postHogiOSSdkName
52+
}
53+
4954
func resetSessionIfExpired(_ completion: () -> Void) {
55+
// for hybrid SDKs, the session is handled by the hybrid SDK
56+
guard isiOSNativeSdk() else {
57+
return
58+
}
59+
5060
sessionLock.withLock {
5161
let timeNow = now().timeIntervalSince1970
5262
if sessionId != nil,
@@ -79,6 +89,11 @@ import Foundation
7989
}
8090

8191
func rotateSessionIdIfRequired(_ completion: @escaping (() -> Void)) {
92+
// for hybrid SDKs, the session is handled by the hybrid SDK
93+
guard isiOSNativeSdk() else {
94+
return
95+
}
96+
8297
sessionLock.withLock {
8398
let timeNow = now().timeIntervalSince1970
8499

@@ -94,6 +109,11 @@ import Foundation
94109
}
95110

96111
func updateSessionLastTime() {
112+
// for hybrid SDKs, the session is handled by the hybrid SDK
113+
guard isiOSNativeSdk() else {
114+
return
115+
}
116+
97117
sessionLock.withLock {
98118
sessionLastTimestamp = now().timeIntervalSince1970
99119
}

PostHog/PostHogVersion.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ import Foundation
1111
// This property is internal only
1212
public var postHogVersion = "3.15.2"
1313

14+
public let postHogiOSSdkName = "posthog-ios"
1415
// This property is internal only
15-
public var postHogSdkName = "posthog-ios"
16+
public var postHogSdkName = postHogiOSSdkName

0 commit comments

Comments
 (0)