@funnelsgrove/runtime 0.1.27 → 0.1.28

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.
@@ -7,10 +7,12 @@ export type FunnelExperimentDefinition = {
7
7
  launchDate: string;
8
8
  control: {
9
9
  stepId: string;
10
+ label?: string;
10
11
  trafficPercent: number;
11
12
  };
12
13
  variant: {
13
14
  stepId: string;
15
+ label?: string;
14
16
  trafficPercent: number;
15
17
  };
16
18
  };
@@ -13,13 +13,7 @@ export const toManifestExperiments = (experiments) => experiments
13
13
  experimentId: experiment.id,
14
14
  stepId: experiment.control.stepId,
15
15
  variants: [
16
- {
17
- variantKey: 'control',
18
- routeToStepId: experiment.control.stepId,
19
- },
20
- {
21
- variantKey: 'variant_b',
22
- routeToStepId: experiment.variant.stepId,
23
- },
16
+ Object.assign(Object.assign({ variantKey: 'control' }, (experiment.control.label ? { label: experiment.control.label } : {})), { trafficPercent: experiment.control.trafficPercent, routeToStepId: experiment.control.stepId }),
17
+ Object.assign(Object.assign({ variantKey: 'variant_b' }, (experiment.variant.label ? { label: experiment.variant.label } : {})), { trafficPercent: experiment.variant.trafficPercent, routeToStepId: experiment.variant.stepId }),
24
18
  ],
25
19
  }));
@@ -9,6 +9,7 @@ export type FunnelManifestStep = {
9
9
  kind?: FunnelStepKind;
10
10
  name?: string;
11
11
  title: string;
12
+ tags?: readonly string[];
12
13
  assetIds?: readonly string[];
13
14
  };
14
15
  export type FunnelManifestImageAsset = {
@@ -28,8 +29,19 @@ export type FunnelManifestEdge = {
28
29
  toStepId: string;
29
30
  conditionId?: string;
30
31
  };
32
+ export type FunnelManifestBranch = {
33
+ id: string;
34
+ name: string;
35
+ sourceStepId: string;
36
+ conditionId?: string;
37
+ label?: string;
38
+ tags?: readonly string[];
39
+ stepIds: readonly string[];
40
+ };
31
41
  export type FunnelManifestExperimentVariant = {
32
42
  variantKey: string;
43
+ label?: string;
44
+ trafficPercent?: number;
33
45
  routeToStepId: string;
34
46
  };
35
47
  export type FunnelManifestExperiment = {
@@ -51,6 +63,7 @@ export type FunnelManifest = {
51
63
  steps: readonly FunnelManifestStep[];
52
64
  entryPoints?: readonly FunnelManifestEntryPoint[];
53
65
  edgesByStepId: Partial<Record<string, readonly FunnelManifestEdge[]>>;
66
+ branches?: readonly FunnelManifestBranch[];
54
67
  experiments: readonly FunnelManifestExperiment[];
55
68
  };
56
69
  export type FunnelStepComponentKey = string;
@@ -46,6 +46,22 @@ export const validateFunnelManifest = (manifest) => {
46
46
  assertValidReference(`edge from "${stepId}"`, edge.toStepId, validStepIds, errors);
47
47
  }
48
48
  }
49
+ pushDuplicateErrors('branch ids', (manifest.branches || []).map((branch) => branch.id), errors);
50
+ for (const branch of manifest.branches || []) {
51
+ if (!isDefinedString(branch.id)) {
52
+ errors.push('branch id is required');
53
+ }
54
+ if (!isDefinedString(branch.name)) {
55
+ errors.push(`branch "${branch.id || ''}" name is required`);
56
+ }
57
+ assertValidReference(`branch "${branch.id}" source`, branch.sourceStepId, validStepIds, errors);
58
+ if (branch.stepIds.length === 0) {
59
+ errors.push(`branch "${branch.id}" must own at least one step`);
60
+ }
61
+ for (const stepId of branch.stepIds) {
62
+ assertValidReference(`branch "${branch.id}" step`, stepId, validStepIds, errors);
63
+ }
64
+ }
49
65
  for (const experiment of manifest.experiments) {
50
66
  assertValidReference(`experiment "${experiment.experimentId}"`, experiment.stepId, validStepIds, errors);
51
67
  for (const variant of experiment.variants) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/runtime",
3
- "version": "0.1.27",
3
+ "version": "0.1.28",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",