@atlaskit/tmp-editor-statsig 148.0.0 → 149.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/dist/cjs/create-boolean-experiment.js +20 -0
- package/dist/cjs/{experiment-builders.js → create-multivariate-experiment.js} +2 -13
- package/dist/cjs/editor-experiment.js +107 -0
- package/dist/cjs/exp-val-no-exposure.js +15 -0
- package/dist/cjs/exp-val.js +31 -0
- package/dist/cjs/expVal.js +29 -49
- package/dist/cjs/experiments-config.js +298 -306
- package/dist/cjs/experiments.js +12 -127
- package/dist/cjs/is-boolean.js +9 -0
- package/dist/cjs/one-of.js +20 -0
- package/dist/cjs/type-guards.js +1 -27
- package/dist/cjs/unstable-editor-experiment-param.js +37 -0
- package/dist/es2019/create-boolean-experiment.js +11 -0
- package/dist/es2019/{experiment-builders.js → create-multivariate-experiment.js} +1 -12
- package/dist/es2019/editor-experiment.js +100 -0
- package/dist/es2019/exp-val-no-exposure.js +9 -0
- package/dist/es2019/exp-val.js +26 -0
- package/dist/es2019/expVal.js +11 -44
- package/dist/es2019/experiments-config.js +3 -11
- package/dist/es2019/experiments.js +5 -119
- package/dist/es2019/is-boolean.js +3 -0
- package/dist/es2019/one-of.js +14 -0
- package/dist/es2019/type-guards.js +0 -20
- package/dist/es2019/unstable-editor-experiment-param.js +31 -0
- package/dist/esm/create-boolean-experiment.js +13 -0
- package/dist/esm/{experiment-builders.js → create-multivariate-experiment.js} +1 -11
- package/dist/esm/editor-experiment.js +101 -0
- package/dist/esm/exp-val-no-exposure.js +9 -0
- package/dist/esm/exp-val.js +26 -0
- package/dist/esm/expVal.js +11 -44
- package/dist/esm/experiments-config.js +3 -11
- package/dist/esm/experiments.js +5 -120
- package/dist/esm/is-boolean.js +3 -0
- package/dist/esm/one-of.js +14 -0
- package/dist/esm/type-guards.js +0 -20
- package/dist/esm/unstable-editor-experiment-param.js +31 -0
- package/dist/types/create-boolean-experiment.d.ts +11 -0
- package/dist/types/create-multivariate-experiment.d.ts +11 -0
- package/dist/types/editor-experiment.d.ts +52 -0
- package/dist/types/exp-val-no-exposure.d.ts +2 -0
- package/dist/types/exp-val.d.ts +18 -0
- package/dist/types/expVal.d.ts +11 -26
- package/dist/types/experiments-config.d.ts +1 -7
- package/dist/types/experiments.d.ts +4 -63
- package/dist/types/is-boolean.d.ts +1 -0
- package/dist/types/one-of.d.ts +1 -0
- package/dist/types/type-guards.d.ts +8 -2
- package/dist/types/unstable-editor-experiment-param.d.ts +15 -0
- package/package.json +1 -1
- package/dist/types/experiment-builders.d.ts +0 -21
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var _process, _process$env, _process2, _process2$env;
|
|
2
|
+
const IS_TESTING_ENV = typeof process !== 'undefined' && (((_process = process) === null || _process === void 0 ? void 0 : (_process$env = _process.env) === null || _process$env === void 0 ? void 0 : _process$env.NODE_ENV) === 'test' || ((_process2 = process) === null || _process2 === void 0 ? void 0 : (_process2$env = _process2.env) === null || _process2$env === void 0 ? void 0 : _process2$env.JEST_WORKER_ID) !== undefined);
|
|
3
|
+
export function oneOf(values) {
|
|
4
|
+
function typeGuard(value) {
|
|
5
|
+
return values.includes(value);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* This is used by test utils to get the variants when running describe.each
|
|
9
|
+
*/
|
|
10
|
+
if (IS_TESTING_ENV) {
|
|
11
|
+
typeGuard.values = values;
|
|
12
|
+
}
|
|
13
|
+
return typeGuard;
|
|
14
|
+
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
var _process, _process$env, _process2, _process2$env;
|
|
2
|
-
export function isBoolean(value) {
|
|
3
|
-
return typeof value === 'boolean';
|
|
4
|
-
}
|
|
5
|
-
export function oneOf(values) {
|
|
6
|
-
function typeGuard(value) {
|
|
7
|
-
return values.includes(value);
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* This is used by test utils to get the variants when running describe.each
|
|
11
|
-
*/
|
|
12
|
-
if (IS_TESTING_ENV) {
|
|
13
|
-
typeGuard.values = values;
|
|
14
|
-
}
|
|
15
|
-
return typeGuard;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
|
|
20
|
-
const IS_TESTING_ENV = typeof process !== 'undefined' && (((_process = process) === null || _process === void 0 ? void 0 : (_process$env = _process.env) === null || _process$env === void 0 ? void 0 : _process$env.NODE_ENV) === 'test' || ((_process2 = process) === null || _process2 === void 0 ? void 0 : (_process2$env = _process2.env) === null || _process2$env === void 0 ? void 0 : _process2$env.JEST_WORKER_ID) !== undefined);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
2
|
+
// Entry file in package.json
|
|
3
|
+
|
|
4
|
+
import FeatureGates from '@atlaskit/feature-gate-js-client/feature-gates';
|
|
5
|
+
import { _paramOverrides } from './setup';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @warning This currently lacks type safety on the param names and return values
|
|
11
|
+
* and has limited associated test tooling.
|
|
12
|
+
*
|
|
13
|
+
* It also only works for experiments where the key matches the productKey used.
|
|
14
|
+
*
|
|
15
|
+
* The typeguard and default value is also expected to move to the experiment config
|
|
16
|
+
*/
|
|
17
|
+
export function unstable_editorExperimentParam(experimentName, paramName, options) {
|
|
18
|
+
var _paramOverrides$exper, _options$exposure;
|
|
19
|
+
if (((_paramOverrides$exper = _paramOverrides[experimentName]) === null || _paramOverrides$exper === void 0 ? void 0 : _paramOverrides$exper[paramName]) !== undefined) {
|
|
20
|
+
// This will be hit in the case of a test setting an override
|
|
21
|
+
|
|
22
|
+
return _paramOverrides[experimentName][paramName];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line @atlaskit/platform/use-recommended-utils
|
|
26
|
+
const experimentValue = FeatureGates.getExperimentValue(experimentName, paramName, options.defaultValue, {
|
|
27
|
+
typeGuard: options.typeGuard,
|
|
28
|
+
fireExperimentExposure: (_options$exposure = options.exposure) !== null && _options$exposure !== void 0 ? _options$exposure : false
|
|
29
|
+
});
|
|
30
|
+
return experimentValue;
|
|
31
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import { isBoolean } from './is-boolean';
|
|
5
|
+
/**
|
|
6
|
+
* Helper to create a boolean experiment configuration
|
|
7
|
+
*/
|
|
8
|
+
export function createBooleanExperiment(config) {
|
|
9
|
+
return _objectSpread(_objectSpread({}, config), {}, {
|
|
10
|
+
typeGuard: isBoolean,
|
|
11
|
+
defaultValue: config.defaultValue
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -2,17 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
import {
|
|
6
|
-
/**
|
|
7
|
-
* Helper to create a boolean experiment configuration
|
|
8
|
-
*/
|
|
9
|
-
export function createBooleanExperiment(config) {
|
|
10
|
-
return _objectSpread(_objectSpread({}, config), {}, {
|
|
11
|
-
typeGuard: isBoolean,
|
|
12
|
-
defaultValue: config.defaultValue
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
5
|
+
import { oneOf } from './one-of';
|
|
16
6
|
/**
|
|
17
7
|
* Helper to create a multivariate experiment configuration
|
|
18
8
|
*/
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
2
|
+
// Entry file in package.json
|
|
3
|
+
|
|
4
|
+
import FeatureGates from '@atlaskit/feature-gate-js-client/feature-gates';
|
|
5
|
+
import { addFeatureFlagAccessed } from '@atlaskit/react-ufo/feature-flags-accessed';
|
|
6
|
+
import { editorExperimentsConfig } from './experiments-config';
|
|
7
|
+
import { _overrides, _product } from './setup';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Check the value of an editor experiment.
|
|
11
|
+
*
|
|
12
|
+
* Note: By default this will not fire an [exposure event](https://hello.atlassian.net/wiki/spaces/~732385844/pages/3187295823/Exposure+Events+101).
|
|
13
|
+
*
|
|
14
|
+
* You need explicitly call it using the exposure property when you need an exposure event to be fired (all experiments should fire exposure events).
|
|
15
|
+
*
|
|
16
|
+
* @example Boolean experiment
|
|
17
|
+
* ```ts
|
|
18
|
+
* if (editorExperiment('example-boolean', true)) {
|
|
19
|
+
* // Run code for on variant
|
|
20
|
+
* } else {
|
|
21
|
+
* // Run code for off variant
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example Multivariate experiment
|
|
26
|
+
* ```ts
|
|
27
|
+
* switch (true) {
|
|
28
|
+
* case editorExperiment('example-multivariate', 'one'):
|
|
29
|
+
* // Run code for variant one
|
|
30
|
+
* break;
|
|
31
|
+
* case editorExperiment('example-multivariate', 'two'):
|
|
32
|
+
* // Run code for variant two
|
|
33
|
+
* break;
|
|
34
|
+
* case editorExperiment('example-multivariate', 'three'):
|
|
35
|
+
* // Run code for variant three
|
|
36
|
+
* break;
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
*```
|
|
40
|
+
|
|
41
|
+
@example Experiment with exposure event
|
|
42
|
+
* ```ts
|
|
43
|
+
* // Inside feature surface where either the control or variant should be shown
|
|
44
|
+
* if (editorExperiment('example-boolean', true, { exposure: true })) {
|
|
45
|
+
* // Run code for on variant
|
|
46
|
+
* } else {
|
|
47
|
+
* // Run code for off variant
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @private
|
|
52
|
+
* @deprecated This utility is deprecated in favour of using `expValEquals` from `@atlaskit/tmp-editor-statsig/exp-val-equals`.
|
|
53
|
+
* ExpValEquals fires exposure events by default preventing cases when consumers of exitorExperiment forget to pass the `exposure` option.
|
|
54
|
+
* It also closely aligns with similar utilities in other Atlassian products.
|
|
55
|
+
* For no exposure option use `expValEqualsNoExposure` from `@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure`.
|
|
56
|
+
*/
|
|
57
|
+
export function editorExperiment(experimentName, expectedExperimentValue) {
|
|
58
|
+
var _experimentConfig$pro;
|
|
59
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
60
|
+
exposure: false
|
|
61
|
+
};
|
|
62
|
+
var experimentConfig = editorExperimentsConfig[experimentName];
|
|
63
|
+
if (_overrides[experimentName] !== undefined) {
|
|
64
|
+
// This will be hit in the case of a test setting an override
|
|
65
|
+
return _overrides[experimentName] === expectedExperimentValue;
|
|
66
|
+
}
|
|
67
|
+
if (experimentConfig === undefined) {
|
|
68
|
+
// Warning! If a product is improperly configured (ie. their editor packages are misaligned)
|
|
69
|
+
// it can cause the editor to crash here or if the experiment does not exist.
|
|
70
|
+
// We will definitely crash via any code path later in this function - this just makes the error explicit and clear.
|
|
71
|
+
throw new Error("Editor experiment configuration is not defined ".concat(experimentName, ". Likely the experiment does not exist or editor package versions are misaligned"));
|
|
72
|
+
}
|
|
73
|
+
if (!_product) {
|
|
74
|
+
// This will be hit in the case of a product not having setup the editor experiment tooling
|
|
75
|
+
return experimentConfig.defaultValue === expectedExperimentValue;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Typescript is complaining here about accessing the productKeys property
|
|
79
|
+
// Ignored via go/ees005
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
81
|
+
var experimentKey = experimentConfig === null || experimentConfig === void 0 || (_experimentConfig$pro = experimentConfig.productKeys) === null || _experimentConfig$pro === void 0 ? void 0 : _experimentConfig$pro[_product];
|
|
82
|
+
if (!experimentKey) {
|
|
83
|
+
var _editorExperimentsCon;
|
|
84
|
+
// This will be hit in the case of an experiment not being set up for the product
|
|
85
|
+
return ((_editorExperimentsCon = editorExperimentsConfig[experimentName]) === null || _editorExperimentsCon === void 0 ? void 0 : _editorExperimentsCon.defaultValue) === expectedExperimentValue;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// eslint-disable-next-line @atlaskit/platform/use-recommended-utils
|
|
89
|
+
var experimentValue = FeatureGates.getExperimentValue(experimentKey, experimentConfig.param, experimentConfig.defaultValue, {
|
|
90
|
+
typeGuard: experimentConfig.typeGuard,
|
|
91
|
+
fireExperimentExposure: options.exposure
|
|
92
|
+
});
|
|
93
|
+
if (
|
|
94
|
+
// When cleaning this gate up -- `calling where the experiments have the product key set`
|
|
95
|
+
// in __tests__/experiments should be updated (as it's had the count bumped to include these).
|
|
96
|
+
// eslint-disable-next-line @atlaskit/platform/use-recommended-utils
|
|
97
|
+
FeatureGates.getExperimentValue('cc_editor_experiments_ufo_gate_reporting', 'isEnabled', false)) {
|
|
98
|
+
addFeatureFlagAccessed("".concat(experimentName, ":").concat(experimentConfig.param), experimentValue);
|
|
99
|
+
}
|
|
100
|
+
return expectedExperimentValue === experimentValue;
|
|
101
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { expValInternal } from './expVal';
|
|
2
|
+
export function expValNoExposure(experimentName, experimentParam, defaultValue) {
|
|
3
|
+
return expValInternal({
|
|
4
|
+
experimentName: experimentName,
|
|
5
|
+
experimentParam: experimentParam,
|
|
6
|
+
defaultValue: defaultValue,
|
|
7
|
+
fireExperimentExposure: false
|
|
8
|
+
});
|
|
9
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { expValInternal } from './expVal';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Use to check a any param value for an experiment
|
|
5
|
+
*
|
|
6
|
+
* **Note**: this will return the default value when the experiment;
|
|
7
|
+
* - is not being served to the client (ie. pre start)
|
|
8
|
+
* - or is not configured in experiments-config
|
|
9
|
+
*
|
|
10
|
+
* If you need to check a param value without an exposure check see
|
|
11
|
+
* {@link import('./exp-val-no-exposure').expValNoExposure}
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const delay = expVal('experiment-name', 'param-name', defaultValue)
|
|
16
|
+
* await new Promise(res => setTimeout(res, delay)
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export function expVal(experimentName, experimentParam, defaultValue) {
|
|
20
|
+
return expValInternal({
|
|
21
|
+
experimentName: experimentName,
|
|
22
|
+
experimentParam: experimentParam,
|
|
23
|
+
defaultValue: defaultValue,
|
|
24
|
+
fireExperimentExposure: true
|
|
25
|
+
});
|
|
26
|
+
}
|
package/dist/esm/expVal.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/* eslint-disable @repo/internal/deprecations/deprecation-ticket-required -- VOLTC-139 tracks removal of these deprecated re-export shims. */
|
|
2
|
+
/* eslint-disable @atlaskit/editor/no-re-export -- deprecated shims re-exporting the split `expVal`/`expValNoExposure` modules for backwards compatibility (VOLTC-139). */
|
|
3
|
+
import FeatureGates from '@atlaskit/feature-gate-js-client/feature-gates';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
3
5
|
import { addFeatureFlagAccessed } from '@atlaskit/react-ufo/feature-flags-accessed';
|
|
4
6
|
import { disallowsProductKeys, editorExperimentsConfig } from './experiments-config';
|
|
5
7
|
import { _overrides, _paramOverrides, _product } from './setup';
|
|
6
|
-
function expValInternal(_ref) {
|
|
8
|
+
export function expValInternal(_ref) {
|
|
7
9
|
var _paramOverrides2, _experimentConfig$pro;
|
|
8
10
|
var experimentName = _ref.experimentName,
|
|
9
11
|
experimentParam = _ref.experimentParam,
|
|
@@ -61,45 +63,10 @@ function expValInternal(_ref) {
|
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
/**
|
|
64
|
-
* Use
|
|
65
|
-
*
|
|
66
|
-
* **Note**: this will return the default value when the experiment;
|
|
67
|
-
* - is not being served to the client (ie. pre start)
|
|
68
|
-
* - or is not configured in experiments-config
|
|
69
|
-
*
|
|
70
|
-
* If you need to check a param value without an exposure check see {@link expValNoExposure}
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```ts
|
|
74
|
-
* const delay = expVal('experiment-name', 'param-name', defaultValue)
|
|
75
|
-
* await new Promise(res => setTimeout(res, delay)
|
|
76
|
-
* ```
|
|
66
|
+
* @deprecated Use `import { expVal } from '@atlaskit/tmp-editor-statsig/expVal'` instead.
|
|
77
67
|
*/
|
|
78
|
-
export
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
fireExperimentExposure: true
|
|
84
|
-
});
|
|
85
|
-
} /**
|
|
86
|
-
* Use to check a any param value for an experiment without firing an exposure event
|
|
87
|
-
*
|
|
88
|
-
* **Note**: this will return the default value when the experiment;
|
|
89
|
-
* - is not being served to the client (ie. pre start)
|
|
90
|
-
* - or is not configured in experiments-config
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
* ```ts
|
|
94
|
-
* const delay = expParamEqualsNoExposure('experiment-name', 'param-name', defaultValue)
|
|
95
|
-
* await new Promise(res => setTimeout(res, delay)
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
export function expValNoExposure(experimentName, experimentParam, defaultValue) {
|
|
99
|
-
return expValInternal({
|
|
100
|
-
experimentName: experimentName,
|
|
101
|
-
experimentParam: experimentParam,
|
|
102
|
-
defaultValue: defaultValue,
|
|
103
|
-
fireExperimentExposure: false
|
|
104
|
-
});
|
|
105
|
-
}
|
|
68
|
+
export { expVal } from './exp-val';
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated Use `import { expValNoExposure } from '@atlaskit/tmp-editor-statsig/expVal'` instead.
|
|
71
|
+
*/
|
|
72
|
+
export { expValNoExposure } from './exp-val-no-exposure';
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
3
3
|
// Entry file in package.json
|
|
4
4
|
|
|
5
|
-
import { createBooleanExperiment
|
|
5
|
+
import { createBooleanExperiment } from './create-boolean-experiment';
|
|
6
|
+
import { createMultivariateExperiment } from './create-multivariate-experiment';
|
|
6
7
|
// eslint-disable-next-line @typescript-eslint/consistent-type-imports -- Need value import for typeof
|
|
7
8
|
|
|
8
9
|
// These experiments have a jira-specific key that differs from the experiment name,
|
|
9
10
|
// so they must opt out of product-key routing to avoid sending the wrong key on jira.
|
|
10
|
-
export var disallowsProductKeys = ['platform_editor_block_menu', 'platform_editor_blocks', 'platform_editor_controls', 'platform_editor_preview_panel_linking_exp', '
|
|
11
|
+
export var disallowsProductKeys = ['platform_editor_block_menu', 'platform_editor_blocks', 'platform_editor_controls', 'platform_editor_preview_panel_linking_exp', 'platform_editor_static_css', 'advanced_layouts', 'single_column_layouts', 'platform_editor_preview_panel_responsiveness', 'platform_editor_toolbar_aifc', 'comment_on_bodied_extensions'];
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Extract valid expected values.
|
|
@@ -866,15 +867,6 @@ export var editorExperimentsConfig = {
|
|
|
866
867
|
param: 'isEnabled',
|
|
867
868
|
defaultValue: false
|
|
868
869
|
}),
|
|
869
|
-
// Added 2025-08-10
|
|
870
|
-
platform_synced_block: createBooleanExperiment({
|
|
871
|
-
productKeys: {
|
|
872
|
-
confluence: 'platform_synced_block',
|
|
873
|
-
jira: 'platform_synced_block_jira'
|
|
874
|
-
},
|
|
875
|
-
param: 'isEnabled',
|
|
876
|
-
defaultValue: false
|
|
877
|
-
}),
|
|
878
870
|
// Added 2025-08-18
|
|
879
871
|
platform_editor_locale_datepicker: createBooleanExperiment({
|
|
880
872
|
productKeys: {
|
package/dist/esm/experiments.js
CHANGED
|
@@ -1,127 +1,12 @@
|
|
|
1
|
+
/* eslint-disable @repo/internal/deprecations/deprecation-ticket-required -- VOLTC-139 tracks removal of these deprecated re-export shims. */
|
|
1
2
|
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
2
3
|
// Entry file in package.json
|
|
3
4
|
|
|
4
|
-
import FeatureGates from '@atlaskit/feature-gate-js-client';
|
|
5
|
-
import { addFeatureFlagAccessed } from '@atlaskit/react-ufo/feature-flags-accessed';
|
|
6
|
-
import { editorExperimentsConfig } from './experiments-config';
|
|
7
|
-
import { _overrides, _paramOverrides, _product } from './setup';
|
|
8
|
-
|
|
9
5
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* Note: By default this will not fire an [exposure event](https://hello.atlassian.net/wiki/spaces/~732385844/pages/3187295823/Exposure+Events+101).
|
|
13
|
-
*
|
|
14
|
-
* You need explicitly call it using the exposure property when you need an exposure event to be fired (all experiments should fire exposure events).
|
|
15
|
-
*
|
|
16
|
-
* @example Boolean experiment
|
|
17
|
-
* ```ts
|
|
18
|
-
* if (editorExperiment('example-boolean', true)) {
|
|
19
|
-
* // Run code for on variant
|
|
20
|
-
* } else {
|
|
21
|
-
* // Run code for off variant
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @example Multivariate experiment
|
|
26
|
-
* ```ts
|
|
27
|
-
* switch (true) {
|
|
28
|
-
* case editorExperiment('example-multivariate', 'one'):
|
|
29
|
-
* // Run code for variant one
|
|
30
|
-
* break;
|
|
31
|
-
* case editorExperiment('example-multivariate', 'two'):
|
|
32
|
-
* // Run code for variant two
|
|
33
|
-
* break;
|
|
34
|
-
* case editorExperiment('example-multivariate', 'three'):
|
|
35
|
-
* // Run code for variant three
|
|
36
|
-
* break;
|
|
37
|
-
* }
|
|
38
|
-
* }
|
|
39
|
-
*```
|
|
40
|
-
|
|
41
|
-
@example Experiment with exposure event
|
|
42
|
-
* ```ts
|
|
43
|
-
* // Inside feature surface where either the control or variant should be shown
|
|
44
|
-
* if (editorExperiment('example-boolean', true, { exposure: true })) {
|
|
45
|
-
* // Run code for on variant
|
|
46
|
-
* } else {
|
|
47
|
-
* // Run code for off variant
|
|
48
|
-
* }
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* @private
|
|
52
|
-
* @deprecated This utility is deprecated in favour of using `expValEquals` from `@atlaskit/tmp-editor-statsig/exp-val-equals`.
|
|
53
|
-
* ExpValEquals fires exposure events by default preventing cases when consumers of exitorExperiment forget to pass the `exposure` option.
|
|
54
|
-
* It also closely aligns with similar utilities in other Atlassian products.
|
|
55
|
-
* For no exposure option use `expValEqualsNoExposure` from `@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure`.
|
|
6
|
+
* @deprecated Use `import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments'` instead.
|
|
56
7
|
*/
|
|
57
|
-
export
|
|
58
|
-
var _experimentConfig$pro;
|
|
59
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
60
|
-
exposure: false
|
|
61
|
-
};
|
|
62
|
-
var experimentConfig = editorExperimentsConfig[experimentName];
|
|
63
|
-
if (_overrides[experimentName] !== undefined) {
|
|
64
|
-
// This will be hit in the case of a test setting an override
|
|
65
|
-
return _overrides[experimentName] === expectedExperimentValue;
|
|
66
|
-
}
|
|
67
|
-
if (experimentConfig === undefined) {
|
|
68
|
-
// Warning! If a product is improperly configured (ie. their editor packages are misaligned)
|
|
69
|
-
// it can cause the editor to crash here or if the experiment does not exist.
|
|
70
|
-
// We will definitely crash via any code path later in this function - this just makes the error explicit and clear.
|
|
71
|
-
throw new Error("Editor experiment configuration is not defined ".concat(experimentName, ". Likely the experiment does not exist or editor package versions are misaligned"));
|
|
72
|
-
}
|
|
73
|
-
if (!_product) {
|
|
74
|
-
// This will be hit in the case of a product not having setup the editor experiment tooling
|
|
75
|
-
return experimentConfig.defaultValue === expectedExperimentValue;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Typescript is complaining here about accessing the productKeys property
|
|
79
|
-
// Ignored via go/ees005
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
81
|
-
var experimentKey = experimentConfig === null || experimentConfig === void 0 || (_experimentConfig$pro = experimentConfig.productKeys) === null || _experimentConfig$pro === void 0 ? void 0 : _experimentConfig$pro[_product];
|
|
82
|
-
if (!experimentKey) {
|
|
83
|
-
var _editorExperimentsCon;
|
|
84
|
-
// This will be hit in the case of an experiment not being set up for the product
|
|
85
|
-
return ((_editorExperimentsCon = editorExperimentsConfig[experimentName]) === null || _editorExperimentsCon === void 0 ? void 0 : _editorExperimentsCon.defaultValue) === expectedExperimentValue;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// eslint-disable-next-line @atlaskit/platform/use-recommended-utils
|
|
89
|
-
var experimentValue = FeatureGates.getExperimentValue(experimentKey, experimentConfig.param, experimentConfig.defaultValue, {
|
|
90
|
-
typeGuard: experimentConfig.typeGuard,
|
|
91
|
-
fireExperimentExposure: options.exposure
|
|
92
|
-
});
|
|
93
|
-
if (
|
|
94
|
-
// When cleaning this gate up -- `calling where the experiments have the product key set`
|
|
95
|
-
// in __tests__/experiments should be updated (as it's had the count bumped to include these).
|
|
96
|
-
// eslint-disable-next-line @atlaskit/platform/use-recommended-utils
|
|
97
|
-
FeatureGates.getExperimentValue('cc_editor_experiments_ufo_gate_reporting', 'isEnabled', false)) {
|
|
98
|
-
addFeatureFlagAccessed("".concat(experimentName, ":").concat(experimentConfig.param), experimentValue);
|
|
99
|
-
}
|
|
100
|
-
return expectedExperimentValue === experimentValue;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
104
|
-
|
|
8
|
+
export { editorExperiment } from './editor-experiment';
|
|
105
9
|
/**
|
|
106
|
-
* @
|
|
107
|
-
* and has limited associated test tooling.
|
|
108
|
-
*
|
|
109
|
-
* It also only works for experiments where the key matches the productKey used.
|
|
110
|
-
*
|
|
111
|
-
* The typeguard and default value is also expected to move to the experiment config
|
|
10
|
+
* @deprecated Use `import { unstable_editorExperimentParam } from '@atlaskit/tmp-editor-statsig/experiments'` instead.
|
|
112
11
|
*/
|
|
113
|
-
export
|
|
114
|
-
var _paramOverrides$exper, _options$exposure;
|
|
115
|
-
if (((_paramOverrides$exper = _paramOverrides[experimentName]) === null || _paramOverrides$exper === void 0 ? void 0 : _paramOverrides$exper[paramName]) !== undefined) {
|
|
116
|
-
// This will be hit in the case of a test setting an override
|
|
117
|
-
|
|
118
|
-
return _paramOverrides[experimentName][paramName];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// eslint-disable-next-line @atlaskit/platform/use-recommended-utils
|
|
122
|
-
var experimentValue = FeatureGates.getExperimentValue(experimentName, paramName, options.defaultValue, {
|
|
123
|
-
typeGuard: options.typeGuard,
|
|
124
|
-
fireExperimentExposure: (_options$exposure = options.exposure) !== null && _options$exposure !== void 0 ? _options$exposure : false
|
|
125
|
-
});
|
|
126
|
-
return experimentValue;
|
|
127
|
-
}
|
|
12
|
+
export { unstable_editorExperimentParam } from './unstable-editor-experiment-param';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var _process, _process2;
|
|
2
|
+
var IS_TESTING_ENV = typeof process !== 'undefined' && (((_process = process) === null || _process === void 0 || (_process = _process.env) === null || _process === void 0 ? void 0 : _process.NODE_ENV) === 'test' || ((_process2 = process) === null || _process2 === void 0 || (_process2 = _process2.env) === null || _process2 === void 0 ? void 0 : _process2.JEST_WORKER_ID) !== undefined);
|
|
3
|
+
export function oneOf(values) {
|
|
4
|
+
function typeGuard(value) {
|
|
5
|
+
return values.includes(value);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* This is used by test utils to get the variants when running describe.each
|
|
9
|
+
*/
|
|
10
|
+
if (IS_TESTING_ENV) {
|
|
11
|
+
typeGuard.values = values;
|
|
12
|
+
}
|
|
13
|
+
return typeGuard;
|
|
14
|
+
}
|
package/dist/esm/type-guards.js
CHANGED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
var _process, _process2;
|
|
2
|
-
export function isBoolean(value) {
|
|
3
|
-
return typeof value === 'boolean';
|
|
4
|
-
}
|
|
5
|
-
export function oneOf(values) {
|
|
6
|
-
function typeGuard(value) {
|
|
7
|
-
return values.includes(value);
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* This is used by test utils to get the variants when running describe.each
|
|
11
|
-
*/
|
|
12
|
-
if (IS_TESTING_ENV) {
|
|
13
|
-
typeGuard.values = values;
|
|
14
|
-
}
|
|
15
|
-
return typeGuard;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
|
|
20
|
-
var IS_TESTING_ENV = typeof process !== 'undefined' && (((_process = process) === null || _process === void 0 || (_process = _process.env) === null || _process === void 0 ? void 0 : _process.NODE_ENV) === 'test' || ((_process2 = process) === null || _process2 === void 0 || (_process2 = _process2.env) === null || _process2 === void 0 ? void 0 : _process2.JEST_WORKER_ID) !== undefined);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
2
|
+
// Entry file in package.json
|
|
3
|
+
|
|
4
|
+
import FeatureGates from '@atlaskit/feature-gate-js-client/feature-gates';
|
|
5
|
+
import { _paramOverrides } from './setup';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @warning This currently lacks type safety on the param names and return values
|
|
11
|
+
* and has limited associated test tooling.
|
|
12
|
+
*
|
|
13
|
+
* It also only works for experiments where the key matches the productKey used.
|
|
14
|
+
*
|
|
15
|
+
* The typeguard and default value is also expected to move to the experiment config
|
|
16
|
+
*/
|
|
17
|
+
export function unstable_editorExperimentParam(experimentName, paramName, options) {
|
|
18
|
+
var _paramOverrides$exper, _options$exposure;
|
|
19
|
+
if (((_paramOverrides$exper = _paramOverrides[experimentName]) === null || _paramOverrides$exper === void 0 ? void 0 : _paramOverrides$exper[paramName]) !== undefined) {
|
|
20
|
+
// This will be hit in the case of a test setting an override
|
|
21
|
+
|
|
22
|
+
return _paramOverrides[experimentName][paramName];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line @atlaskit/platform/use-recommended-utils
|
|
26
|
+
var experimentValue = FeatureGates.getExperimentValue(experimentName, paramName, options.defaultValue, {
|
|
27
|
+
typeGuard: options.typeGuard,
|
|
28
|
+
fireExperimentExposure: (_options$exposure = options.exposure) !== null && _options$exposure !== void 0 ? _options$exposure : false
|
|
29
|
+
});
|
|
30
|
+
return experimentValue;
|
|
31
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isBoolean } from './is-boolean';
|
|
2
|
+
import type { BooleanExperimentConfig, ProductKeys } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Helper to create a boolean experiment configuration
|
|
5
|
+
*/
|
|
6
|
+
export declare function createBooleanExperiment(config: BooleanExperimentConfig): {
|
|
7
|
+
defaultValue: boolean;
|
|
8
|
+
param: string;
|
|
9
|
+
productKeys?: ProductKeys;
|
|
10
|
+
typeGuard: typeof isBoolean;
|
|
11
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MultivariateExperimentConfig, ProductKeys } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Helper to create a multivariate experiment configuration
|
|
4
|
+
*/
|
|
5
|
+
export declare function createMultivariateExperiment<T extends string[]>(config: MultivariateExperimentConfig<T>): {
|
|
6
|
+
defaultValue: T[number];
|
|
7
|
+
param: string;
|
|
8
|
+
productKeys?: ProductKeys;
|
|
9
|
+
typeGuard: (value: unknown) => value is T[number];
|
|
10
|
+
values: [...T][number][];
|
|
11
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { EditorExperimentsConfig } from './experiments-config';
|
|
2
|
+
/**
|
|
3
|
+
* Check the value of an editor experiment.
|
|
4
|
+
*
|
|
5
|
+
* Note: By default this will not fire an [exposure event](https://hello.atlassian.net/wiki/spaces/~732385844/pages/3187295823/Exposure+Events+101).
|
|
6
|
+
*
|
|
7
|
+
* You need explicitly call it using the exposure property when you need an exposure event to be fired (all experiments should fire exposure events).
|
|
8
|
+
*
|
|
9
|
+
* @example Boolean experiment
|
|
10
|
+
* ```ts
|
|
11
|
+
* if (editorExperiment('example-boolean', true)) {
|
|
12
|
+
* // Run code for on variant
|
|
13
|
+
* } else {
|
|
14
|
+
* // Run code for off variant
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @example Multivariate experiment
|
|
19
|
+
* ```ts
|
|
20
|
+
* switch (true) {
|
|
21
|
+
* case editorExperiment('example-multivariate', 'one'):
|
|
22
|
+
* // Run code for variant one
|
|
23
|
+
* break;
|
|
24
|
+
* case editorExperiment('example-multivariate', 'two'):
|
|
25
|
+
* // Run code for variant two
|
|
26
|
+
* break;
|
|
27
|
+
* case editorExperiment('example-multivariate', 'three'):
|
|
28
|
+
* // Run code for variant three
|
|
29
|
+
* break;
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
*```
|
|
33
|
+
|
|
34
|
+
@example Experiment with exposure event
|
|
35
|
+
* ```ts
|
|
36
|
+
* // Inside feature surface where either the control or variant should be shown
|
|
37
|
+
* if (editorExperiment('example-boolean', true, { exposure: true })) {
|
|
38
|
+
* // Run code for on variant
|
|
39
|
+
* } else {
|
|
40
|
+
* // Run code for off variant
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @private
|
|
45
|
+
* @deprecated This utility is deprecated in favour of using `expValEquals` from `@atlaskit/tmp-editor-statsig/exp-val-equals`.
|
|
46
|
+
* ExpValEquals fires exposure events by default preventing cases when consumers of exitorExperiment forget to pass the `exposure` option.
|
|
47
|
+
* It also closely aligns with similar utilities in other Atlassian products.
|
|
48
|
+
* For no exposure option use `expValEqualsNoExposure` from `@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function editorExperiment<ExperimentName extends keyof EditorExperimentsConfig>(experimentName: ExperimentName, expectedExperimentValue: EditorExperimentsConfig[ExperimentName]['defaultValue'], options?: {
|
|
51
|
+
exposure: boolean;
|
|
52
|
+
}): boolean;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { EditorExperimentsConfig } from './experiments-config';
|
|
2
|
+
export declare function expValNoExposure<ExperimentName extends keyof EditorExperimentsConfig, DefaultValue extends string | number | boolean>(experimentName: ExperimentName, experimentParam: string, defaultValue: DefaultValue extends boolean ? false : DefaultValue): DefaultValue;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { EditorExperimentsConfig } from './experiments-config';
|
|
2
|
+
/**
|
|
3
|
+
* Use to check a any param value for an experiment
|
|
4
|
+
*
|
|
5
|
+
* **Note**: this will return the default value when the experiment;
|
|
6
|
+
* - is not being served to the client (ie. pre start)
|
|
7
|
+
* - or is not configured in experiments-config
|
|
8
|
+
*
|
|
9
|
+
* If you need to check a param value without an exposure check see
|
|
10
|
+
* {@link import('./exp-val-no-exposure').expValNoExposure}
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const delay = expVal('experiment-name', 'param-name', defaultValue)
|
|
15
|
+
* await new Promise(res => setTimeout(res, delay)
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function expVal<ExperimentName extends keyof EditorExperimentsConfig, DefaultValue extends string | number | boolean>(experimentName: ExperimentName, experimentParam: string, defaultValue: DefaultValue extends boolean ? false : DefaultValue): DefaultValue;
|