Reference Source Test
public class | source

Metrics

Extends:

* → Metrics

Metrics Class - Provides access to the Mux Data Metrics API

Example:

const muxClient = new Mux(accessToken, secret);
const { Data } = muxClient;

// List all of the values across every breakdown for a specific metric grouped by operating system
Data.Metrics.breakdown('aggregate_startup_time', { group_by: 'operating_system' });

Test:

Method Summary

Public Methods
public

breakdown(metricId: string, params: Object): Promise

List the breakdown values for a specific metric

public

List all of the values across every breakdown for a specific metric

public

insights(metricId: string, params: Object): Promise

Returns a list of insights for a metric.

public

overall(metricId: string, params: Object): Promise

Returns the overall value for a specific metric, as well as the total view count, watch time, and the Mux Global metric value for the metric.

public

timeseries(metricId: string, params: Object): Promise

Returns timeseries data for a specific metric

Public Methods

public breakdown(metricId: string, params: Object): Promise source

List the breakdown values for a specific metric

Params:

NameTypeAttributeDescription
metricId string

The metric name/id for see https://api-docs.mux.com/#breakdown-get for a list of all metric ids

params Object

example: {group_by: 'browser'} NOTE: the group_by query parameter is required

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const muxClient = new Mux(accessToken, secret);
const { Data } = muxClient;

// List all of the values across every breakdown for a specific metric grouped by browser
Data.Metrics.breakdown('aggregate_startup_time', { group_by: 'browser' });

See:

public comparison(params: Object): Promise source

List all of the values across every breakdown for a specific metric

Params:

NameTypeAttributeDescription
params Object

example { value: 'safari', timeframe: '24:hours', dimension: 'cdn' }

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const muxClient = new Mux(accessToken, secret);
const { Data } = muxClient;

// List the breakdown values for a specific metric within the last 24 hours
Data.Metrics.comparison({ value: 'safari', timeframe: '24:hours', dimension: 'cdn' });
Note: the value query parameter is required

Test:

See:

public insights(metricId: string, params: Object): Promise source

Returns a list of insights for a metric. These are the worst performing values across all breakdowns sorted by how much they negatively impact a specific metric.

Params:

NameTypeAttributeDescription
metricId string

The metric name/id for see https://api-docs.mux.com/#breakdown-get for a list of all metric ids

params Object
  • optional

example { measurement: 'median', order_direction: 'desc' }

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const muxClient = new Mux(accessToken, secret);
const { Data } = muxClient;

// Get a list of insights for a metric measured by median and ordered descending
Data.Metrics.insights('aggregate_startup_time', { measurement: 'median', order_direction: 'desc' });

Test:

See:

public overall(metricId: string, params: Object): Promise source

Returns the overall value for a specific metric, as well as the total view count, watch time, and the Mux Global metric value for the metric.

Params:

NameTypeAttributeDescription
metricId string

The metric name/id for see https://api-docs.mux.com/#overall-get for a list of all metric ids

params Object
  • optional

example { timeframe: ['7:days'], filters: ['operating_system:windows'] }

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const muxClient = new Mux(accessToken, secret);
const { Data } = muxClient;

// Get the overall value for a specific metric within the past 7 days
Data.Metrics.overall('aggregate_startup_time', { timeframe: ['7:days'] });

Test:

See:

public timeseries(metricId: string, params: Object): Promise source

Returns timeseries data for a specific metric

Params:

NameTypeAttributeDescription
metricId string

The metric name/id for see https://api-docs.mux.com/#timeseries for a list of all metric ids

params Object
  • optional

example { timeframe: ['7:days'], filters: ['operating_system:windows'] }

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const muxClient = new Mux(accessToken, secret);
const { Data } = muxClient;

// Get timeseries data for a specific metric within the past 7 days
Data.Metrics.timeseries('aggregate_startup_time', { timeframe: ['7:days'] });

Test:

See: