Measure Events

In some cases, you may want to measure event occurrences in your app, but not necessarily the duration. To do this, you can use the logMeasurement method on the PolarisService class.

export class GridComponent {
  onClick() {

Let's look at the signature of the logMeasurement method.

logMeasurement( eventName: string, result: MeasurementResult, duration: number, url: string | null, measurementMetadata: object = {}, resultMetadata: object = {}) => void

Let's review each argument:

  • eventName - The name of the event you want to measure. This is the only required argument.
  • result - The result of the event. This can be one of the following values:
    • MeasurementResult.Success - The event was successful.
    • MeasurementResult.Failure - The event failed.
    • MeasurementResult.Aborted - The event was aborted.
  • duration - The duration of the event in milliseconds.
  • url - The URL of the event. This is useful for tracking events that occur on different pages.
  • measurementMetadata - Any additional metadata you want to include about the event.
  • resultMetadata - Any additional metadata you want to include about the result.