Skip to content

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

Open
@fzy-github

Description

@fzy-github

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions