From e1ab9fc0485a575ecbe449f4582fef9d0c51a611 Mon Sep 17 00:00:00 2001 From: Argenis Jesus Ferrer Mora Date: Thu, 9 Jan 2025 01:36:30 +0100 Subject: [PATCH] Clarification on registering super properties (#1702) Making many calls to register super properties sequentially can cause race conditions overwriting each other. Updating the docs on how to create them to make it more efficient and reduce the chance of the issue. Also filing a feature request for this to be improved. --- pages/docs/tracking-methods/sdks/swift.mdx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/pages/docs/tracking-methods/sdks/swift.mdx b/pages/docs/tracking-methods/sdks/swift.mdx index 66d72c2b2b..2b51061207 100644 --- a/pages/docs/tracking-methods/sdks/swift.mdx +++ b/pages/docs/tracking-methods/sdks/swift.mdx @@ -180,16 +180,26 @@ Mixpanel.mainInstance().registerSuperProperties(["name": "Sam"]) /// track "some_event" /// "name" is automatically added as an event prop Mixpanel.mainInstance().track(event: "some_event") - -// this is ignored because "name" already exists -Mixpanel.mainInstance().registerSuperPropertiesOnce(["name": "Samantha"]) - -/// register a "location" super property -Mixpanel.mainInstance().registerSuperPropertiesOnce(["location": "us"]) ``` Our mobile libraries store your super properties in local storage. They will persist so long as the app is installed (between launches and updates). Uninstalling the app will remove that customers super properties. +**Note** +As creating properties involves an async operation to local storage, if you will create multiple properties at once, it's best to send a single call to the register function with all properties at once, to avoid possible issues with race conditions overwriting each other. This is just in case you will create multiple properties all in the same block of code. + +**Example Usage** +```swift Swift +Mixpanel.mainInstance().registerSuperProperties([ + "superProp0": "value1", + "superProp1": "value2", + "superProp2": "value3", + "superProp3": 1, + "superProp4": 2, + "superProp5": 3]) + +Mixpanel.mainInstance().(event:"test") +``` + See more methods related to super properties in the complete library reference [here](https://mixpanel.github.io/mixpanel-swift/Classes/MixpanelInstance.html).