Skip to content

Commit

Permalink
Clarification on registering super properties (#1702)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
argenisf authored Jan 9, 2025
1 parent 371672a commit e1ab9fc
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions pages/docs/tracking-methods/sdks/swift.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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).


Expand Down

0 comments on commit e1ab9fc

Please sign in to comment.