Skip to content

Latest commit

 

History

History
434 lines (306 loc) · 29.6 KB

File metadata and controls

434 lines (306 loc) · 29.6 KB

Metrics

Overview

Operations involving metrics

Available Operations

listBreakdownValues

Retrieves breakdown values for a specified metric and timespan, allowing you to analyze the performance of your content based on various dimensions. It provides insights into how different factors contribute to the overall metrics.

How it works

  1. Before using this endpoint, you can call the List Dimensions endpoint to retrieve all available dimensions that can be used in your query.

  2. Send a GET request to this endpoint with the required metricId and other query parameters.

  3. You receive a response containing the breakdown values for the specified metric, grouped and filtered according to your parameters.

  4. Upon successful retrieval, the response includes the breakdown values based on the specified parameters. Note that the time values ( totalWatchTime and totalPlayingTime ) are in milliseconds

Example

A developer wants to analyze how watch time varies across different device types. By calling this endpoint for the playing_time metric and filtering by device_type, they can understand how engagement differs between mobile, desktop, and tablet users. This data guides optimization efforts for different platforms.

Key fields in response

  • views: The count of views based based on the applied filters.

  • value: The specific metric value calculated based on the applied filters.

  • totalWatchTime: Total time watched across all views, represented in milliseconds.

  • totalPlayTime: Total time spent playing the video, represented in milliseconds.

  • field: The grouping field value based on the groupBy parameter.

Related guide: Understand data definitions

Example Usage

import { Fastpix } from "@fastpix/fastpix-node";

const fastpix = new Fastpix({
  security: {
    username: "your-access-token",
    password: "your-secret-key",
  },
});

async function run() {
  const result = await fastpix.metrics.listBreakdownValues({
    metricId: "your-metric-id",
    timespan: "24:hours",
    filterby: "browser_name:Chrome",
    groupBy: "browser_name",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { FastpixCore } from "@fastpix/fastpix-node/core.js";
import { metricsListBreakdownValues } from "@fastpix/fastpix-node/funcs/metricsListBreakdownValues.js";

// Use `FastpixCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const fastpix = new FastpixCore({
  security: {
    username: "your-access-token",
    password: "your-secret-key",
  },
});

async function run() {
  const res = await metricsListBreakdownValues(fastpix, {
    metricId: "your-metric-id",
    timespan: "24:hours",
    filterby: "browser_name:Chrome",
    groupBy: "browser_name",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("metricsListBreakdownValues failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.ListBreakdownValuesRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.ListBreakdownValuesResponse>

Errors

Error Type Status Code Content Type
errors.FastpixDefaultError 4XX, 5XX */*

listOverallValues

Retrieves overall values for a specified metric, providing summary statistics that help you understand the performance of your content. The response includes key metrics such as totalWatchTime, uniqueViews, totalPlayTime and totalViews.

How it works

  1. Before using this endpoint, you can call the list dimensions endpoint to retrieve all available dimensions that can be used in your query.

  2. Send a GET request to this endpoint with the required metricId and other query parameters.

  3. You receive a response containing the overall values for the specified metric, which may vary based on the applied filters.

Key fields in response

  • value: The specific metric value calculated based on the applied filters.
  • totalWatchTime: Total time watched across all views, represented in milliseconds.
  • uniqueViews: The count of unique viewers who interacted with the content.
  • totalViews: The total number of views recorded.
  • totalPlayTime: Total time spent playing the video, represented in milliseconds.
  • globalValue: A global metric value that reflects the overall performance of the specified metric across the entire dataset for the given timespan. This value is not affected by specific filters.

Related guide: Understand data definitions

Example Usage

import { Fastpix } from "@fastpix/fastpix-node";

const fastpix = new Fastpix({
  security: {
    username: "your-access-token",
    password: "your-secret-key",
  },
});

async function run() {
  const result = await fastpix.metrics.listOverallValues({
    metricId: "your-metric-id",
    timespan: "24:hours",
    filterby: "browser_name:Chrome",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { FastpixCore } from "@fastpix/fastpix-node/core.js";
import { metricsListOverallValues } from "@fastpix/fastpix-node/funcs/metricsListOverallValues.js";

// Use `FastpixCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const fastpix = new FastpixCore({
  security: {
    username: "your-access-token",
    password: "your-secret-key",
  },
});

async function run() {
  const res = await metricsListOverallValues(fastpix, {
    metricId: "your-metric-id",
    timespan: "24:hours",
    filterby: "browser_name:Chrome",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("metricsListOverallValues failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.ListOverallValuesRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.ListOverallValuesResponse>

Errors

Error Type Status Code Content Type
errors.FastpixDefaultError 4XX, 5XX */*

getTimeseriesData

This endpoint retrieves timeseries data for a specified metric, providing insights into how the metric values change over time. The response includes an array of data points, each representing the metrics value at specific intervals.

Key fields in response

  • intervalTime: The timestamp for the data point indicating when the metric value was recorded.
  • metricValue: The value of the specified metric at the given interval, reflecting the performance or engagement level during that time.
  • numberOfViews: The total number of views recorded during that interval, providing context for the metric value.

Example Usage

import { Fastpix } from "@fastpix/fastpix-node";

const fastpix = new Fastpix({
  security: {
    username: "your-access-token",
    password: "your-secret-key",
  },
});

async function run() {
  const result = await fastpix.metrics.getTimeseriesData({
    metricId: "your-metric-id",
    timespan: "24:hours",
    filterby: "browser_name:Chrome",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { FastpixCore } from "@fastpix/fastpix-node/core.js";
import { metricsGetTimeseriesData } from "@fastpix/fastpix-node/funcs/metricsGetTimeseriesData.js";

// Use `FastpixCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const fastpix = new FastpixCore({
  security: {
    username: "your-access-token",
    password: "your-secret-key",
  },
});

async function run() {
  const res = await metricsGetTimeseriesData(fastpix, {
    metricId: "your-metric-id",
    timespan: "24:hours",
    filterby: "browser_name:Chrome",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("metricsGetTimeseriesData failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetTimeseriesDataRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.GetTimeseriesDataResponse>

Errors

Error Type Status Code Content Type
errors.FastpixDefaultError 4XX, 5XX */*

listCompares

This endpoint lets you to compare multiple metrics across specified dimensions. You can specify the metrics you want to compare in the query parameters, and the response includes the relevant metrics for the specified dimensions.

Key fields in response

  • value: The specific metric value calculated based on the applied filters.
  • type: The data unit or format type (for example, "number", "milliseconds", "percentage").
  • name: The display name of the metric (for example, "Views", "Overall Score").
  • metric: The metric field represents the name of the Key Performance Indicator (KPI) being tracked or analyzed. It identifies a specific measurable aspect of the video playback experience, such as buffering time, video start failure rate, or playback quality.
  • items: Nested breakdown of related metrics for more detailed analysis.
  • measurement: Defines the aggregation type (for example, "avg", "sum", "median", "95th").

How it works

  1. Before making a request to this endpoint, call the list dimensions endpoint to obtain all available dimensions that can be used for comparison.

  2. Send a GET request to this endpoint with the desired metrics specified in the query parameters.

  3. You Receive a response containing the comparison values for the specified metrics across the selected dimensions.

Related guide: Compare metrics in dashboard

Example Usage

import { Fastpix } from "@fastpix/fastpix-node";

const fastpix = new Fastpix({
  security: {
    username: "your-access-token",
    password: "your-secret-key",
  },
});

async function run() {
  const result = await fastpix.metrics.listCompares({
    timespan: "24:hours",
    filterby: "browser_name:Chrome",
    dimension: "browser_name",
    value: "Chrome",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { FastpixCore } from "@fastpix/fastpix-node/core.js";
import { metricsListCompares } from "@fastpix/fastpix-node/funcs/metricsListCompares.js";

// Use `FastpixCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const fastpix = new FastpixCore({
  security: {
    username: "your-access-token",
    password: "your-secret-key",
  },
});

async function run() {
  const res = await metricsListCompares(fastpix, {
    timespan: "24:hours",
    filterby: "browser_name:Chrome",
    dimension: "browser_name",
    value: "Chrome",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("metricsListCompares failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.ListComparisonValuesRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.ListComparisonValuesResponse>

Errors

Error Type Status Code Content Type
errors.FastpixDefaultError 4XX, 5XX */*