@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
package/dist/cjs/experiments.js
CHANGED
|
@@ -1,134 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _experimentsConfig = require("./experiments-config");
|
|
12
|
-
var _setup = require("./setup");
|
|
13
|
-
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
14
|
-
// Entry file in package.json
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Check the value of an editor experiment.
|
|
18
|
-
*
|
|
19
|
-
* Note: By default this will not fire an [exposure event](https://hello.atlassian.net/wiki/spaces/~732385844/pages/3187295823/Exposure+Events+101).
|
|
20
|
-
*
|
|
21
|
-
* You need explicitly call it using the exposure property when you need an exposure event to be fired (all experiments should fire exposure events).
|
|
22
|
-
*
|
|
23
|
-
* @example Boolean experiment
|
|
24
|
-
* ```ts
|
|
25
|
-
* if (editorExperiment('example-boolean', true)) {
|
|
26
|
-
* // Run code for on variant
|
|
27
|
-
* } else {
|
|
28
|
-
* // Run code for off variant
|
|
29
|
-
* }
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* @example Multivariate experiment
|
|
33
|
-
* ```ts
|
|
34
|
-
* switch (true) {
|
|
35
|
-
* case editorExperiment('example-multivariate', 'one'):
|
|
36
|
-
* // Run code for variant one
|
|
37
|
-
* break;
|
|
38
|
-
* case editorExperiment('example-multivariate', 'two'):
|
|
39
|
-
* // Run code for variant two
|
|
40
|
-
* break;
|
|
41
|
-
* case editorExperiment('example-multivariate', 'three'):
|
|
42
|
-
* // Run code for variant three
|
|
43
|
-
* break;
|
|
44
|
-
* }
|
|
45
|
-
* }
|
|
46
|
-
*```
|
|
47
|
-
|
|
48
|
-
@example Experiment with exposure event
|
|
49
|
-
* ```ts
|
|
50
|
-
* // Inside feature surface where either the control or variant should be shown
|
|
51
|
-
* if (editorExperiment('example-boolean', true, { exposure: true })) {
|
|
52
|
-
* // Run code for on variant
|
|
53
|
-
* } else {
|
|
54
|
-
* // Run code for off variant
|
|
55
|
-
* }
|
|
56
|
-
* ```
|
|
57
|
-
*
|
|
58
|
-
* @private
|
|
59
|
-
* @deprecated This utility is deprecated in favour of using `expValEquals` from `@atlaskit/tmp-editor-statsig/exp-val-equals`.
|
|
60
|
-
* ExpValEquals fires exposure events by default preventing cases when consumers of exitorExperiment forget to pass the `exposure` option.
|
|
61
|
-
* It also closely aligns with similar utilities in other Atlassian products.
|
|
62
|
-
* For no exposure option use `expValEqualsNoExposure` from `@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure`.
|
|
63
|
-
*/
|
|
64
|
-
function editorExperiment(experimentName, expectedExperimentValue) {
|
|
65
|
-
var _experimentConfig$pro;
|
|
66
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
67
|
-
exposure: false
|
|
68
|
-
};
|
|
69
|
-
var experimentConfig = _experimentsConfig.editorExperimentsConfig[experimentName];
|
|
70
|
-
if (_setup._overrides[experimentName] !== undefined) {
|
|
71
|
-
// This will be hit in the case of a test setting an override
|
|
72
|
-
return _setup._overrides[experimentName] === expectedExperimentValue;
|
|
73
|
-
}
|
|
74
|
-
if (experimentConfig === undefined) {
|
|
75
|
-
// Warning! If a product is improperly configured (ie. their editor packages are misaligned)
|
|
76
|
-
// it can cause the editor to crash here or if the experiment does not exist.
|
|
77
|
-
// We will definitely crash via any code path later in this function - this just makes the error explicit and clear.
|
|
78
|
-
throw new Error("Editor experiment configuration is not defined ".concat(experimentName, ". Likely the experiment does not exist or editor package versions are misaligned"));
|
|
79
|
-
}
|
|
80
|
-
if (!_setup._product) {
|
|
81
|
-
// This will be hit in the case of a product not having setup the editor experiment tooling
|
|
82
|
-
return experimentConfig.defaultValue === expectedExperimentValue;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Typescript is complaining here about accessing the productKeys property
|
|
86
|
-
// Ignored via go/ees005
|
|
87
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
88
|
-
var experimentKey = experimentConfig === null || experimentConfig === void 0 || (_experimentConfig$pro = experimentConfig.productKeys) === null || _experimentConfig$pro === void 0 ? void 0 : _experimentConfig$pro[_setup._product];
|
|
89
|
-
if (!experimentKey) {
|
|
90
|
-
var _editorExperimentsCon;
|
|
91
|
-
// This will be hit in the case of an experiment not being set up for the product
|
|
92
|
-
return ((_editorExperimentsCon = _experimentsConfig.editorExperimentsConfig[experimentName]) === null || _editorExperimentsCon === void 0 ? void 0 : _editorExperimentsCon.defaultValue) === expectedExperimentValue;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// eslint-disable-next-line @atlaskit/platform/use-recommended-utils
|
|
96
|
-
var experimentValue = _featureGateJsClient.default.getExperimentValue(experimentKey, experimentConfig.param, experimentConfig.defaultValue, {
|
|
97
|
-
typeGuard: experimentConfig.typeGuard,
|
|
98
|
-
fireExperimentExposure: options.exposure
|
|
99
|
-
});
|
|
100
|
-
if (
|
|
101
|
-
// When cleaning this gate up -- `calling where the experiments have the product key set`
|
|
102
|
-
// in __tests__/experiments should be updated (as it's had the count bumped to include these).
|
|
103
|
-
// eslint-disable-next-line @atlaskit/platform/use-recommended-utils
|
|
104
|
-
_featureGateJsClient.default.getExperimentValue('cc_editor_experiments_ufo_gate_reporting', 'isEnabled', false)) {
|
|
105
|
-
(0, _featureFlagsAccessed.addFeatureFlagAccessed)("".concat(experimentName, ":").concat(experimentConfig.param), experimentValue);
|
|
6
|
+
Object.defineProperty(exports, "editorExperiment", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _editorExperiment.editorExperiment;
|
|
106
10
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* @warning This currently lacks type safety on the param names and return values
|
|
114
|
-
* and has limited associated test tooling.
|
|
115
|
-
*
|
|
116
|
-
* It also only works for experiments where the key matches the productKey used.
|
|
117
|
-
*
|
|
118
|
-
* The typeguard and default value is also expected to move to the experiment config
|
|
119
|
-
*/
|
|
120
|
-
function unstable_editorExperimentParam(experimentName, paramName, options) {
|
|
121
|
-
var _paramOverrides$exper, _options$exposure;
|
|
122
|
-
if (((_paramOverrides$exper = _setup._paramOverrides[experimentName]) === null || _paramOverrides$exper === void 0 ? void 0 : _paramOverrides$exper[paramName]) !== undefined) {
|
|
123
|
-
// This will be hit in the case of a test setting an override
|
|
124
|
-
|
|
125
|
-
return _setup._paramOverrides[experimentName][paramName];
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "unstable_editorExperimentParam", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _unstableEditorExperimentParam.unstable_editorExperimentParam;
|
|
126
16
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
typeGuard: options.typeGuard,
|
|
131
|
-
fireExperimentExposure: (_options$exposure = options.exposure) !== null && _options$exposure !== void 0 ? _options$exposure : false
|
|
132
|
-
});
|
|
133
|
-
return experimentValue;
|
|
134
|
-
}
|
|
17
|
+
});
|
|
18
|
+
var _editorExperiment = require("./editor-experiment");
|
|
19
|
+
var _unstableEditorExperimentParam = require("./unstable-editor-experiment-param");
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.oneOf = oneOf;
|
|
7
|
+
var _process, _process2;
|
|
8
|
+
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);
|
|
9
|
+
function oneOf(values) {
|
|
10
|
+
function typeGuard(value) {
|
|
11
|
+
return values.includes(value);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* This is used by test utils to get the variants when running describe.each
|
|
15
|
+
*/
|
|
16
|
+
if (IS_TESTING_ENV) {
|
|
17
|
+
typeGuard.values = values;
|
|
18
|
+
}
|
|
19
|
+
return typeGuard;
|
|
20
|
+
}
|
package/dist/cjs/type-guards.js
CHANGED
|
@@ -1,27 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isBoolean = isBoolean;
|
|
7
|
-
exports.oneOf = oneOf;
|
|
8
|
-
var _process, _process2;
|
|
9
|
-
function isBoolean(value) {
|
|
10
|
-
return typeof value === 'boolean';
|
|
11
|
-
}
|
|
12
|
-
function oneOf(values) {
|
|
13
|
-
function typeGuard(value) {
|
|
14
|
-
return values.includes(value);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* This is used by test utils to get the variants when running describe.each
|
|
18
|
-
*/
|
|
19
|
-
if (IS_TESTING_ENV) {
|
|
20
|
-
typeGuard.values = values;
|
|
21
|
-
}
|
|
22
|
-
return typeGuard;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
|
|
27
|
-
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);
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.unstable_editorExperimentParam = unstable_editorExperimentParam;
|
|
8
|
+
var _featureGates = _interopRequireDefault(require("@atlaskit/feature-gate-js-client/feature-gates"));
|
|
9
|
+
var _setup = require("./setup");
|
|
10
|
+
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
11
|
+
// Entry file in package.json
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @warning This currently lacks type safety on the param names and return values
|
|
17
|
+
* and has limited associated test tooling.
|
|
18
|
+
*
|
|
19
|
+
* It also only works for experiments where the key matches the productKey used.
|
|
20
|
+
*
|
|
21
|
+
* The typeguard and default value is also expected to move to the experiment config
|
|
22
|
+
*/
|
|
23
|
+
function unstable_editorExperimentParam(experimentName, paramName, options) {
|
|
24
|
+
var _paramOverrides$exper, _options$exposure;
|
|
25
|
+
if (((_paramOverrides$exper = _setup._paramOverrides[experimentName]) === null || _paramOverrides$exper === void 0 ? void 0 : _paramOverrides$exper[paramName]) !== undefined) {
|
|
26
|
+
// This will be hit in the case of a test setting an override
|
|
27
|
+
|
|
28
|
+
return _setup._paramOverrides[experimentName][paramName];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// eslint-disable-next-line @atlaskit/platform/use-recommended-utils
|
|
32
|
+
var experimentValue = _featureGates.default.getExperimentValue(experimentName, paramName, options.defaultValue, {
|
|
33
|
+
typeGuard: options.typeGuard,
|
|
34
|
+
fireExperimentExposure: (_options$exposure = options.exposure) !== null && _options$exposure !== void 0 ? _options$exposure : false
|
|
35
|
+
});
|
|
36
|
+
return experimentValue;
|
|
37
|
+
}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
3
|
-
* Helper to create a boolean experiment configuration
|
|
4
|
-
*/
|
|
5
|
-
export function createBooleanExperiment(config) {
|
|
6
|
-
return {
|
|
7
|
-
...config,
|
|
8
|
-
typeGuard: isBoolean,
|
|
9
|
-
defaultValue: config.defaultValue
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
1
|
+
import { oneOf } from './one-of';
|
|
13
2
|
/**
|
|
14
3
|
* Helper to create a multivariate experiment configuration
|
|
15
4
|
*/
|
|
@@ -0,0 +1,100 @@
|
|
|
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, options = {
|
|
58
|
+
exposure: false
|
|
59
|
+
}) {
|
|
60
|
+
var _experimentConfig$pro;
|
|
61
|
+
const experimentConfig = editorExperimentsConfig[experimentName];
|
|
62
|
+
if (_overrides[experimentName] !== undefined) {
|
|
63
|
+
// This will be hit in the case of a test setting an override
|
|
64
|
+
return _overrides[experimentName] === expectedExperimentValue;
|
|
65
|
+
}
|
|
66
|
+
if (experimentConfig === undefined) {
|
|
67
|
+
// Warning! If a product is improperly configured (ie. their editor packages are misaligned)
|
|
68
|
+
// it can cause the editor to crash here or if the experiment does not exist.
|
|
69
|
+
// We will definitely crash via any code path later in this function - this just makes the error explicit and clear.
|
|
70
|
+
throw new Error(`Editor experiment configuration is not defined ${experimentName}. Likely the experiment does not exist or editor package versions are misaligned`);
|
|
71
|
+
}
|
|
72
|
+
if (!_product) {
|
|
73
|
+
// This will be hit in the case of a product not having setup the editor experiment tooling
|
|
74
|
+
return experimentConfig.defaultValue === expectedExperimentValue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Typescript is complaining here about accessing the productKeys property
|
|
78
|
+
// Ignored via go/ees005
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
80
|
+
const experimentKey = experimentConfig === null || experimentConfig === void 0 ? void 0 : (_experimentConfig$pro = experimentConfig.productKeys) === null || _experimentConfig$pro === void 0 ? void 0 : _experimentConfig$pro[_product];
|
|
81
|
+
if (!experimentKey) {
|
|
82
|
+
var _editorExperimentsCon;
|
|
83
|
+
// This will be hit in the case of an experiment not being set up for the product
|
|
84
|
+
return ((_editorExperimentsCon = editorExperimentsConfig[experimentName]) === null || _editorExperimentsCon === void 0 ? void 0 : _editorExperimentsCon.defaultValue) === expectedExperimentValue;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// eslint-disable-next-line @atlaskit/platform/use-recommended-utils
|
|
88
|
+
const experimentValue = FeatureGates.getExperimentValue(experimentKey, experimentConfig.param, experimentConfig.defaultValue, {
|
|
89
|
+
typeGuard: experimentConfig.typeGuard,
|
|
90
|
+
fireExperimentExposure: options.exposure
|
|
91
|
+
});
|
|
92
|
+
if (
|
|
93
|
+
// When cleaning this gate up -- `calling where the experiments have the product key set`
|
|
94
|
+
// in __tests__/experiments should be updated (as it's had the count bumped to include these).
|
|
95
|
+
// eslint-disable-next-line @atlaskit/platform/use-recommended-utils
|
|
96
|
+
FeatureGates.getExperimentValue('cc_editor_experiments_ufo_gate_reporting', 'isEnabled', false)) {
|
|
97
|
+
addFeatureFlagAccessed(`${experimentName}:${experimentConfig.param}`, experimentValue);
|
|
98
|
+
}
|
|
99
|
+
return expectedExperimentValue === experimentValue;
|
|
100
|
+
}
|
|
@@ -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,
|
|
22
|
+
experimentParam,
|
|
23
|
+
defaultValue: defaultValue,
|
|
24
|
+
fireExperimentExposure: true
|
|
25
|
+
});
|
|
26
|
+
}
|
package/dist/es2019/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({
|
|
8
|
+
export function expValInternal({
|
|
7
9
|
experimentName,
|
|
8
10
|
experimentParam,
|
|
9
11
|
defaultValue,
|
|
@@ -62,45 +64,10 @@ function expValInternal({
|
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
/**
|
|
65
|
-
* Use
|
|
66
|
-
*
|
|
67
|
-
* **Note**: this will return the default value when the experiment;
|
|
68
|
-
* - is not being served to the client (ie. pre start)
|
|
69
|
-
* - or is not configured in experiments-config
|
|
70
|
-
*
|
|
71
|
-
* If you need to check a param value without an exposure check see {@link expValNoExposure}
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```ts
|
|
75
|
-
* const delay = expVal('experiment-name', 'param-name', defaultValue)
|
|
76
|
-
* await new Promise(res => setTimeout(res, delay)
|
|
77
|
-
* ```
|
|
67
|
+
* @deprecated Use `import { expVal } from '@atlaskit/tmp-editor-statsig/expVal'` instead.
|
|
78
68
|
*/
|
|
79
|
-
export
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
fireExperimentExposure: true
|
|
85
|
-
});
|
|
86
|
-
} /**
|
|
87
|
-
* Use to check a any param value for an experiment without firing an exposure event
|
|
88
|
-
*
|
|
89
|
-
* **Note**: this will return the default value when the experiment;
|
|
90
|
-
* - is not being served to the client (ie. pre start)
|
|
91
|
-
* - or is not configured in experiments-config
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* ```ts
|
|
95
|
-
* const delay = expParamEqualsNoExposure('experiment-name', 'param-name', defaultValue)
|
|
96
|
-
* await new Promise(res => setTimeout(res, delay)
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
export function expValNoExposure(experimentName, experimentParam, defaultValue) {
|
|
100
|
-
return expValInternal({
|
|
101
|
-
experimentName,
|
|
102
|
-
experimentParam,
|
|
103
|
-
defaultValue: defaultValue,
|
|
104
|
-
fireExperimentExposure: false
|
|
105
|
-
});
|
|
106
|
-
}
|
|
69
|
+
export { expVal } from './exp-val';
|
|
70
|
+
/**
|
|
71
|
+
* @deprecated Use `import { expValNoExposure } from '@atlaskit/tmp-editor-statsig/expVal'` instead.
|
|
72
|
+
*/
|
|
73
|
+
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 const disallowsProductKeys = ['platform_editor_block_menu', 'platform_editor_blocks', 'platform_editor_controls', 'platform_editor_preview_panel_linking_exp', '
|
|
11
|
+
export const 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 const 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: {
|
|
@@ -1,126 +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
|
-
exposure: false
|
|
59
|
-
}) {
|
|
60
|
-
var _experimentConfig$pro;
|
|
61
|
-
const experimentConfig = editorExperimentsConfig[experimentName];
|
|
62
|
-
if (_overrides[experimentName] !== undefined) {
|
|
63
|
-
// This will be hit in the case of a test setting an override
|
|
64
|
-
return _overrides[experimentName] === expectedExperimentValue;
|
|
65
|
-
}
|
|
66
|
-
if (experimentConfig === undefined) {
|
|
67
|
-
// Warning! If a product is improperly configured (ie. their editor packages are misaligned)
|
|
68
|
-
// it can cause the editor to crash here or if the experiment does not exist.
|
|
69
|
-
// We will definitely crash via any code path later in this function - this just makes the error explicit and clear.
|
|
70
|
-
throw new Error(`Editor experiment configuration is not defined ${experimentName}. Likely the experiment does not exist or editor package versions are misaligned`);
|
|
71
|
-
}
|
|
72
|
-
if (!_product) {
|
|
73
|
-
// This will be hit in the case of a product not having setup the editor experiment tooling
|
|
74
|
-
return experimentConfig.defaultValue === expectedExperimentValue;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Typescript is complaining here about accessing the productKeys property
|
|
78
|
-
// Ignored via go/ees005
|
|
79
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
80
|
-
const experimentKey = experimentConfig === null || experimentConfig === void 0 ? void 0 : (_experimentConfig$pro = experimentConfig.productKeys) === null || _experimentConfig$pro === void 0 ? void 0 : _experimentConfig$pro[_product];
|
|
81
|
-
if (!experimentKey) {
|
|
82
|
-
var _editorExperimentsCon;
|
|
83
|
-
// This will be hit in the case of an experiment not being set up for the product
|
|
84
|
-
return ((_editorExperimentsCon = editorExperimentsConfig[experimentName]) === null || _editorExperimentsCon === void 0 ? void 0 : _editorExperimentsCon.defaultValue) === expectedExperimentValue;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// eslint-disable-next-line @atlaskit/platform/use-recommended-utils
|
|
88
|
-
const experimentValue = FeatureGates.getExperimentValue(experimentKey, experimentConfig.param, experimentConfig.defaultValue, {
|
|
89
|
-
typeGuard: experimentConfig.typeGuard,
|
|
90
|
-
fireExperimentExposure: options.exposure
|
|
91
|
-
});
|
|
92
|
-
if (
|
|
93
|
-
// When cleaning this gate up -- `calling where the experiments have the product key set`
|
|
94
|
-
// in __tests__/experiments should be updated (as it's had the count bumped to include these).
|
|
95
|
-
// eslint-disable-next-line @atlaskit/platform/use-recommended-utils
|
|
96
|
-
FeatureGates.getExperimentValue('cc_editor_experiments_ufo_gate_reporting', 'isEnabled', false)) {
|
|
97
|
-
addFeatureFlagAccessed(`${experimentName}:${experimentConfig.param}`, experimentValue);
|
|
98
|
-
}
|
|
99
|
-
return expectedExperimentValue === experimentValue;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
103
|
-
|
|
8
|
+
export { editorExperiment } from './editor-experiment';
|
|
104
9
|
/**
|
|
105
|
-
* @
|
|
106
|
-
* and has limited associated test tooling.
|
|
107
|
-
*
|
|
108
|
-
* It also only works for experiments where the key matches the productKey used.
|
|
109
|
-
*
|
|
110
|
-
* 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.
|
|
111
11
|
*/
|
|
112
|
-
export
|
|
113
|
-
var _paramOverrides$exper, _options$exposure;
|
|
114
|
-
if (((_paramOverrides$exper = _paramOverrides[experimentName]) === null || _paramOverrides$exper === void 0 ? void 0 : _paramOverrides$exper[paramName]) !== undefined) {
|
|
115
|
-
// This will be hit in the case of a test setting an override
|
|
116
|
-
|
|
117
|
-
return _paramOverrides[experimentName][paramName];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// eslint-disable-next-line @atlaskit/platform/use-recommended-utils
|
|
121
|
-
const experimentValue = FeatureGates.getExperimentValue(experimentName, paramName, options.defaultValue, {
|
|
122
|
-
typeGuard: options.typeGuard,
|
|
123
|
-
fireExperimentExposure: (_options$exposure = options.exposure) !== null && _options$exposure !== void 0 ? _options$exposure : false
|
|
124
|
-
});
|
|
125
|
-
return experimentValue;
|
|
126
|
-
}
|
|
12
|
+
export { unstable_editorExperimentParam } from './unstable-editor-experiment-param';
|