Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to track multiple "time" events with the same name #614

Open
fzy-github opened this issue Sep 27, 2023 · 3 comments
Open

How to track multiple "time" events with the same name #614

fzy-github opened this issue Sep 27, 2023 · 3 comments

Comments

@fzy-github
Copy link

fzy-github commented Sep 27, 2023

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

@nathanmclain
Copy link

@fzy-spyro ever get an answer or find a work around on this?

@fzy-github
Copy link
Author

@nathanmclain unfortunately no. I implemented my own way of tracking those events

@cmriboldi
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants