Skip to content

Latest commit

 

History

History
512 lines (366 loc) · 38.1 KB

README.md

File metadata and controls

512 lines (366 loc) · 38.1 KB

Metrics

(metrics)

Available Operations

get

Read Single Metric Value

Example Usage

import { Statsig } from "statsig";

const statsig = new Statsig({
  statsigApiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await statsig.metrics.get({
    id: "<id>",
    date: "<value>",
  });

  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { metricsGet } from "statsig/funcs/metricsGet.js";

// Use `StatsigCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const statsig = new StatsigCore({
  statsigApiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await metricsGet(statsig, {
    id: "<id>",
    date: "<value>",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.ConsoleV1MetricsControllerGenReadMetricRequest ✔️ 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.ConsoleV1MetricsControllerGenReadMetricResponseBody>

Errors

Error Object Status Code Content Type
errors.ConsoleV1MetricsControllerGenReadMetricResponseBody 401 application/json
errors.SDKError 4xx-5xx /

getDefinition

Read Metric Definition

Example Usage

import { Statsig } from "statsig";

const statsig = new Statsig({
  statsigApiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await statsig.metrics.getDefinition({
    id: "<id>",
  });

  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { metricsGetDefinition } from "statsig/funcs/metricsGetDefinition.js";

// Use `StatsigCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const statsig = new StatsigCore({
  statsigApiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await metricsGetDefinition(statsig, {
    id: "<id>",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.ConsoleV1MetricsControllerGenReadMetricDefinitionRequest ✔️ 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.ConsoleV1MetricsControllerGenReadMetricDefinitionResponseBody>

Errors

Error Object Status Code Content Type
errors.ConsoleV1MetricsControllerGenReadMetricDefinitionResponseBody 404 application/json
errors.SDKError 4xx-5xx /

update

Update a metric

Example Usage

import { Statsig } from "statsig";

const statsig = new Statsig({
  statsigApiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await statsig.metrics.update({
    id: "<id>",
    metricsUpdateContractDto: {},
  });

  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { metricsUpdate } from "statsig/funcs/metricsUpdate.js";

// Use `StatsigCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const statsig = new StatsigCore({
  statsigApiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await metricsUpdate(statsig, {
    id: "<id>",
    metricsUpdateContractDto: {},
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.ConsoleV1MetricsControllerUpdateMetricRequest ✔️ 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.ConsoleV1MetricsControllerUpdateMetricResponseBody>

Errors

Error Object Status Code Content Type
errors.ConsoleV1MetricsControllerUpdateMetricResponseBody 401 application/json
errors.ConsoleV1MetricsControllerUpdateMetricMetricsResponseBody 404 application/json
errors.SDKError 4xx-5xx /

delete

Delete a metric

Example Usage

import { Statsig } from "statsig";

const statsig = new Statsig({
  statsigApiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await statsig.metrics.delete({
    id: "<id>",
  });

  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { metricsDelete } from "statsig/funcs/metricsDelete.js";

// Use `StatsigCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const statsig = new StatsigCore({
  statsigApiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await metricsDelete(statsig, {
    id: "<id>",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.ConsoleV1MetricsControllerDeleteMetricRequest ✔️ 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.ConsoleV1MetricsControllerDeleteMetricResponseBody>

Errors

Error Object Status Code Content Type
errors.ConsoleV1MetricsControllerDeleteMetricResponseBody 401 application/json
errors.ConsoleV1MetricsControllerDeleteMetricMetricsResponseBody 404 application/json
errors.SDKError 4xx-5xx /

listExperiments

Lineage: List experiments related to Metric

Example Usage

import { Statsig } from "statsig";

const statsig = new Statsig({
  statsigApiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await statsig.metrics.listExperiments({
    id: "<id>",
    tags: {
    "singleTag": {
      "value": "tag1",
    },
    "multipleTags": {
      "value": [
        "tag1",
        "tag2",
      ],
    },
  },
    limit: 10,
    page: 1,
  });

  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { metricsListExperiments } from "statsig/funcs/metricsListExperiments.js";

// Use `StatsigCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const statsig = new StatsigCore({
  statsigApiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await metricsListExperiments(statsig, {
    id: "<id>",
    tags: {
    "singleTag": {
      "value": "tag1",
    },
    "multipleTags": {
      "value": [
        "tag1",
        "tag2",
      ],
    },
  },
    limit: 10,
    page: 1,
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.ConsoleV1MetricsControllerGenExperimentListFromMetricRequest ✔️ 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.ConsoleV1MetricsControllerGenExperimentListFromMetricResponseBody>

Errors

Error Object Status Code Content Type
errors.ConsoleV1MetricsControllerGenExperimentListFromMetricResponseBody 401 application/json
errors.SDKError 4xx-5xx /

reload

Reload metric data

Example Usage

import { Statsig } from "statsig";

const statsig = new Statsig({
  statsigApiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await statsig.metrics.reload({
    id: "<id>",
  });

  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { metricsReload } from "statsig/funcs/metricsReload.js";

// Use `StatsigCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const statsig = new StatsigCore({
  statsigApiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await metricsReload(statsig, {
    id: "<id>",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.ConsoleV1MetricsControllerReloadMetricRequest ✔️ 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.ConsoleV1MetricsControllerReloadMetricResponseBody>

Errors

Error Object Status Code Content Type
errors.ConsoleV1MetricsControllerReloadMetricResponseBody 401 application/json
errors.ConsoleV1MetricsControllerReloadMetricMetricsResponseBody 404 application/json
errors.SDKError 4xx-5xx /