Skip to content

Commit

Permalink
add option for 'createAlias' for not creating user profile
Browse files Browse the repository at this point in the history
  • Loading branch information
zihejia committed Jun 24, 2022
1 parent 763b116 commit c9d3df5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,16 @@
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
launchAutomaticallySubstyle = "8">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/MixpanelDemo">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "86F86E8A22440C5C00B69832"
BuildableName = "MixpanelDemoWatch.app"
BlueprintName = "MixpanelDemoWatch"
ReferencedContainer = "container:MixpanelDemo.xcodeproj">
</BuildableReference>
</RemoteRunnable>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand All @@ -75,27 +73,16 @@
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
launchAutomaticallySubstyle = "8">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/MixpanelDemo">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "86F86E8A22440C5C00B69832"
BuildableName = "MixpanelDemoWatch.app"
BlueprintName = "MixpanelDemoWatch"
ReferencedContainer = "container:MixpanelDemo.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "86F86E8A22440C5C00B69832"
BuildableName = "MixpanelDemoWatch.app"
BlueprintName = "MixpanelDemoWatch"
ReferencedContainer = "container:MixpanelDemo.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,46 +54,33 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/MixpanelDemo">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "86F86E8A22440C5C00B69832"
BuildableName = "MixpanelDemoWatch.app"
BlueprintName = "MixpanelDemoWatch"
ReferencedContainer = "container:MixpanelDemo.xcodeproj">
</BuildableReference>
</RemoteRunnable>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/MixpanelDemo">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "86F86E8A22440C5C00B69832"
BuildableName = "MixpanelDemoWatch.app"
BlueprintName = "MixpanelDemoWatch"
ReferencedContainer = "container:MixpanelDemo.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "86F86E8A22440C5C00B69832"
BuildableName = "MixpanelDemoWatch.app"
BlueprintName = "MixpanelDemoWatch"
ReferencedContainer = "container:MixpanelDemo.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
6 changes: 4 additions & 2 deletions Sources/MixpanelInstance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ extension MixpanelInstance {
- parameter completion: an optional completion handler for when the createAlias has completed.
This should only be set to false if you wish to prevent people profile updates for that user.
*/
open func createAlias(_ alias: String, distinctId: String, usePeople: Bool = true, completion: (() -> Void)? = nil) {
open func createAlias(_ alias: String, distinctId: String, usePeople: Bool = true, createUserProfile: Bool = true, completion: (() -> Void)? = nil) {
if hasOptedOutTracking() {
if let completion = completion {
DispatchQueue.main.async(execute: completion)
Expand Down Expand Up @@ -731,7 +731,9 @@ extension MixpanelInstance {

let properties = ["distinct_id": distinctId, "alias": alias]
track(event: "$create_alias", properties: properties)
identify(distinctId: distinctId, usePeople: usePeople)
if createUserProfile {
identify(distinctId: distinctId, usePeople: usePeople)
}
flush(completion: completion)
} else {
Logger.error(message: "alias: \(alias) matches distinctId: \(distinctId) - skipping api call.")
Expand Down

0 comments on commit c9d3df5

Please sign in to comment.