Skip to content

Latest commit

 

History

History
2310 lines (1804 loc) · 131 KB

README.md

File metadata and controls

2310 lines (1804 loc) · 131 KB

Gates

(gates)

Available Operations

create

Create Gate

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.create({
    gateCreateDto: {
      isEnabled: false,
      description: "helpful summary of what this gate does",
      rules: [
        {
          name: "All Conditions",
          passPercentage: 10,
          conditions: [
            {
              type: "public",
            },
            {
            targetValue:     [
                  111,
                  222,
                ],
              operator: "any",
              type: "user_id",
            },
            {
            targetValue:     [
                  @outlook.com,
                  @gmail.com,
                ],
              operator: "str_contains_any",
              type: "email",
            },
            {
            targetValue: 31,
              operator: "gt",
              field: "age",
              type: "custom_field",
            },
            {
            targetValue: "1.1.1",
              operator: "version_gt",
              type: "app_version",
            },
            {
            targetValue: "[\"Android\",\"Chrome\"]",
              operator: "any",
              type: "browser_name",
            },
            {
            targetValue: 94.0.4606.81,94.0.4606.92,
              operator: "any",
              type: "browser_version",
            },
            {
            targetValue:     [
                  Android,
                  Windows,
                ],
              operator: "none",
              type: "os_name",
            },
            {
            targetValue: "11.0.0",
              operator: "version_lte",
              type: "os_version",
            },
            {
            targetValue:     [
                  NZ,
                  US,
                ],
              operator: "any",
              type: "country",
            },
            {
            targetValue: "my_gate_2",
              type: "passes_gate",
            },
            {
            targetValue: "my_gate_2",
              type: "fails_gate",
            },
            {
            targetValue: 1643070357193,
              operator: "after",
              type: "time",
            },
            {
            targetValue:     [
                  "production",
                ],
              operator: "any",
              type: "environment_tier",
            },
            {
            targetValue: "growth_org",
              type: "passes_segment",
            },
            {
            targetValue: "growth_org",
              type: "fails_segment",
            },
            {
            targetValue: 1.1.1.1,8.8.8.8,
              operator: "any",
              type: "ip_address",
            },
          ],
        },
      ],
      tags: [
        "<value>",
      ],
      idType: "userID",
    targetApps: "[\"my_app\"]",
      team: "team",
      monitoringMetrics: [
        {
          name: "dau",
          type: "user",
        },
      ],
      name: "a_verbose_gate",
    },
  });

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

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { gatesCreate } from "statsig/funcs/gatesCreate.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 gatesCreate(statsig, {
    gateCreateDto: {
      isEnabled: false,
      description: "helpful summary of what this gate does",
      rules: [
        {
          name: "All Conditions",
          passPercentage: 10,
          conditions: [
            {
              type: "public",
            },
            {
            targetValue:     [
                  "111",
                  "222",
                ],
              operator: "any",
              type: "user_id",
            },
            {
            targetValue: "[\"@outlook.com\",\"@gmail.com\"]",
              operator: "str_contains_any",
              type: "email",
            },
            {
            targetValue: 31,
              operator: "gt",
              field: "age",
              type: "custom_field",
            },
            {
            targetValue: "1.1.1",
              operator: "version_gt",
              type: "app_version",
            },
            {
            targetValue: Android,Chrome,
              operator: "any",
              type: "browser_name",
            },
            {
            targetValue: 94.0.4606.81,94.0.4606.92,
              operator: "any",
              type: "browser_version",
            },
            {
            targetValue: Android,Windows,
              operator: "none",
              type: "os_name",
            },
            {
            targetValue: "11.0.0",
              operator: "version_lte",
              type: "os_version",
            },
            {
            targetValue: "[\"NZ\",\"US\"]",
              operator: "any",
              type: "country",
            },
            {
            targetValue: "my_gate_2",
              type: "passes_gate",
            },
            {
            targetValue: "my_gate_2",
              type: "fails_gate",
            },
            {
            targetValue: 1643070357193,
              operator: "after",
              type: "time",
            },
            {
            targetValue: "[\"production\"]",
              operator: "any",
              type: "environment_tier",
            },
            {
            targetValue: "growth_org",
              type: "passes_segment",
            },
            {
            targetValue: "growth_org",
              type: "fails_segment",
            },
            {
            targetValue: 1.1.1.1,8.8.8.8,
              operator: "any",
              type: "ip_address",
            },
          ],
        },
      ],
      tags: [
        "<value>",
      ],
      idType: "userID",
    targetApps:     [
          "my_app",
        ],
      team: "team",
      monitoringMetrics: [
        {
          name: "dau",
          type: "user",
        },
      ],
      name: "a_verbose_gate",
    },
  });

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

  const { value: result } = res;

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

