Skip to content

Commit

Permalink
Merge branch 'main' into fix/sync-deadlock
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
ioannisj committed Nov 19, 2024
2 parents e72c278 + 79dd9dc commit de4107d
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

- fix: reading screen size could sometimes lead to a deadlock ([#252](https://github.com/PostHog/posthog-ios/pull/252))

## 3.15.3 - 2024-11-18

- fix: mangled wireframe layouts ([#250](https://github.com/PostHog/posthog-ios/pull/250))
- recording: do not rotate the session id for hybrid SDKs ([#253](https://github.com/PostHog/posthog-ios/pull/253))

## 3.15.2 - 2024-11-13

- fix: allow changing person properties after identify ([#249](https://github.com/PostHog/posthog-ios/pull/249))
Expand Down
2 changes: 1 addition & 1 deletion PostHog.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "PostHog"
s.version = "3.15.2"
s.version = "3.15.3"
s.summary = "The hassle-free way to add posthog to your iOS app."

s.description = <<-DESC
Expand Down
20 changes: 20 additions & 0 deletions PostHog/PostHogSessionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,17 @@ import Foundation
timeNow - sessionLastTimestamp > sessionChangeThreshold
}

private func isiOSNativeSdk() -> Bool {
// postHogSdkName will be set to eg posthog-react-native if not
postHogSdkName == postHogiOSSdkName
}

func resetSessionIfExpired(_ completion: () -> Void) {
// for hybrid SDKs, the session is handled by the hybrid SDK
guard isiOSNativeSdk() else {
return
}

sessionLock.withLock {
let timeNow = now().timeIntervalSince1970
if sessionId != nil,
Expand Down Expand Up @@ -79,6 +89,11 @@ import Foundation
}

func rotateSessionIdIfRequired(_ completion: @escaping (() -> Void)) {
// for hybrid SDKs, the session is handled by the hybrid SDK
guard isiOSNativeSdk() else {
return
}

sessionLock.withLock {
let timeNow = now().timeIntervalSince1970

Expand All @@ -94,6 +109,11 @@ import Foundation
}

func updateSessionLastTime() {
// for hybrid SDKs, the session is handled by the hybrid SDK
guard isiOSNativeSdk() else {
return
}

sessionLock.withLock {
sessionLastTimestamp = now().timeIntervalSince1970
}
Expand Down
5 changes: 3 additions & 2 deletions PostHog/PostHogVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import Foundation

// if you change this, make sure to also change it in the podspec and check if the script scripts/bump-version.sh still works
// This property is internal only
public var postHogVersion = "3.15.2"
public var postHogVersion = "3.15.3"

public let postHogiOSSdkName = "posthog-ios"
// This property is internal only
public var postHogSdkName = "posthog-ios"
public var postHogSdkName = postHogiOSSdkName
19 changes: 13 additions & 6 deletions PostHog/Replay/PostHogReplayIntegration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,19 @@
style.paddingLeft = Int(insets.left)
}

private func createBasicWireframe(_ window: UIView) -> RRWireframe {
private func createBasicWireframe(_ view: UIView) -> RRWireframe {
let wireframe = RRWireframe()

wireframe.id = window.hash
wireframe.posX = Int(window.frame.origin.x)
wireframe.posY = Int(window.frame.origin.y)
wireframe.width = Int(window.frame.size.width)
wireframe.height = Int(window.frame.size.height)
// since FE will render each node of the wireframe with position: fixed
// we need to convert bounds to global screen coordinates
// otherwise each view of depth > 1 will likely have an origin of 0,0 (which is the local origin)
let frame = view.toAbsoluteRect(view.window)

wireframe.id = view.hash
wireframe.posX = Int(frame.origin.x)
wireframe.posY = Int(frame.origin.y)
wireframe.width = Int(frame.size.width)
wireframe.height = Int(frame.size.height)

return wireframe
}
Expand Down Expand Up @@ -448,6 +453,8 @@
wireframe.disabled = !button.isEnabled

if let text = button.titleLabel?.text {
// NOTE: this will create a ghosting effect since text will also be captured in child UILabel
// We also may be masking this UIButton but child UILabel may remain unmasked
wireframe.value = isButtonSensitive(button) ? text.mask() : text
}
}
Expand Down
2 changes: 1 addition & 1 deletion PostHog/Replay/PostHogSessionReplayConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

@objc(PostHogSessionReplayConfig) public class PostHogSessionReplayConfig: NSObject {
/// Enable masking of all text input fields
/// Enable masking of all text and text input fields
/// Experimental support
/// Default: true
@objc public var maskAllTextInputs: Bool = true
Expand Down
2 changes: 1 addition & 1 deletion PostHog/Replay/UIView+Util.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
}

// you need this because of SwiftUI otherwise the coordinates always zeroed for some reason
func toAbsoluteRect(_ window: UIWindow) -> CGRect {
func toAbsoluteRect(_ window: UIWindow?) -> CGRect {
convert(bounds, to: window)
}
}
Expand Down
6 changes: 2 additions & 4 deletions PostHog/Utils/UIApplication+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
}
} else {
// check scene.windows.isKeyWindow
for window in scene.windows {
if window.isKeyWindow {
return window
}
for window in scene.windows where window.isKeyWindow {
return window
}
}

Expand Down

0 comments on commit de4107d

Please sign in to comment.