Skip to content

Commit

Permalink
Merge branch 'main' into feat/auto-capture-element-interactions
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
ioannisj committed Oct 31, 2024
2 parents 6b4ff59 + 4524c42 commit 52f16ba
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 10 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

- add autocapture support for UIKit ([#224](https://github.com/PostHog/posthog-ios/pull/224))

## 3.13.3 - 2024-10-25

- fix race condition in PostHogFileBackedQueue.deleteFiles ([#218](https://github.com/PostHog/posthog-ios/pull/218))

## 3.13.2 - 2024-10-18

- add missing capture method for objC with groups overload ([#217](https://github.com/PostHog/posthog-ios/pull/217))

## 3.13.1 - 2024-10-16

- add optional distinctId parameter to capture methods ([#216](https://github.com/PostHog/posthog-ios/pull/216))
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.13.1"
s.version = "3.13.3"
s.summary = "The hassle-free way to add posthog to your iOS app."

s.description = <<-DESC
Expand Down
12 changes: 8 additions & 4 deletions PostHog/PostHogFileBackedQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,14 @@ class PostHogFileBackedQueue {

private func deleteFiles(_ count: Int) {
for _ in 0 ..< count {
if items.isEmpty { return }
let removed = items.remove(at: 0) // We always remove from the top of the queue

deleteSafely(queue.appendingPathComponent(removed))
if let removed: String = _items.mutate({ items in
if items.isEmpty {
return nil
}
return items.remove(at: 0) // We always remove from the top of the queue
}) {
deleteSafely(queue.appendingPathComponent(removed))
}
}
}
}
12 changes: 11 additions & 1 deletion PostHog/PostHogSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ let maxRetryDelay = 30.0
}

@objc public func capture(_ event: String) {
capture(event, properties: nil, userProperties: nil, userPropertiesSetOnce: nil, groups: nil)
capture(event, distinctId: nil, properties: nil, userProperties: nil, userPropertiesSetOnce: nil, groups: nil)
}

@objc(captureWithEvent:properties:)
Expand Down Expand Up @@ -524,6 +524,16 @@ let maxRetryDelay = 30.0
return false
}

@objc(captureWithEvent:properties:userProperties:userPropertiesSetOnce:groups:)
public func capture(_ event: String,
properties: [String: Any]? = nil,
userProperties: [String: Any]? = nil,
userPropertiesSetOnce: [String: Any]? = nil,
groups: [String: String]? = nil)
{
capture(event, distinctId: nil, properties: properties, userProperties: userProperties, userPropertiesSetOnce: userPropertiesSetOnce, groups: groups)
}

@objc(captureWithEvent:distinctId:properties:userProperties:userPropertiesSetOnce:groups:)
public func capture(_ event: String,
distinctId: String? = nil,
Expand Down
2 changes: 1 addition & 1 deletion PostHog/PostHogVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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.13.1"
public var postHogVersion = "3.13.3"

// This property is internal only
public var postHogSdkName = "posthog-ios"
9 changes: 6 additions & 3 deletions PostHog/Utils/ReadWriteLock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ public final class ReadWriteLock<Value> {
/// The lock will be acquired once for writing before invoking the closure.
///
/// - Parameter closure: The closure with the mutable value.
public func mutate(_ closure: (inout Value) -> Void) {
@discardableResult
public func mutate<T>(_ closure: (inout Value) -> T) -> T {
pthread_rwlock_wrlock(&rwlock)
closure(&value)
pthread_rwlock_unlock(&rwlock)
defer {
pthread_rwlock_unlock(&rwlock)
}
return closure(&value)
}
}

Expand Down

0 comments on commit 52f16ba

Please sign in to comment.