Skip to content

Latest commit

 

History

History
786 lines (568 loc) · 57 KB

README.md

File metadata and controls

786 lines (568 loc) · 57 KB

Segments

(segments)

Available Operations

create

Create Segment

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.segments.create({
    segmentCreateContractDto: {
      name: "<value>",
      type: "rule_based",
    },
  });

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

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { segmentsCreate } from "statsig/funcs/segmentsCreate.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 segmentsCreate(statsig, {
    segmentCreateContractDto: {
      name: "<value>",
      type: "rule_based",
    },
  });

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

  const { value: result } = res;

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

run();

Parameters

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

Errors

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

list

List Segments

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.segments.list({
    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 { segmentsList } from "statsig/funcs/segmentsList.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 segmentsList(statsig, {
    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.ConsoleV1SegmentsControllerGenListRequest ✔️ 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.ConsoleV1SegmentsControllerGenListResponseBody>

Errors

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

get

Get Segment

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.segments.get({
    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 { segmentsGet } from "statsig/funcs/segmentsGet.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 segmentsGet(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.ConsoleV1SegmentsControllerGenReadRequest ✔️ 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.ConsoleV1SegmentsControllerGenReadResponseBody>

Errors

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

delete

Delete Segment

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.segments.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 { segmentsDelete } from "statsig/funcs/segmentsDelete.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 segmentsDelete(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.ConsoleV1SegmentsControllerGenRemoveRequest ✔️ 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.ConsoleV1SegmentsControllerGenRemoveResponseBody>

Errors

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

getIDList

Get IDs in a Segment

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.segments.getIDList({
    id: "<id>",
    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 { segmentsGetIDList } from "statsig/funcs/segmentsGetIDList.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 segmentsGetIDList(statsig, {
    id: "<id>",
    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.ConsoleV1SegmentsIDListControllerReadRequest ✔️ 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.ConsoleV1SegmentsIDListControllerReadResponseBody>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

addIDs

Add IDs to Segment

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.segments.addIDs({
    id: "<id>",
    segmentIDListContractDto: {
      ids: [
        "<value>",
      ],
    },
  });

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

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { segmentsAddIDs } from "statsig/funcs/segmentsAddIDs.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 segmentsAddIDs(statsig, {
    id: "<id>",
    segmentIDListContractDto: {
      ids: [
        "<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.ConsoleV1SegmentsIDListControllerAddRequest ✔️ 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.ConsoleV1SegmentsIDListControllerAddResponseBody>

Errors

Error Object Status Code Content Type
errors.ConsoleV1SegmentsIDListControllerAddResponseBody 400 application/json
errors.ConsoleV1SegmentsIDListControllerAddSegmentsResponseBody 401 application/json
errors.ConsoleV1SegmentsIDListControllerAddSegmentsResponseResponseBody 404 application/json
errors.SDKError 4xx-5xx /

removeIDs

Remove IDs from Segment

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.segments.removeIDs({
    id: "<id>",
    segmentIDListContractDto: {
      ids: [
        "<value>",
      ],
    },
  });

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

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { segmentsRemoveIDs } from "statsig/funcs/segmentsRemoveIDs.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 segmentsRemoveIDs(statsig, {
    id: "<id>",
    segmentIDListContractDto: {
      ids: [
        "<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.ConsoleV1SegmentsIDListControllerGenRemoveRequest ✔️ 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.ConsoleV1SegmentsIDListControllerGenRemoveResponseBody>

Errors

Error Object Status Code Content Type
errors.ConsoleV1SegmentsIDListControllerGenRemoveResponseBody 400 application/json
errors.ConsoleV1SegmentsIDListControllerGenRemoveSegmentsResponseBody 401 application/json
errors.ConsoleV1SegmentsIDListControllerGenRemoveSegmentsResponseResponseBody 404 application/json
errors.SDKError 4xx-5xx /

resetIDList

Upsert ID List Segment

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.segments.resetIDList({
    id: "<id>",
    segmentIDListResetContractDto: {
      ids: [
        "<value>",
      ],
    },
  });

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

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { segmentsResetIDList } from "statsig/funcs/segmentsResetIDList.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 segmentsResetIDList(statsig, {
    id: "<id>",
    segmentIDListResetContractDto: {
      ids: [
        "<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.ConsoleV1SegmentsIDListResetControllerResetRequest ✔️ 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.ConsoleV1SegmentsIDListResetControllerResetResponseBody>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

updateConditional

Update Segment Rules

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.segments.updateConditional({
    id: "<id>",
    requestBody: [
      {
        name: "<value>",
        passPercentage: 9737.46,
        conditions: [
          {
            type: "browser_version",
          },
        ],
      },
    ],
  });

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

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { segmentsUpdateConditional } from "statsig/funcs/segmentsUpdateConditional.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 segmentsUpdateConditional(statsig, {
    id: "<id>",
    requestBody: [
      {
        name: "<value>",
        passPercentage: 8202.56,
        conditions: [
          {
            type: "browser_name",
          },
        ],
      },
    ],
  });

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

  const { value: result } = res;

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

run();

Parameters

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

Errors

Error Object Status Code Content Type
errors.ConsoleV1SegmentsRulesControllerUpdateResponseBody 400 application/json
errors.ConsoleV1SegmentsRulesControllerUpdateSegmentsResponseBody 401 application/json
errors.ConsoleV1SegmentsRulesControllerUpdateSegmentsResponseResponseBody 404 application/json
errors.SDKError 4xx-5xx /