Skip to content

Commit

Permalink
fix: allow set person properties after identify
Browse files Browse the repository at this point in the history
  • Loading branch information
ioannisj committed Nov 12, 2024
1 parent 8d74acb commit ddf8c36
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion PostHog/PostHogSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,10 @@ let maxRetryDelay = 30.0

let isIdentified = storageManager.isIdentified()

if distinctId != oldDistinctId, !isIdentified {
let hasDistinctIdChanges = distinctId != oldDistinctId && !isIdentified
let hasUserPropertyChanges = !(userProperties?.isEmpty ?? true) || !(userPropertiesSetOnce?.isEmpty ?? true)

if hasDistinctIdChanges {
// We keep the AnonymousId to be used by decide calls and identify to link the previousId
storageManager.setAnonymousId(oldDistinctId)
storageManager.setDistinctId(distinctId)
Expand All @@ -490,6 +493,11 @@ let maxRetryDelay = 30.0
if shouldReloadFlagsForTesting {
reloadFeatureFlags()
}
} else if hasUserPropertyChanges {
capture("$set",
distinctId: distinctId,
userProperties: userProperties,
userPropertiesSetOnce: userPropertiesSetOnce)
} else {
hedgeLog("already identified with id: \(oldDistinctId)")
}
Expand Down

0 comments on commit ddf8c36

Please sign in to comment.