New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@atlaskit/feature-gate-js-client

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atlaskit/feature-gate-js-client - npm Package Compare versions

Comparing version 4.24.0 to 4.25.0

18

CHANGELOG.md
# @atlaskit/feature-gate-js-client
## 4.25.0
### Minor Changes
- [#115504](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/115504)
[`3a98e35bee8a5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3a98e35bee8a5) -
Added loomAnonymousId, loomUserId and loomWorkspaceId
## 4.24.1
### Patch Changes
- [#115023](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/115023)
[`f317911486c79`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f317911486c79) -
The client now reads STATSIG_JS_LITE_LOCAL_OVERRIDES (the old local storage key) when initialising
itself, for better compatibility with code that's relying on deprecated and obsolete private
Statsig APIs
## 4.24.0

@@ -4,0 +22,0 @@

52

dist/cjs/client/Client.js

@@ -554,14 +554,14 @@ "use strict";

/**
* Returns the value of a given parameter in an experiment config.
*
* @template T
* @param {string} experimentName - The name of the experiment
* @param {string} parameterName - The name of the parameter to fetch from the experiment config
* @param {T} defaultValue - The value to serve if the experiment or parameter do not exist, or
* Returns the value of a given parameter in an experiment config.
*
* @template T
* @param {string} experimentName - The name of the experiment
* @param {string} parameterName - The name of the parameter to fetch from the experiment config
* @param {T} defaultValue - The value to serve if the experiment or parameter do not exist, or
* if the returned value does not match the expected type.
* @param {Object} options
* @param {boolean} options.fireExperimentExposure - Whether or not to fire the exposure event
* @param {Object} options
* @param {boolean} options.fireExperimentExposure - Whether or not to fire the exposure event
* for the experiment. Defaults to true. To log an exposure event manually at a later time, use
* {@link Client.manuallyLogExperimentExposure} (see [Statsig docs about manually logging exposures](https://docs.statsig.com/client/jsClientSDK#manual-exposures-))
* @param {function} options.typeGuard - A function that asserts that the return value has the
* @param {function} options.typeGuard - A function that asserts that the return value has the
* expected type. If this function returns false, then the default value will be returned

@@ -571,20 +571,20 @@ * instead. This can be set to protect your code from unexpected values being set remotely. By

* type.
* @returns The value of the parameter if the experiment and parameter both exist, otherwise the
* @returns The value of the parameter if the experiment and parameter both exist, otherwise the
* default value.
* @example
``` ts
type ValidColor = 'blue' | 'red' | 'yellow';
type ValidColorTypeCheck = (value: unknown) => value is ValidColor;
const isValidColor: ValidColorTypeCheck =
(value: unknown) => typeof value === 'string' && ['blue', 'red', 'yellow'].includes(value);
const buttonColor: ValidColor = client.getExperimentValue(
'example-experiment-name',
'backgroundColor',
'yellow',
{
typeGuard: isValidColor
}
);
```
*/
* @example
``` ts
type ValidColor = 'blue' | 'red' | 'yellow';
type ValidColorTypeCheck = (value: unknown) => value is ValidColor;
const isValidColor: ValidColorTypeCheck =
(value: unknown) => typeof value === 'string' && ['blue', 'red', 'yellow'].includes(value);
const buttonColor: ValidColor = client.getExperimentValue(
'example-experiment-name',
'backgroundColor',
'yellow',
{
typeGuard: isValidColor
}
);
```
*/
}, {

@@ -591,0 +591,0 @@ key: "getExperimentValue",

@@ -9,2 +9,3 @@ "use strict";

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

@@ -17,2 +18,3 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var LOCAL_STORAGE_KEY = exports.LOCAL_STORAGE_KEY = 'STATSIG_OVERRIDES';
var LEGACY_LOCAL_STORAGE_KEY = 'STATSIG_JS_LITE_LOCAL_OVERRIDES';
var makeEmptyStore = function makeEmptyStore() {

@@ -40,4 +42,4 @@ return {

return (0, _createClass2.default)(PersistentOverrideAdapter, [{
key: "initFromStoredOverrides",
value: function initFromStoredOverrides() {
key: "parseStoredOverrides",
value: function parseStoredOverrides(localStorageKey) {
try {

@@ -48,8 +50,43 @@ var json = window.localStorage.getItem(LOCAL_STORAGE_KEY);

}
this._overrides = JSON.parse(json);
return JSON.parse(json);
} catch (_unused) {
this._overrides = makeEmptyStore();
return makeEmptyStore();
}
}
}, {
key: "mergeOverrides",
value: function mergeOverrides() {
var merged = makeEmptyStore();
for (var _len = arguments.length, allOverrides = new Array(_len), _key = 0; _key < _len; _key++) {
allOverrides[_key] = arguments[_key];
}
for (var _i = 0, _allOverrides = allOverrides; _i < _allOverrides.length; _i++) {
var overrides = _allOverrides[_i];
for (var _i2 = 0, _Object$entries = Object.entries(overrides.gates); _i2 < _Object$entries.length; _i2++) {
var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i2], 2),
name = _Object$entries$_i[0],
value = _Object$entries$_i[1];
merged.gates[name] = value;
}
for (var _i3 = 0, _Object$entries2 = Object.entries(overrides.configs); _i3 < _Object$entries2.length; _i3++) {
var _Object$entries2$_i = (0, _slicedToArray2.default)(_Object$entries2[_i3], 2),
_name = _Object$entries2$_i[0],
_value = _Object$entries2$_i[1];
merged.configs[_name] = _value;
}
for (var _i4 = 0, _Object$entries3 = Object.entries(overrides.layers); _i4 < _Object$entries3.length; _i4++) {
var _Object$entries3$_i = (0, _slicedToArray2.default)(_Object$entries3[_i4], 2),
_name2 = _Object$entries3$_i[0],
_value2 = _Object$entries3$_i[1];
merged.layers[_name2] = _value2;
}
}
return merged;
}
}, {
key: "initFromStoredOverrides",
value: function initFromStoredOverrides() {
this._overrides = this.mergeOverrides(this.parseStoredOverrides(LEGACY_LOCAL_STORAGE_KEY), this.parseStoredOverrides(LOCAL_STORAGE_KEY));
}
}, {
key: "saveOverrides",

@@ -62,3 +99,17 @@ value: function saveOverrides() {

value: function getOverrides() {
return this._overrides;
return Object.fromEntries(Object.entries(this._overrides).map(function (_ref) {
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
key = _ref2[0],
container = _ref2[1];
var record = {};
for (var _i5 = 0, _Object$entries4 = Object.entries(container); _i5 < _Object$entries4.length; _i5++) {
var _Object$entries4$_i = (0, _slicedToArray2.default)(_Object$entries4[_i5], 2),
name = _Object$entries4$_i[0],
value = _Object$entries4$_i[1];
if (Object.prototype.hasOwnProperty.call(container, (0, _clientCore._DJB2)(name))) {
record[name] = value;
}
}
return [key, record];
}));
}

@@ -68,3 +119,16 @@ }, {

value: function setOverrides(overrides) {
this._overrides = _objectSpread(_objectSpread({}, makeEmptyStore()), overrides);
var newOverrides = _objectSpread(_objectSpread({}, makeEmptyStore()), overrides);
for (var _i6 = 0, _Object$values = Object.values(newOverrides); _i6 < _Object$values.length; _i6++) {
var container = _Object$values[_i6];
for (var _i7 = 0, _Object$entries5 = Object.entries(container); _i7 < _Object$entries5.length; _i7++) {
var _Object$entries5$_i = (0, _slicedToArray2.default)(_Object$entries5[_i7], 2),
name = _Object$entries5$_i[0],
value = _Object$entries5$_i[1];
var hash = (0, _clientCore._DJB2)(name);
if (!Object.prototype.hasOwnProperty.call(container, hash)) {
container[hash] = value;
}
}
}
this._overrides = newOverrides;
this.saveOverrides();

@@ -154,7 +218,2 @@ }

}, {
key: "getAllOverrides",
value: function getAllOverrides() {
return JSON.parse(JSON.stringify(this._overrides));
}
}, {
key: "removeAllOverrides",

@@ -161,0 +220,0 @@ value: function removeAllOverrides() {

@@ -8,2 +8,2 @@ "use strict";

/// <reference types="node" />
var CLIENT_VERSION = exports.CLIENT_VERSION = "4.24.0";
var CLIENT_VERSION = exports.CLIENT_VERSION = "4.25.0";

@@ -379,14 +379,14 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";

/**
* Returns the value of a given parameter in an experiment config.
*
* @template T
* @param {string} experimentName - The name of the experiment
* @param {string} parameterName - The name of the parameter to fetch from the experiment config
* @param {T} defaultValue - The value to serve if the experiment or parameter do not exist, or
* Returns the value of a given parameter in an experiment config.
*
* @template T
* @param {string} experimentName - The name of the experiment
* @param {string} parameterName - The name of the parameter to fetch from the experiment config
* @param {T} defaultValue - The value to serve if the experiment or parameter do not exist, or
* if the returned value does not match the expected type.
* @param {Object} options
* @param {boolean} options.fireExperimentExposure - Whether or not to fire the exposure event
* @param {Object} options
* @param {boolean} options.fireExperimentExposure - Whether or not to fire the exposure event
* for the experiment. Defaults to true. To log an exposure event manually at a later time, use
* {@link Client.manuallyLogExperimentExposure} (see [Statsig docs about manually logging exposures](https://docs.statsig.com/client/jsClientSDK#manual-exposures-))
* @param {function} options.typeGuard - A function that asserts that the return value has the
* @param {function} options.typeGuard - A function that asserts that the return value has the
* expected type. If this function returns false, then the default value will be returned

@@ -396,20 +396,20 @@ * instead. This can be set to protect your code from unexpected values being set remotely. By

* type.
* @returns The value of the parameter if the experiment and parameter both exist, otherwise the
* @returns The value of the parameter if the experiment and parameter both exist, otherwise the
* default value.
* @example
``` ts
type ValidColor = 'blue' | 'red' | 'yellow';
type ValidColorTypeCheck = (value: unknown) => value is ValidColor;
const isValidColor: ValidColorTypeCheck =
(value: unknown) => typeof value === 'string' && ['blue', 'red', 'yellow'].includes(value);
const buttonColor: ValidColor = client.getExperimentValue(
'example-experiment-name',
'backgroundColor',
'yellow',
{
typeGuard: isValidColor
}
);
```
*/
* @example
``` ts
type ValidColor = 'blue' | 'red' | 'yellow';
type ValidColorTypeCheck = (value: unknown) => value is ValidColor;
const isValidColor: ValidColorTypeCheck =
(value: unknown) => typeof value === 'string' && ['blue', 'red', 'yellow'].includes(value);
const buttonColor: ValidColor = client.getExperimentValue(
'example-experiment-name',
'backgroundColor',
'yellow',
{
typeGuard: isValidColor
}
);
```
*/
getExperimentValue(experimentName, parameterName, defaultValue, options = {}) {

@@ -416,0 +416,0 @@ const experiment = this.getExperiment(experimentName, options);

import { _DJB2, _makeTypedGet } from '@statsig/client-core';
const LOCAL_OVERRIDE_REASON = 'LocalOverride:Recognized';
export const LOCAL_STORAGE_KEY = 'STATSIG_OVERRIDES';
const LEGACY_LOCAL_STORAGE_KEY = 'STATSIG_JS_LITE_LOCAL_OVERRIDES';
const makeEmptyStore = () => ({

@@ -22,3 +23,3 @@ gates: {},

}
initFromStoredOverrides() {
parseStoredOverrides(localStorageKey) {
try {

@@ -29,7 +30,25 @@ const json = window.localStorage.getItem(LOCAL_STORAGE_KEY);

}
this._overrides = JSON.parse(json);
return JSON.parse(json);
} catch {
this._overrides = makeEmptyStore();
return makeEmptyStore();
}
}
mergeOverrides(...allOverrides) {
const merged = makeEmptyStore();
for (const overrides of allOverrides) {
for (const [name, value] of Object.entries(overrides.gates)) {
merged.gates[name] = value;
}
for (const [name, value] of Object.entries(overrides.configs)) {
merged.configs[name] = value;
}
for (const [name, value] of Object.entries(overrides.layers)) {
merged.layers[name] = value;
}
}
return merged;
}
initFromStoredOverrides() {
this._overrides = this.mergeOverrides(this.parseStoredOverrides(LEGACY_LOCAL_STORAGE_KEY), this.parseStoredOverrides(LOCAL_STORAGE_KEY));
}
saveOverrides() {

@@ -39,9 +58,26 @@ window.localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(this._overrides));

getOverrides() {
return this._overrides;
return Object.fromEntries(Object.entries(this._overrides).map(([key, container]) => {
const record = {};
for (const [name, value] of Object.entries(container)) {
if (Object.prototype.hasOwnProperty.call(container, _DJB2(name))) {
record[name] = value;
}
}
return [key, record];
}));
}
setOverrides(overrides) {
this._overrides = {
const newOverrides = {
...makeEmptyStore(),
...overrides
};
for (const container of Object.values(newOverrides)) {
for (const [name, value] of Object.entries(container)) {
const hash = _DJB2(name);
if (!Object.prototype.hasOwnProperty.call(container, hash)) {
container[hash] = value;
}
}
}
this._overrides = newOverrides;
this.saveOverrides();

@@ -110,5 +146,2 @@ }

}
getAllOverrides() {
return JSON.parse(JSON.stringify(this._overrides));
}
removeAllOverrides() {

@@ -115,0 +148,0 @@ this._overrides = makeEmptyStore();

/// <reference types="node" />
export const CLIENT_VERSION = "4.24.0";
export const CLIENT_VERSION = "4.25.0";

@@ -547,14 +547,14 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";

/**
* Returns the value of a given parameter in an experiment config.
*
* @template T
* @param {string} experimentName - The name of the experiment
* @param {string} parameterName - The name of the parameter to fetch from the experiment config
* @param {T} defaultValue - The value to serve if the experiment or parameter do not exist, or
* Returns the value of a given parameter in an experiment config.
*
* @template T
* @param {string} experimentName - The name of the experiment
* @param {string} parameterName - The name of the parameter to fetch from the experiment config
* @param {T} defaultValue - The value to serve if the experiment or parameter do not exist, or
* if the returned value does not match the expected type.
* @param {Object} options
* @param {boolean} options.fireExperimentExposure - Whether or not to fire the exposure event
* @param {Object} options
* @param {boolean} options.fireExperimentExposure - Whether or not to fire the exposure event
* for the experiment. Defaults to true. To log an exposure event manually at a later time, use
* {@link Client.manuallyLogExperimentExposure} (see [Statsig docs about manually logging exposures](https://docs.statsig.com/client/jsClientSDK#manual-exposures-))
* @param {function} options.typeGuard - A function that asserts that the return value has the
* @param {function} options.typeGuard - A function that asserts that the return value has the
* expected type. If this function returns false, then the default value will be returned

@@ -564,20 +564,20 @@ * instead. This can be set to protect your code from unexpected values being set remotely. By

* type.
* @returns The value of the parameter if the experiment and parameter both exist, otherwise the
* @returns The value of the parameter if the experiment and parameter both exist, otherwise the
* default value.
* @example
``` ts
type ValidColor = 'blue' | 'red' | 'yellow';
type ValidColorTypeCheck = (value: unknown) => value is ValidColor;
const isValidColor: ValidColorTypeCheck =
(value: unknown) => typeof value === 'string' && ['blue', 'red', 'yellow'].includes(value);
const buttonColor: ValidColor = client.getExperimentValue(
'example-experiment-name',
'backgroundColor',
'yellow',
{
typeGuard: isValidColor
}
);
```
*/
* @example
``` ts
type ValidColor = 'blue' | 'red' | 'yellow';
type ValidColorTypeCheck = (value: unknown) => value is ValidColor;
const isValidColor: ValidColorTypeCheck =
(value: unknown) => typeof value === 'string' && ['blue', 'red', 'yellow'].includes(value);
const buttonColor: ValidColor = client.getExperimentValue(
'example-experiment-name',
'backgroundColor',
'yellow',
{
typeGuard: isValidColor
}
);
```
*/
}, {

@@ -584,0 +584,0 @@ key: "getExperimentValue",

import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";

@@ -9,2 +10,3 @@ import _createClass from "@babel/runtime/helpers/createClass";

export var LOCAL_STORAGE_KEY = 'STATSIG_OVERRIDES';
var LEGACY_LOCAL_STORAGE_KEY = 'STATSIG_JS_LITE_LOCAL_OVERRIDES';
var makeEmptyStore = function makeEmptyStore() {

@@ -32,4 +34,4 @@ return {

return _createClass(PersistentOverrideAdapter, [{
key: "initFromStoredOverrides",
value: function initFromStoredOverrides() {
key: "parseStoredOverrides",
value: function parseStoredOverrides(localStorageKey) {
try {

@@ -40,8 +42,43 @@ var json = window.localStorage.getItem(LOCAL_STORAGE_KEY);

}
this._overrides = JSON.parse(json);
return JSON.parse(json);
} catch (_unused) {
this._overrides = makeEmptyStore();
return makeEmptyStore();
}
}
}, {
key: "mergeOverrides",
value: function mergeOverrides() {
var merged = makeEmptyStore();
for (var _len = arguments.length, allOverrides = new Array(_len), _key = 0; _key < _len; _key++) {
allOverrides[_key] = arguments[_key];
}
for (var _i = 0, _allOverrides = allOverrides; _i < _allOverrides.length; _i++) {
var overrides = _allOverrides[_i];
for (var _i2 = 0, _Object$entries = Object.entries(overrides.gates); _i2 < _Object$entries.length; _i2++) {
var _Object$entries$_i = _slicedToArray(_Object$entries[_i2], 2),
name = _Object$entries$_i[0],
value = _Object$entries$_i[1];
merged.gates[name] = value;
}
for (var _i3 = 0, _Object$entries2 = Object.entries(overrides.configs); _i3 < _Object$entries2.length; _i3++) {
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i3], 2),
_name = _Object$entries2$_i[0],
_value = _Object$entries2$_i[1];
merged.configs[_name] = _value;
}
for (var _i4 = 0, _Object$entries3 = Object.entries(overrides.layers); _i4 < _Object$entries3.length; _i4++) {
var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i4], 2),
_name2 = _Object$entries3$_i[0],
_value2 = _Object$entries3$_i[1];
merged.layers[_name2] = _value2;
}
}
return merged;
}
}, {
key: "initFromStoredOverrides",
value: function initFromStoredOverrides() {
this._overrides = this.mergeOverrides(this.parseStoredOverrides(LEGACY_LOCAL_STORAGE_KEY), this.parseStoredOverrides(LOCAL_STORAGE_KEY));
}
}, {
key: "saveOverrides",

@@ -54,3 +91,17 @@ value: function saveOverrides() {

value: function getOverrides() {
return this._overrides;
return Object.fromEntries(Object.entries(this._overrides).map(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
key = _ref2[0],
container = _ref2[1];
var record = {};
for (var _i5 = 0, _Object$entries4 = Object.entries(container); _i5 < _Object$entries4.length; _i5++) {
var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i5], 2),
name = _Object$entries4$_i[0],
value = _Object$entries4$_i[1];
if (Object.prototype.hasOwnProperty.call(container, _DJB2(name))) {
record[name] = value;
}
}
return [key, record];
}));
}

@@ -60,3 +111,16 @@ }, {

value: function setOverrides(overrides) {
this._overrides = _objectSpread(_objectSpread({}, makeEmptyStore()), overrides);
var newOverrides = _objectSpread(_objectSpread({}, makeEmptyStore()), overrides);
for (var _i6 = 0, _Object$values = Object.values(newOverrides); _i6 < _Object$values.length; _i6++) {
var container = _Object$values[_i6];
for (var _i7 = 0, _Object$entries5 = Object.entries(container); _i7 < _Object$entries5.length; _i7++) {
var _Object$entries5$_i = _slicedToArray(_Object$entries5[_i7], 2),
name = _Object$entries5$_i[0],
value = _Object$entries5$_i[1];
var hash = _DJB2(name);
if (!Object.prototype.hasOwnProperty.call(container, hash)) {
container[hash] = value;
}
}
}
this._overrides = newOverrides;
this.saveOverrides();

@@ -146,7 +210,2 @@ }

}, {
key: "getAllOverrides",
value: function getAllOverrides() {
return JSON.parse(JSON.stringify(this._overrides));
}
}, {
key: "removeAllOverrides",

@@ -153,0 +212,0 @@ value: function removeAllOverrides() {

/// <reference types="node" />
export var CLIENT_VERSION = "4.24.0";
export var CLIENT_VERSION = "4.25.0";

@@ -131,14 +131,14 @@ import { StatsigClient } from '@statsig/js-client';

/**
* Returns the value of a given parameter in an experiment config.
*
* @template T
* @param {string} experimentName - The name of the experiment
* @param {string} parameterName - The name of the parameter to fetch from the experiment config
* @param {T} defaultValue - The value to serve if the experiment or parameter do not exist, or
* Returns the value of a given parameter in an experiment config.
*
* @template T
* @param {string} experimentName - The name of the experiment
* @param {string} parameterName - The name of the parameter to fetch from the experiment config
* @param {T} defaultValue - The value to serve if the experiment or parameter do not exist, or
* if the returned value does not match the expected type.
* @param {Object} options
* @param {boolean} options.fireExperimentExposure - Whether or not to fire the exposure event
* @param {Object} options
* @param {boolean} options.fireExperimentExposure - Whether or not to fire the exposure event
* for the experiment. Defaults to true. To log an exposure event manually at a later time, use
* {@link Client.manuallyLogExperimentExposure} (see [Statsig docs about manually logging exposures](https://docs.statsig.com/client/jsClientSDK#manual-exposures-))
* @param {function} options.typeGuard - A function that asserts that the return value has the
* @param {function} options.typeGuard - A function that asserts that the return value has the
* expected type. If this function returns false, then the default value will be returned

@@ -148,22 +148,22 @@ * instead. This can be set to protect your code from unexpected values being set remotely. By

* type.
* @returns The value of the parameter if the experiment and parameter both exist, otherwise the
* @returns The value of the parameter if the experiment and parameter both exist, otherwise the
* default value.
* @example
``` ts
type ValidColor = 'blue' | 'red' | 'yellow';
type ValidColorTypeCheck = (value: unknown) => value is ValidColor;
* @example
``` ts
type ValidColor = 'blue' | 'red' | 'yellow';
type ValidColorTypeCheck = (value: unknown) => value is ValidColor;
const isValidColor: ValidColorTypeCheck =
(value: unknown) => typeof value === 'string' && ['blue', 'red', 'yellow'].includes(value);
const isValidColor: ValidColorTypeCheck =
(value: unknown) => typeof value === 'string' && ['blue', 'red', 'yellow'].includes(value);
const buttonColor: ValidColor = client.getExperimentValue(
'example-experiment-name',
'backgroundColor',
'yellow',
{
typeGuard: isValidColor
}
);
```
*/
const buttonColor: ValidColor = client.getExperimentValue(
'example-experiment-name',
'backgroundColor',
'yellow',
{
typeGuard: isValidColor
}
);
```
*/
getExperimentValue<T>(experimentName: string, parameterName: string, defaultValue: T, options?: GetExperimentValueOptions<T>): T;

@@ -170,0 +170,0 @@ /**

@@ -19,3 +19,5 @@ import { type DynamicConfig, type Experiment, type FeatureGate, type Layer, type OverrideAdapter, type StatsigUser } from '@statsig/client-core';

constructor();
initFromStoredOverrides(): LocalOverrides | undefined;
private parseStoredOverrides;
private mergeOverrides;
initFromStoredOverrides(): void;
saveOverrides(): void;

@@ -35,3 +37,2 @@ getOverrides(): LocalOverrides;

removeLayerOverride(name: string): void;
getAllOverrides(): LocalOverrides;
removeAllOverrides(): void;

@@ -38,0 +39,0 @@ getLayerOverride(current: Layer, _user: StatsigUser): Layer | null;

@@ -16,2 +16,5 @@ import type { StatsigOptions as NewStatsigOptions } from '@statsig/js-client';

intercomConversationId?: string;
loomAnonymousId?: string;
loomUserId?: string;
loomWorkspaceId?: string;
marketplaceAnonymousId?: string;

@@ -18,0 +21,0 @@ marketplacePartnerId?: string;

@@ -131,14 +131,14 @@ import { StatsigClient } from '@statsig/js-client';

/**
* Returns the value of a given parameter in an experiment config.
*
* @template T
* @param {string} experimentName - The name of the experiment
* @param {string} parameterName - The name of the parameter to fetch from the experiment config
* @param {T} defaultValue - The value to serve if the experiment or parameter do not exist, or
* Returns the value of a given parameter in an experiment config.
*
* @template T
* @param {string} experimentName - The name of the experiment
* @param {string} parameterName - The name of the parameter to fetch from the experiment config
* @param {T} defaultValue - The value to serve if the experiment or parameter do not exist, or
* if the returned value does not match the expected type.
* @param {Object} options
* @param {boolean} options.fireExperimentExposure - Whether or not to fire the exposure event
* @param {Object} options
* @param {boolean} options.fireExperimentExposure - Whether or not to fire the exposure event
* for the experiment. Defaults to true. To log an exposure event manually at a later time, use
* {@link Client.manuallyLogExperimentExposure} (see [Statsig docs about manually logging exposures](https://docs.statsig.com/client/jsClientSDK#manual-exposures-))
* @param {function} options.typeGuard - A function that asserts that the return value has the
* @param {function} options.typeGuard - A function that asserts that the return value has the
* expected type. If this function returns false, then the default value will be returned

@@ -148,22 +148,22 @@ * instead. This can be set to protect your code from unexpected values being set remotely. By

* type.
* @returns The value of the parameter if the experiment and parameter both exist, otherwise the
* @returns The value of the parameter if the experiment and parameter both exist, otherwise the
* default value.
* @example
``` ts
type ValidColor = 'blue' | 'red' | 'yellow';
type ValidColorTypeCheck = (value: unknown) => value is ValidColor;
* @example
``` ts
type ValidColor = 'blue' | 'red' | 'yellow';
type ValidColorTypeCheck = (value: unknown) => value is ValidColor;
const isValidColor: ValidColorTypeCheck =
(value: unknown) => typeof value === 'string' && ['blue', 'red', 'yellow'].includes(value);
const isValidColor: ValidColorTypeCheck =
(value: unknown) => typeof value === 'string' && ['blue', 'red', 'yellow'].includes(value);
const buttonColor: ValidColor = client.getExperimentValue(
'example-experiment-name',
'backgroundColor',
'yellow',
{
typeGuard: isValidColor
}
);
```
*/
const buttonColor: ValidColor = client.getExperimentValue(
'example-experiment-name',
'backgroundColor',
'yellow',
{
typeGuard: isValidColor
}
);
```
*/
getExperimentValue<T>(experimentName: string, parameterName: string, defaultValue: T, options?: GetExperimentValueOptions<T>): T;

@@ -170,0 +170,0 @@ /**

@@ -19,3 +19,5 @@ import { type DynamicConfig, type Experiment, type FeatureGate, type Layer, type OverrideAdapter, type StatsigUser } from '@statsig/client-core';

constructor();
initFromStoredOverrides(): LocalOverrides | undefined;
private parseStoredOverrides;
private mergeOverrides;
initFromStoredOverrides(): void;
saveOverrides(): void;

@@ -35,3 +37,2 @@ getOverrides(): LocalOverrides;

removeLayerOverride(name: string): void;
getAllOverrides(): LocalOverrides;
removeAllOverrides(): void;

@@ -38,0 +39,0 @@ getLayerOverride(current: Layer, _user: StatsigUser): Layer | null;

@@ -16,2 +16,5 @@ import type { StatsigOptions as NewStatsigOptions } from '@statsig/js-client';

intercomConversationId?: string;
loomAnonymousId?: string;
loomUserId?: string;
loomWorkspaceId?: string;
marketplaceAnonymousId?: string;

@@ -18,0 +21,0 @@ marketplacePartnerId?: string;

{
"name": "@atlaskit/feature-gate-js-client",
"version": "4.24.0",
"version": "4.25.0",
"description": "Atlassians wrapper for the Statsig js-lite client.",

@@ -5,0 +5,0 @@ "author": "Atlassian Pty Ltd",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc