@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
@@ -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/setup.js CHANGED
@@ -38,7 +38,6 @@ paramOverrides, options) {
38
38
  // values.
39
39
  // For production usage -- this is done via the feature flag client which takes the type
40
40
  // and performs equivalent logic.
41
- // @ts-ignore
42
41
  groupOverrides = Object.entries(groupOverrides).reduce(function (acc, _ref) {
43
42
  var _ref2 = _slicedToArray(_ref, 2),
44
43
  key = _ref2[0],
@@ -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;
@@ -1,30 +1,15 @@
1
1
  import type { EditorExperimentsConfig } from './experiments-config';
2
+ export declare function expValInternal<ExperimentName extends keyof EditorExperimentsConfig, DefaultValue extends string | number | boolean>({ experimentName, experimentParam, defaultValue, fireExperimentExposure, }: {
3
+ defaultValue: DefaultValue;
4
+ experimentName: ExperimentName;
5
+ experimentParam: string;
6
+ fireExperimentExposure: boolean;
7
+ }): DefaultValue;
2
8
  /**
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 {@link expValNoExposure}
10
- *
11
- * @example
12
- * ```ts
13
- * const delay = expVal('experiment-name', 'param-name', defaultValue)
14
- * await new Promise(res => setTimeout(res, delay)
15
- * ```
9
+ * @deprecated Use `import { expVal } from '@atlaskit/tmp-editor-statsig/expVal'` instead.
16
10
  */
17
- export declare function expVal<ExperimentName extends keyof EditorExperimentsConfig, DefaultValue extends string | number | boolean>(experimentName: ExperimentName, experimentParam: string, defaultValue: DefaultValue extends boolean ? false : DefaultValue): DefaultValue; /**
18
- * Use to check a any param value for an experiment without firing an exposure event
19
- *
20
- * **Note**: this will return the default value when the experiment;
21
- * - is not being served to the client (ie. pre start)
22
- * - or is not configured in experiments-config
23
- *
24
- * @example
25
- * ```ts
26
- * const delay = expParamEqualsNoExposure('experiment-name', 'param-name', defaultValue)
27
- * await new Promise(res => setTimeout(res, delay)
28
- * ```
11
+ export { expVal } from './exp-val';
12
+ /**
13
+ * @deprecated Use `import { expValNoExposure } from '@atlaskit/tmp-editor-statsig/expVal'` instead.
29
14
  */
30
- export declare function expValNoExposure<ExperimentName extends keyof EditorExperimentsConfig, DefaultValue extends string | number | boolean>(experimentName: ExperimentName, experimentParam: string, defaultValue: DefaultValue extends boolean ? false : DefaultValue): DefaultValue;
15
+ export { expValNoExposure } from './exp-val-no-exposure';
@@ -1,4 +1,4 @@
1
- import { isBoolean } from './type-guards';
1
+ import { isBoolean } from './is-boolean';
2
2
  import type { ProductKeys } from './types';
3
3
  type IsBooleanType = typeof isBoolean;
4
4
  export type EditorExperimentsConfig = typeof editorExperimentsConfig;
@@ -112,12 +112,6 @@ export declare const editorExperimentsConfig: {
112
112
  productKeys?: ProductKeys;
113
113
  typeGuard: IsBooleanType;
114
114
  };
115
- platform_editor_dom_node_count: {
116
- defaultValue: boolean;
117
- param: string;
118
- productKeys?: ProductKeys;
119
- typeGuard: IsBooleanType;
120
- };
121
115
  cc_editor_fix_insm_inp_buffer: {
122
116
  defaultValue: boolean;
123
117
  param: string;
@@ -1,67 +1,8 @@
1
- import type { EditorExperimentsConfig } from './experiments-config';
2
1
  /**
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`.
2
+ * @deprecated Use `import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments'` instead.
49
3
  */
50
- export declare function editorExperiment<ExperimentName extends keyof EditorExperimentsConfig>(experimentName: ExperimentName, expectedExperimentValue: EditorExperimentsConfig[ExperimentName]['defaultValue'], options?: {
51
- exposure: boolean;
52
- }): boolean;
53
- type Unstable_EditorExperimentParams = {};
4
+ export { editorExperiment } from './editor-experiment';
54
5
  /**
55
- * @warning This currently lacks type safety on the param names and return values
56
- * and has limited associated test tooling.
57
- *
58
- * It also only works for experiments where the key matches the productKey used.
59
- *
60
- * The typeguard and default value is also expected to move to the experiment config
6
+ * @deprecated Use `import { unstable_editorExperimentParam } from '@atlaskit/tmp-editor-statsig/experiments'` instead.
61
7
  */
62
- export declare function unstable_editorExperimentParam<ExperimentName extends keyof Unstable_EditorExperimentParams, ParamKey extends Unstable_EditorExperimentParams[ExperimentName]['params'], ParamValue = unknown>(experimentName: ExperimentName, paramName: ParamKey, options: {
63
- defaultValue: ParamValue;
64
- exposure?: boolean;
65
- typeGuard: (value: unknown) => value is ParamValue;
66
- }): ParamValue;
67
- export {};
8
+ export { unstable_editorExperimentParam } from './unstable-editor-experiment-param';
@@ -0,0 +1 @@
1
+ export declare function isBoolean(value: unknown): value is boolean;
@@ -0,0 +1 @@
1
+ export declare function oneOf<T extends string>(values: T[]): (value: unknown) => value is T;
@@ -1,2 +1,8 @@
1
- export declare function isBoolean(value: unknown): value is boolean;
2
- export declare function oneOf<T extends string>(values: T[]): (value: unknown) => value is T;
1
+ type Global = globalThis.Window & typeof globalThis & {
2
+ process: {
3
+ env: {
4
+ JEST_WORKER_ID: string;
5
+ NODE_ENV: string;
6
+ };
7
+ };
8
+ };
@@ -0,0 +1,15 @@
1
+ type Unstable_EditorExperimentParams = {};
2
+ /**
3
+ * @warning This currently lacks type safety on the param names and return values
4
+ * and has limited associated test tooling.
5
+ *
6
+ * It also only works for experiments where the key matches the productKey used.
7
+ *
8
+ * The typeguard and default value is also expected to move to the experiment config
9
+ */
10
+ export declare function unstable_editorExperimentParam<ExperimentName extends keyof Unstable_EditorExperimentParams, ParamKey extends Unstable_EditorExperimentParams[ExperimentName]['params'], ParamValue = unknown>(experimentName: ExperimentName, paramName: ParamKey, options: {
11
+ defaultValue: ParamValue;
12
+ exposure?: boolean;
13
+ typeGuard: (value: unknown) => value is ParamValue;
14
+ }): ParamValue;
15
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/tmp-editor-statsig",
3
- "version": "147.1.0",
3
+ "version": "148.1.0",
4
4
  "description": "Temp plugin to ease use of statsig feature flags until platform feature flags are available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@atlaskit/feature-gate-js-client": "^6.0.0",
29
29
  "@atlaskit/platform-feature-flags": "^2.1.0",
30
- "@atlaskit/react-ufo": "^7.5.0",
30
+ "@atlaskit/react-ufo": "^7.6.0",
31
31
  "@babel/runtime": "^7.0.0"
32
32
  },
33
33
  "platform-feature-flags": {
@@ -1,21 +0,0 @@
1
- import { isBoolean } from './type-guards';
2
- import type { BooleanExperimentConfig, MultivariateExperimentConfig, 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
- };
12
- /**
13
- * Helper to create a multivariate experiment configuration
14
- */
15
- export declare function createMultivariateExperiment<T extends string[]>(config: MultivariateExperimentConfig<T>): {
16
- defaultValue: T[number];
17
- param: string;
18
- productKeys?: ProductKeys;
19
- typeGuard: (value: unknown) => value is T[number];
20
- values: [...T][number][];
21
- };