mixpanel-swift
mixpanel-swift copied to clipboard
How to track multiple "time" events with the same name
Hey Mixpanel team,
I have a question - is it possible to track multiple "time" events withe the same name?
Let's imagine that I am working on a "cloud storage" app and I want to track how long it takes for a user to upload a single file to a server and at the same time app allows uploading multiple files in parallel.
my tracking code would look smth like:
func startUpload(filePaths: [String]) {
filePaths.forEach { upload($0) }
}
func upload(filePath: String) async {
Task {
do {
Mixpanel.mainInstance().time("FileUpload")
try await httpClient.uploadFile(filePath)
Mixpanel.mainInstance().track("FileUpload", properties: ["result": "ok", "path": filePath])
} catch {
Mixpanel.mainInstance().track("FileUpload", properties: ["result": "fail", "path": filePath])
}
}
}
Is this valid code from Mixpanel tracking point of view? Will it correctly track eg. 3 uploads happening in parallel?
If not how this can be achieved using mixpanel?
I can possibly create a unique event name like eg: FileUpload-\(filePath)
but this means that I am not following best practice as shown eg here: https://docs.mixpanel.com/docs/tracking/how-tos/events-and-properties#best-practices
@fzy-spyro ever get an answer or find a work around on this?
@nathanmclain unfortunately no. I implemented my own way of tracking those events
@nathanmclain and @fzy-spyro I fixed the issue in this MR. It would be nice if we get some eyes and traction on it so that we can get this merged in so that we don't have to make our own "fixes" for this very fixable issue with the SDK.