123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- import type {experimentList, unassignedValue} from 'sentry/data/experimentConfig';
- export enum ExperimentType {
- ORGANIZATION = 'organization',
- USER = 'user',
- }
- export type ExperimentConfig = {
-
- assignments: ReadonlyArray<string | number | typeof unassignedValue>;
-
- key: string;
-
- parameter: string | 'variant' | 'exposed';
-
- type: ExperimentType;
- };
- type ExperimentList = (typeof experimentList)[number];
- type ExperimentSelect<
- C extends ExperimentConfig,
- N extends ExperimentConfig['key'],
- > = C extends {key: N} ? C : never;
- type TypeSelect<
- C extends ExperimentConfig,
- T extends ExperimentConfig['type'],
- > = C extends {type: T} ? C : never;
- export type Experiments = {
- [E in ExperimentList['key']]: ExperimentSelect<ExperimentList, E>;
- };
- export type ExperimentKey = keyof Experiments;
- type GetExperimentAssignment<E extends ExperimentList['key']> = {
- [K in E]: Experiments[K]['assignments'][number];
- };
- export type OrgExperiments = GetExperimentAssignment<
- TypeSelect<ExperimentList, ExperimentType.ORGANIZATION>['key']
- >;
- export type UserExperiments = GetExperimentAssignment<
- TypeSelect<ExperimentList, ExperimentType.USER>['key']
- >;
- export type ExperimentAssignment = GetExperimentAssignment<ExperimentList['key']>;
|