run();

Parameters

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

Errors

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

list

List Gates

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.list({
    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 { gatesList } from "statsig/funcs/gatesList.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 gatesList(statsig, {
    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.ConsoleV1GatesControllerGenListRequest ✔️ 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.ConsoleV1GatesControllerGenListResponseBody>

Errors

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

get

Read Gate

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.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 { gatesGet } from "statsig/funcs/gatesGet.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 gatesGet(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.ConsoleV1GatesControllerGenReadRequest ✔️ 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.ConsoleV1GatesControllerGenReadResponseBody>

Errors

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

updatePartial

Partially Update Gates

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.updatePartial({
    id: "<id>",
    gatePartialUpdateDto: {
      description: "Updated the description of the gate",
    },
  });

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

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { gatesUpdatePartial } from "statsig/funcs/gatesUpdatePartial.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 gatesUpdatePartial(statsig, {
    id: "<id>",
    gatePartialUpdateDto: {
      description: "Updated the description of the gate",
    },
  });

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

  const { value: result } = res;

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

run();

Parameters

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

Errors

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

update

Fully Update Gates

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.update({
    id: "<id>",
    gateFullUpdateDto: {
      isEnabled: false,
      description: "Updated Gate Description",
      rules: [
        {
          name: "All Conditions",
          passPercentage: 10,
          conditions: [
            {
            targetValue: 111,222,
              operator: "any",
              type: "user_id",
            },
            {
            targetValue:     [
                  "@outlook.com",
                  "@gmail.com",
                ],
              operator: "str_contains_any",
              type: "email",
            },
            {
            targetValue: 31,
              operator: "gt",
              field: "age",
              type: "custom_field",
            },
            {
            targetValue: "1.1.1",
              operator: "version_gt",
              type: "app_version",
            },
            {
            targetValue: "[\"Android\",\"Chrome\"]",
              operator: "any",
              type: "browser_name",
            },
            {
            targetValue:     [
                  "94.0.4606.81",
                  "94.0.4606.92",
                ],
              operator: "any",
              type: "browser_version",
            },
            {
            targetValue:     [
                  Android,
                  Windows,
                ],
              operator: "none",
              type: "os_name",
            },
            {
            targetValue: "11.0.0",
              operator: "version_lte",
              type: "os_version",
            },
            {
            targetValue: "[\"NZ\",\"US\"]",
              operator: "any",
              type: "country",
            },
            {
            targetValue: production,
              operator: "any",
              type: "environment_tier",
            },
            {
            targetValue: "growth_org",
              type: "passes_segment",
            },
            {
            targetValue: "growth_org",
              type: "fails_segment",
            },
            {
            targetValue:     [
                  1.1.1.1,
                  8.8.8.8,
                ],
              operator: "any",
              type: "ip_address",
            },
            {
            targetValue: "[\"31\"]",
              operator: "any",
              customID: "userID",
              type: "unit_id",
            },
          ],
        },
      ],
      tags: [
        "★ Core",
      ],
      type: "TEMPORARY",
      idType: "stableID",
    targetApps:     [
          "<value>",
        ],
    },
  });

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

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { gatesUpdate } from "statsig/funcs/gatesUpdate.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 gatesUpdate(statsig, {
    id: "<id>",
    gateFullUpdateDto: {
      isEnabled: false,
      description: "Updated Gate Description",
      rules: [
        {
          name: "All Conditions",
          passPercentage: 10,
          conditions: [
            {
            targetValue:     [
                  111,
                  222,
                ],
              operator: "any",
              type: "user_id",
            },
            {
            targetValue:     [
                  @outlook.com,
                  @gmail.com,
                ],
              operator: "str_contains_any",
              type: "email",
            },
            {
            targetValue: 31,
              operator: "gt",
              field: "age",
              type: "custom_field",
            },
            {
            targetValue: "1.1.1",
              operator: "version_gt",
              type: "app_version",
            },
            {
            targetValue:     [
                  Android,
                  Chrome,
                ],
              operator: "any",
              type: "browser_name",
            },
            {
            targetValue: 94.0.4606.81,94.0.4606.92,
              operator: "any",
              type: "browser_version",
            },
            {
            targetValue:     [
                  "Android",
                  "Windows",
                ],
              operator: "none",
              type: "os_name",
            },
            {
            targetValue: "11.0.0",
              operator: "version_lte",
              type: "os_version",
            },
            {
            targetValue:     [
                  NZ,
                  US,
                ],
              operator: "any",
              type: "country",
            },
            {
            targetValue:     [
                  "production",
                ],
              operator: "any",
              type: "environment_tier",
            },
            {
            targetValue: "growth_org",
              type: "passes_segment",
            },
            {
            targetValue: "growth_org",
              type: "fails_segment",
            },
            {
            targetValue: "[\"1.1.1.1\",\"8.8.8.8\"]",
              operator: "any",
              type: "ip_address",
            },
            {
            targetValue: 31,
              operator: "any",
              customID: "userID",
              type: "unit_id",
            },
          ],
        },
      ],
      tags: [
        "★ Core",
      ],
      type: "TEMPORARY",
      idType: "stableID",
    targetApps:     [
          "<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.ConsoleV1GatesControllerGenFullUpdateRequest ✔️ 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.ConsoleV1GatesControllerGenFullUpdateResponseBody>

Errors

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

delete

Delete Gates

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.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 { gatesDelete } from "statsig/funcs/gatesDelete.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 gatesDelete(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.ConsoleV1GatesControllerGenRemoveRequest ✔️ 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.ConsoleV1GatesControllerGenRemoveResponseBody>

Errors

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

getRules

Read Gate Rules

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.getRules({
    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 { gatesGetRules } from "statsig/funcs/gatesGetRules.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 gatesGetRules(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.ConsoleV1GatesControllerGenReadRulesRequest ✔️ 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.ConsoleV1GatesControllerGenReadRulesResponseBody>

Errors

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

updateRules

Update list of Gate Rules

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.updateRules({
    id: "<id>",
    multiRuleUpdateDto: {
      rules: [
        {
          name: "All Conditions",
          passPercentage: 10,
          conditions: [
            {
            targetValue:     [
                  0,
                ],
              operator: "any",
              field: "string",
              customID: "string",
              type: "user_id",
            },
          ],
          environments: [
            "string",
          ],
          id: "38ttpCpzrQFTMKcqFKk02l:10.00:1",
          baseID: "38ttpCpzrQFTMKcqFKk02l",
        },
      ],
    },
  });

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

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { gatesUpdateRules } from "statsig/funcs/gatesUpdateRules.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 gatesUpdateRules(statsig, {
    id: "<id>",
    multiRuleUpdateDto: {
      rules: [
        {
          name: "All Conditions",
          passPercentage: 10,
          conditions: [
            {
            targetValue:     [
                  "0",
                ],
              operator: "any",
              field: "string",
              customID: "string",
              type: "user_id",
            },
          ],
          environments: [
            "string",
          ],
          id: "38ttpCpzrQFTMKcqFKk02l:10.00:1",
          baseID: "38ttpCpzrQFTMKcqFKk02l",
        },
      ],
    },
  });

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

  const { value: result } = res;

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

run();

Parameters

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

Errors

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

addRules

Add Multiple Gate Rule

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.addRules({
    id: "<id>",
    multiRuleDto: {
      rules: [
        {
          name: "<value>",
          passPercentage: 8990.96,
          conditions: [
            {
              type: "passes_gate",
            },
          ],
        },
      ],
    },
  });

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

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { gatesAddRules } from "statsig/funcs/gatesAddRules.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 gatesAddRules(statsig, {
    id: "<id>",
    multiRuleDto: {
      rules: [
        {
          name: "<value>",
          passPercentage: 7545.19,
          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.ConsoleV1GatesControllerGenMultiRuleAddRequest ✔️ 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.ConsoleV1GatesControllerGenMultiRuleAddResponseBody>

Errors

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

updateRule

Update all given rules. It does NOT create or delete if you add more rules and remove rules in the rules object.

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.updateRule({
    id: "<id>",
    ruleID: "<value>",
    ruleUpdateDto: {
      name: "All Conditions",
      passPercentage: 10,
      conditions: [
        {
        targetValue: "[\"35sClJFs8l0y5uRQhDwUDo\"]",
          operator: "any",
          type: "user_id",
        },
      ],
      environments: [
        "staging",
      ],
      id: "38ttpCpzrQFTMKcqFKk02l:10.00:1",
      baseID: "38ttpCpzrQFTMKcqFKk02l",
    },
  });

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

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { gatesUpdateRule } from "statsig/funcs/gatesUpdateRule.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 gatesUpdateRule(statsig, {
    id: "<id>",
    ruleID: "<value>",
    ruleUpdateDto: {
      name: "All Conditions",
      passPercentage: 10,
      conditions: [
        {
        targetValue: 35sClJFs8l0y5uRQhDwUDo,
          operator: "any",
          type: "user_id",
        },
      ],
      environments: [
        "staging",
      ],
      id: "38ttpCpzrQFTMKcqFKk02l:10.00:1",
      baseID: "38ttpCpzrQFTMKcqFKk02l",
    },
  });

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

  const { value: result } = res;

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

run();

Parameters

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

Errors

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

deleteRule

Delete Gate Rules

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.deleteRule({
    id: "<id>",
    ruleID: "<value>",
  });

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

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { gatesDeleteRule } from "statsig/funcs/gatesDeleteRule.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 gatesDeleteRule(statsig, {
    id: "<id>",
    ruleID: "<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.ConsoleV1GatesControllerGenRuleDeleteRequest ✔️ 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.ConsoleV1GatesControllerGenRuleDeleteResponseBody>

Errors

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

addRule

Add Gate Rule

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.addRule({
    id: "<id>",
    ruleDto: {
      name: "<value>",
      passPercentage: 9050.54,
      conditions: [
        {
          type: "time",
        },
      ],
    },
  });

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

run();

Standalone function

The standalone function version of this method:

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

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

  const { value: result } = res;

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

run();

Parameters

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

Errors

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

launch

Launch Gate

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.launch({
    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 { gatesLaunch } from "statsig/funcs/gatesLaunch.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 gatesLaunch(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.ConsoleV1GatesControllerGenLaunchRequest ✔️ 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.ConsoleV1GatesControllerGenLaunchResponseBody>

Errors

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

disable

Disable Gate

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.disable({
    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 { gatesDisable } from "statsig/funcs/gatesDisable.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 gatesDisable(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.ConsoleV1GatesControllerGenDisableRequest ✔️ 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.ConsoleV1GatesControllerGenDisableResponseBody>

Errors

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

enable

Enable Gate

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.enable({
    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 { gatesEnable } from "statsig/funcs/gatesEnable.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 gatesEnable(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.ConsoleV1GatesControllerGenEnableRequest ✔️ 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.ConsoleV1GatesControllerGenEnableResponseBody>

Errors

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

archive

Archive Gate

Example Usage

import { Statsig } from "statsig";

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

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

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

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { gatesArchive } from "statsig/funcs/gatesArchive.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 gatesArchive(statsig, {
    id: "<id>",
    archiveSchemaDto: {},
  });

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

  const { value: result } = res;

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

run();

Parameters

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

Errors

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

loadPulse

Load Pulse Gate

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.loadPulse({
    id: "<id>",
    echidnaGateLoadPulseQueryDto: {
      ruleId: "<value>",
    },
  });

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

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { gatesLoadPulse } from "statsig/funcs/gatesLoadPulse.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 gatesLoadPulse(statsig, {
    id: "<id>",
    echidnaGateLoadPulseQueryDto: {
      ruleId: "<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.ConsoleV1GatesControllerGenLoadPulseRequest ✔️ 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.ConsoleV1GatesControllerGenLoadPulseResponseBody>

Errors

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

getOverride

Get Gate Override

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.getOverride({
    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 { gatesGetOverride } from "statsig/funcs/gatesGetOverride.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 gatesGetOverride(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.ConsoleV1GateOverridesControllerGenReadRequest ✔️ 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.ConsoleV1GateOverridesControllerGenReadResponseBody>

Errors

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

updateOverride

Update Gate Overrides

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.updateOverride({
    id: "<id>",
  updateOverridesContractDto:     {
        passingUserIDs: [
          "user123",
          "user456",
        ],
        failingUserIDs: [
          "user789",
          "user012",
        ],
        passingCustomIDs: [
          "custom123",
        ],
        failingCustomIDs: [
          "custom456",
        ],
      },
  });

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

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { gatesUpdateOverride } from "statsig/funcs/gatesUpdateOverride.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 gatesUpdateOverride(statsig, {
    id: "<id>",
  updateOverridesContractDto:     {
        environmentOverrides: [
          {
            environment: "staging",
            unitID: "unit123",
            passingIDs: [
              "id1",
              "id2",
            ],
            failingIDs: [
              "id3",
              "id4",
            ],
          },
        ],
      },
  });

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

  const { value: result } = res;

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

run();

Parameters

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

Errors

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

addOverride

Add Gate Overrides

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.addOverride({
    id: "<id>",
  updateOverridesContractDto:     {
        passingUserIDs: [
          "user123",
          "user456",
        ],
        failingUserIDs: [
          "user789",
          "user012",
        ],
        passingCustomIDs: [
          "custom123",
        ],
        failingCustomIDs: [
          "custom456",
        ],
      },
  });

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

run();

Standalone function

The standalone function version of this method:

import { StatsigCore } from "statsig/core.js";
import { gatesAddOverride } from "statsig/funcs/gatesAddOverride.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 gatesAddOverride(statsig, {
    id: "<id>",
  updateOverridesContractDto:     {
        passingUserIDs: [
          "user123",
          "user456",
        ],
        failingUserIDs: [
          "user789",
          "user012",
        ],
        passingCustomIDs: [
          "custom123",
        ],
        failingCustomIDs: [
          "custom456",
        ],
      },
  });

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

  const { value: result } = res;

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

run();

Parameters

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

Errors

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

removeOverride

Delete Gate Overrides

Example Usage

import { Statsig } from "statsig";

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

async function run() {
  const result = await statsig.gates.removeOverride({
    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 { gatesRemoveOverride } from "statsig/funcs/gatesRemoveOverride.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 gatesRemoveOverride(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.ConsoleV1GateOverridesControllerGenRemoveRequest ✔️ 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.ConsoleV1GateOverridesControllerGenRemoveResponseBody>

Errors

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