@atlaskit/tmp-editor-statsig 147.1.0 → 148.1.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/cjs/create-boolean-experiment.js +20 -0
  3. package/dist/cjs/{experiment-builders.js → create-multivariate-experiment.js} +2 -13
  4. package/dist/cjs/editor-experiment.js +107 -0
  5. package/dist/cjs/exp-val-equals-internal.js +0 -2
  6. package/dist/cjs/exp-val-no-exposure.js +15 -0
  7. package/dist/cjs/exp-val.js +31 -0
  8. package/dist/cjs/expVal.js +29 -51
  9. package/dist/cjs/experiments-config.js +298 -305
  10. package/dist/cjs/experiments.js +12 -129
  11. package/dist/cjs/is-boolean.js +9 -0
  12. package/dist/cjs/one-of.js +20 -0
  13. package/dist/cjs/setup.js +0 -1
  14. package/dist/cjs/type-guards.js +1 -27
  15. package/dist/cjs/unstable-editor-experiment-param.js +37 -0
  16. package/dist/es2019/create-boolean-experiment.js +11 -0
  17. package/dist/es2019/{experiment-builders.js → create-multivariate-experiment.js} +1 -12
  18. package/dist/es2019/editor-experiment.js +100 -0
  19. package/dist/es2019/exp-val-equals-internal.js +0 -2
  20. package/dist/es2019/exp-val-no-exposure.js +9 -0
  21. package/dist/es2019/exp-val.js +26 -0
  22. package/dist/es2019/expVal.js +11 -46
  23. package/dist/es2019/experiments-config.js +2 -9
  24. package/dist/es2019/experiments.js +5 -121
  25. package/dist/es2019/is-boolean.js +3 -0
  26. package/dist/es2019/one-of.js +14 -0
  27. package/dist/es2019/setup.js +0 -1
  28. package/dist/es2019/type-guards.js +0 -20
  29. package/dist/es2019/unstable-editor-experiment-param.js +31 -0
  30. package/dist/esm/create-boolean-experiment.js +13 -0
  31. package/dist/esm/{experiment-builders.js → create-multivariate-experiment.js} +1 -11
  32. package/dist/esm/editor-experiment.js +101 -0
  33. package/dist/esm/exp-val-equals-internal.js +0 -2
  34. package/dist/esm/exp-val-no-exposure.js +9 -0
  35. package/dist/esm/exp-val.js +26 -0
  36. package/dist/esm/expVal.js +11 -46
  37. package/dist/esm/experiments-config.js +2 -9
  38. package/dist/esm/experiments.js +5 -122
  39. package/dist/esm/is-boolean.js +3 -0
  40. package/dist/esm/one-of.js +14 -0
  41. package/dist/esm/setup.js +0 -1
  42. package/dist/esm/type-guards.js +0 -20
  43. package/dist/esm/unstable-editor-experiment-param.js +31 -0
  44. package/dist/types/create-boolean-experiment.d.ts +11 -0
  45. package/dist/types/create-multivariate-experiment.d.ts +11 -0
  46. package/dist/types/editor-experiment.d.ts +52 -0
  47. package/dist/types/exp-val-no-exposure.d.ts +2 -0
  48. package/dist/types/exp-val.d.ts +18 -0
  49. package/dist/types/expVal.d.ts +11 -26
  50. package/dist/types/experiments-config.d.ts +1 -7
  51. package/dist/types/experiments.d.ts +4 -63
  52. package/dist/types/is-boolean.d.ts +1 -0
  53. package/dist/types/one-of.d.ts +1 -0
  54. package/dist/types/type-guards.d.ts +8 -2
  55. package/dist/types/unstable-editor-experiment-param.d.ts +15 -0
  56. package/package.json +2 -2
  57. package/dist/types/experiment-builders.d.ts +0 -21
@@ -1,128 +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
- * 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`.
6
+ * @deprecated Use `import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments'` instead.
56
7
  */
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(
89
- // @ts-ignore
90
- experimentKey, experimentConfig.param, experimentConfig.defaultValue, {
91
- typeGuard: experimentConfig.typeGuard,
92
- fireExperimentExposure: options.exposure
93
- });
94
- if (
95
- // When cleaning this gate up -- `calling where the experiments have the product key set`
96
- // in __tests__/experiments should be updated (as it's had the count bumped to include these).
97
- // eslint-disable-next-line @atlaskit/platform/use-recommended-utils
98
- FeatureGates.getExperimentValue('cc_editor_experiments_ufo_gate_reporting', 'isEnabled', false)) {
99
- addFeatureFlagAccessed(`${experimentName}:${experimentConfig.param}`, experimentValue);
100
- }
101
- return expectedExperimentValue === experimentValue;
102
- }
103
-
104
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
105
-
8
+ export { editorExperiment } from './editor-experiment';
106
9
  /**
107
- * @warning This currently lacks type safety on the param names and return values
108
- * and has limited associated test tooling.
109
- *
110
- * It also only works for experiments where the key matches the productKey used.
111
- *
112
- * 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.
113
11
  */
114
- export function unstable_editorExperimentParam(experimentName, paramName, options) {
115
- var _paramOverrides$exper, _options$exposure;
116
- if (((_paramOverrides$exper = _paramOverrides[experimentName]) === null || _paramOverrides$exper === void 0 ? void 0 : _paramOverrides$exper[paramName]) !== undefined) {
117
- // This will be hit in the case of a test setting an override
118
-
119
- return _paramOverrides[experimentName][paramName];
120
- }
121
-
122
- // eslint-disable-next-line @atlaskit/platform/use-recommended-utils
123
- const experimentValue = FeatureGates.getExperimentValue(experimentName, paramName, options.defaultValue, {
124
- typeGuard: options.typeGuard,
125
- fireExperimentExposure: (_options$exposure = options.exposure) !== null && _options$exposure !== void 0 ? _options$exposure : false
126
- });
127
- return experimentValue;
128
- }
12
+ export { unstable_editorExperimentParam } from './unstable-editor-experiment-param';
@@ -0,0 +1,3 @@
1
+ export function isBoolean(value) {
2
+ return typeof value === 'boolean';
3
+ }
@@ -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
+ }
@@ -34,7 +34,6 @@ paramOverrides, options) {
34
34
  // values.
35
35
  // For production usage -- this is done via the feature flag client which takes the type
36
36
  // and performs equivalent logic.
37
- // @ts-ignore
38
37
  groupOverrides = Object.entries(groupOverrides).reduce((acc, [key, value]) => {
39
38
  const config = editorExperimentsConfig[key];
40
39
  if (config) {
@@ -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 { isBoolean, oneOf } from './type-guards';
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
+ }
@@ -25,10 +25,8 @@ var allowsProductKeys = ['cc-maui-experiment', 'cc_maui_create_keyword', 'cc_mau
25
25
  */
26
26
  export function expValEqualsInternal(experimentName, experimentParam, experimentExpectedValue, experimentDefaultValue, experimentExposure) {
27
27
  var _editorExperimentsCon, _editorExperimentsCon2;
28
- // @ts-ignore need to loosen the type here to allow for any experiment name
29
28
  if (_overrides[experimentName] !== undefined) {
30
29
  // This will be hit in the case of a test setting an override
31
- // @ts-ignore need to loosen the type here to allow for any experiment name
32
30
  return _overrides[experimentName] === experimentExpectedValue;
33
31
  }
34
32
 
@@ -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
+ }
@@ -1,9 +1,11 @@
1
- import FeatureGates from '@atlaskit/feature-gate-js-client';
2
- import { fg } from '@atlaskit/platform-feature-flags';
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,
@@ -16,8 +18,6 @@ function expValInternal(_ref) {
16
18
  // We will definitely crash via any code path later in this function - this just makes the error explicit and clear.
17
19
  throw new Error("Editor experiment configuration is not defined ".concat(experimentName, ". Likely the experiment does not exist or editor package versions are misaligned"));
18
20
  }
19
-
20
- // @ts-ignore need to loosen the type here to allow for any experiment name
21
21
  if (_overrides[experimentName] !== undefined) {
22
22
  // This will be hit in the case of a test setting an override
23
23
  // @ts-ignore need to loosen the type here to allow for any experiment name
@@ -63,45 +63,10 @@ function expValInternal(_ref) {
63
63
  }
64
64
 
65
65
  /**
66
- * Use to check a any param value for an experiment
67
- *
68
- * **Note**: this will return the default value when the experiment;
69
- * - is not being served to the client (ie. pre start)
70
- * - or is not configured in experiments-config
71
- *
72
- * If you need to check a param value without an exposure check see {@link expValNoExposure}
73
- *
74
- * @example
75
- * ```ts
76
- * const delay = expVal('experiment-name', 'param-name', defaultValue)
77
- * await new Promise(res => setTimeout(res, delay)
78
- * ```
66
+ * @deprecated Use `import { expVal } from '@atlaskit/tmp-editor-statsig/expVal'` instead.
79
67
  */
80
- export function expVal(experimentName, experimentParam, defaultValue) {
81
- return expValInternal({
82
- experimentName: experimentName,
83
- experimentParam: experimentParam,
84
- defaultValue: defaultValue,
85
- fireExperimentExposure: true
86
- });
87
- } /**
88
- * Use to check a any param value for an experiment without firing an exposure event
89
- *
90
- * **Note**: this will return the default value when the experiment;
91
- * - is not being served to the client (ie. pre start)
92
- * - or is not configured in experiments-config
93
- *
94
- * @example
95
- * ```ts
96
- * const delay = expParamEqualsNoExposure('experiment-name', 'param-name', defaultValue)
97
- * await new Promise(res => setTimeout(res, delay)
98
- * ```
99
- */
100
- export function expValNoExposure(experimentName, experimentParam, defaultValue) {
101
- return expValInternal({
102
- experimentName: experimentName,
103
- experimentParam: experimentParam,
104
- defaultValue: defaultValue,
105
- fireExperimentExposure: false
106
- });
107
- }
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,7 +2,8 @@
2
2
  /* eslint-disable @atlaskit/editor/no-re-export */
3
3
  // Entry file in package.json
4
4
 
5
- import { createBooleanExperiment, createMultivariateExperiment } from './experiment-builders';
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,
@@ -208,14 +209,6 @@ export var editorExperimentsConfig = {
208
209
  param: 'isEnabled',
209
210
  defaultValue: false
210
211
  }),
211
- // Added 2026-07-14
212
- platform_editor_dom_node_count: createBooleanExperiment({
213
- productKeys: {
214
- confluence: 'platform_editor_dom_node_count'
215
- },
216
- param: 'isEnabled',
217
- defaultValue: false
218
- }),
219
212
  // Added 2026-03-26
220
213
  cc_editor_fix_insm_inp_buffer: createBooleanExperiment({
221
214
  productKeys: {
@@ -1,129 +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
- * 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`.
6
+ * @deprecated Use `import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments'` instead.
56
7
  */
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(
90
- // @ts-ignore
91
- experimentKey, experimentConfig.param, experimentConfig.defaultValue, {
92
- typeGuard: experimentConfig.typeGuard,
93
- fireExperimentExposure: options.exposure
94
- });
95
- if (
96
- // When cleaning this gate up -- `calling where the experiments have the product key set`
97
- // in __tests__/experiments should be updated (as it's had the count bumped to include these).
98
- // eslint-disable-next-line @atlaskit/platform/use-recommended-utils
99
- FeatureGates.getExperimentValue('cc_editor_experiments_ufo_gate_reporting', 'isEnabled', false)) {
100
- addFeatureFlagAccessed("".concat(experimentName, ":").concat(experimentConfig.param), experimentValue);
101
- }
102
- return expectedExperimentValue === experimentValue;
103
- }
104
-
105
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
106
-
8
+ export { editorExperiment } from './editor-experiment';
107
9
  /**
108
- * @warning This currently lacks type safety on the param names and return values
109
- * and has limited associated test tooling.
110
- *
111
- * It also only works for experiments where the key matches the productKey used.
112
- *
113
- * 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.
114
11
  */
115
- export function unstable_editorExperimentParam(experimentName, paramName, options) {
116
- var _paramOverrides$exper, _options$exposure;
117
- if (((_paramOverrides$exper = _paramOverrides[experimentName]) === null || _paramOverrides$exper === void 0 ? void 0 : _paramOverrides$exper[paramName]) !== undefined) {
118
- // This will be hit in the case of a test setting an override
119
-
120
- return _paramOverrides[experimentName][paramName];
121
- }
122
-
123
- // eslint-disable-next-line @atlaskit/platform/use-recommended-utils
124
- var experimentValue = FeatureGates.getExperimentValue(experimentName, paramName, options.defaultValue, {
125
- typeGuard: options.typeGuard,
126
- fireExperimentExposure: (_options$exposure = options.exposure) !== null && _options$exposure !== void 0 ? _options$exposure : false
127
- });
128
- return experimentValue;
129
- }
12
+ export { unstable_editorExperimentParam } from './unstable-editor-experiment-param';
@@ -0,0 +1,3 @@
1
+ export function isBoolean(value) {
2
+ return typeof value === 'boolean';
3
+ }