@delmaredigital/payload-experiments 0.3.0-rc.1 → 0.4.0-rc.1
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/README.md +172 -21
- package/dist/admin/MetricSourceSelect.js +3 -3
- package/dist/admin/PlacementStatus.d.ts +3 -0
- package/dist/admin/PlacementStatus.js +54 -0
- package/dist/admin/PreviewLinks.d.ts +2 -1
- package/dist/admin/PreviewLinks.js +47 -26
- package/dist/admin/TestsNavLink.d.ts +3 -1
- package/dist/admin/TestsNavLink.js +2 -2
- package/dist/admin/actions/ConfirmDialog.d.ts +2 -1
- package/dist/admin/actions/ConfirmDialog.js +2 -2
- package/dist/admin/actions/DecideDialog.d.ts +2 -1
- package/dist/admin/actions/DecideDialog.js +2 -2
- package/dist/admin/api.d.ts +11 -2
- package/dist/admin/api.js +20 -2
- package/dist/admin/armSelect/ArmSelectField.js +14 -22
- package/dist/admin/arms/arms.model.d.ts +1 -21
- package/dist/admin/arms/arms.model.js +1 -153
- package/dist/admin/blocks/BlockPanel.d.ts +4 -0
- package/dist/admin/blocks/BlockPanel.js +153 -0
- package/dist/admin/blocks/TestBlockField.d.ts +5 -0
- package/dist/admin/blocks/TestBlockField.js +163 -0
- package/dist/admin/blocks/formApi.d.ts +43 -0
- package/dist/admin/blocks/formApi.js +153 -0
- package/dist/admin/blocks/inject.d.ts +7 -0
- package/dist/admin/blocks/inject.js +41 -0
- package/dist/admin/blocks/model.d.ts +17 -0
- package/dist/admin/blocks/model.js +45 -0
- package/dist/admin/blocks/statusCache.d.ts +7 -0
- package/dist/admin/blocks/statusCache.js +83 -0
- package/dist/admin/blocks/useBlockForm.d.ts +17 -0
- package/dist/admin/blocks/useBlockForm.js +46 -0
- package/dist/admin/copy/actions.d.ts +2 -0
- package/dist/admin/copy/actions.js +9 -0
- package/dist/admin/copy/arms.d.ts +1 -6
- package/dist/admin/copy/arms.js +1 -16
- package/dist/admin/copy/blocks.d.ts +27 -0
- package/dist/admin/copy/blocks.js +38 -0
- package/dist/admin/copy/goals.d.ts +2 -0
- package/dist/admin/copy/goals.js +4 -1
- package/dist/admin/copy/newTest.d.ts +10 -0
- package/dist/admin/copy/newTest.js +10 -0
- package/dist/admin/copy/pages.d.ts +26 -0
- package/dist/admin/copy/pages.js +26 -0
- package/dist/admin/copy/readiness.d.ts +25 -3
- package/dist/admin/copy/readiness.js +25 -3
- package/dist/admin/copy/results.d.ts +3 -0
- package/dist/admin/copy/results.js +4 -1
- package/dist/admin/copy/review.d.ts +1 -1
- package/dist/admin/copy/review.js +1 -1
- package/dist/admin/copy/surface.d.ts +0 -1
- package/dist/admin/copy/surface.js +0 -1
- package/dist/admin/copy/testPage.d.ts +4 -0
- package/dist/admin/copy/testPage.js +4 -0
- package/dist/admin/goals/XpGoalField.d.ts +2 -0
- package/dist/admin/goals/XpGoalField.js +152 -0
- package/dist/admin/metricSource.model.d.ts +2 -0
- package/dist/admin/metricSource.model.js +4 -0
- package/dist/admin/pageCollections.d.ts +10 -0
- package/dist/admin/pageCollections.js +20 -0
- package/dist/admin/paths.d.ts +8 -1
- package/dist/admin/paths.js +8 -1
- package/dist/admin/placementStatus.model.d.ts +2 -0
- package/dist/admin/placementStatus.model.js +19 -0
- package/dist/admin/placements/placementLabels.d.ts +11 -0
- package/dist/admin/placements/placementLabels.js +21 -0
- package/dist/admin/placements/placementLabels.model.d.ts +13 -0
- package/dist/admin/placements/placementLabels.model.js +12 -0
- package/dist/admin/placements/usePlacementLabels.d.ts +12 -0
- package/dist/admin/placements/usePlacementLabels.js +102 -0
- package/dist/admin/previewLinks.model.d.ts +2 -0
- package/dist/admin/previewLinks.model.js +3 -0
- package/dist/admin/results/DataQualityPanel.js +4 -1
- package/dist/admin/results/legacy.d.ts +16 -0
- package/dist/admin/results/legacy.js +27 -0
- package/dist/admin/results/results.model.d.ts +9 -6
- package/dist/admin/results/results.model.js +22 -9
- package/dist/admin/results/snapshot.d.ts +14 -0
- package/dist/admin/results/snapshot.js +3 -0
- package/dist/admin/surface/TestsHome.js +43 -15
- package/dist/admin/surface/TestsSurface.js +5 -1
- package/dist/admin/surface/contracts.d.ts +6 -5
- package/dist/admin/surface/goals/GoalForm.js +67 -34
- package/dist/admin/surface/goals/GoalsList.js +3 -3
- package/dist/admin/surface/goals/data.js +19 -16
- package/dist/admin/surface/goals/goals.model.d.ts +1 -2
- package/dist/admin/surface/goals/goals.model.js +1 -3
- package/dist/admin/surface/home.model.d.ts +2 -1
- package/dist/admin/surface/home.model.js +8 -4
- package/dist/admin/surface/newTest/NewTest.js +58 -17
- package/dist/admin/surface/newTest/PageWizard.d.ts +7 -0
- package/dist/admin/surface/newTest/PageWizard.js +209 -0
- package/dist/admin/surface/pagePicker/CopyRoute.d.ts +6 -0
- package/dist/admin/surface/pagePicker/CopyRoute.js +53 -0
- package/dist/admin/surface/pagePicker/PagePicker.d.ts +10 -0
- package/dist/admin/surface/pagePicker/PagePicker.js +172 -0
- package/dist/admin/surface/pagePicker/pagePicker.model.d.ts +25 -0
- package/dist/admin/surface/pagePicker/pagePicker.model.js +25 -0
- package/dist/admin/surface/readiness/ActionDialogs.js +103 -69
- package/dist/admin/surface/readiness/Banner.js +30 -6
- package/dist/admin/surface/readiness/readiness.model.d.ts +8 -1
- package/dist/admin/surface/readiness/readiness.model.js +95 -6
- package/dist/admin/surface/results/ReleasePages.d.ts +3 -1
- package/dist/admin/surface/results/ReleasePages.js +3 -7
- package/dist/admin/surface/results/ResultsBody.js +23 -3
- package/dist/admin/surface/results/ResultsHeader.js +2 -5
- package/dist/admin/surface/results/recommendation.model.d.ts +3 -2
- package/dist/admin/surface/results/recommendation.model.js +10 -3
- package/dist/admin/surface/results/useResults.d.ts +10 -1
- package/dist/admin/surface/surface.css +0 -1
- package/dist/admin/surface/test/AdvancedSection.js +111 -104
- package/dist/admin/surface/test/GoalSection.js +97 -22
- package/dist/admin/surface/test/LengthSection.js +1 -1
- package/dist/admin/surface/test/PageHoldout.d.ts +3 -0
- package/dist/admin/surface/test/PageHoldout.js +67 -0
- package/dist/admin/surface/test/TestPage.js +2 -1
- package/dist/admin/surface/test/VersionsSection.js +12 -5
- package/dist/admin/surface/test/fields.d.ts +13 -4
- package/dist/admin/surface/test/fields.js +46 -14
- package/dist/admin/surface/test/jumpToSection.d.ts +1 -1
- package/dist/admin/surface/test/jumpToSection.js +4 -3
- package/dist/admin/surface/test/pageParts.d.ts +4 -1
- package/dist/admin/surface/test/pageParts.js +79 -2
- package/dist/admin/surface/test/testPage.css +8 -1
- package/dist/admin/surface/test/testPage.model.d.ts +2 -3
- package/dist/admin/surface/test/testPage.model.js +1 -21
- package/dist/admin/surface/testDocument.model.d.ts +1 -0
- package/dist/admin/surface/testDocument.model.js +2 -1
- package/dist/admin/surface/useTestDocument.d.ts +11 -2
- package/dist/admin/surface/useTestDocument.js +55 -16
- package/dist/admin/useApi.d.ts +11 -2
- package/dist/admin/useApi.js +3 -5
- package/dist/admin/useLayerUsage.js +14 -23
- package/dist/admin/views/ExperimentsRootView.js +58 -16
- package/dist/admin/views/TestsNavLinkServer.d.ts +2 -0
- package/dist/admin/views/TestsNavLinkServer.js +43 -0
- package/dist/arms/copy.d.ts +6 -0
- package/dist/arms/copy.js +16 -0
- package/dist/arms/model.d.ts +23 -0
- package/dist/arms/model.js +173 -0
- package/dist/blocks/bindings.d.ts +3 -0
- package/dist/blocks/bindings.js +34 -0
- package/dist/blocks/createExperimentBlock.d.ts +6 -0
- package/dist/blocks/createExperimentBlock.js +77 -0
- package/dist/blocks/formState.d.ts +31 -0
- package/dist/blocks/formState.js +146 -0
- package/dist/blocks/model.d.ts +41 -0
- package/dist/blocks/model.js +34 -0
- package/dist/client/ExperimentGroup.d.ts +6 -0
- package/dist/client/ExperimentGroup.js +9 -0
- package/dist/client/ExperimentsProvider.js +20 -4
- package/dist/client/clickGoals.d.ts +4 -0
- package/dist/client/clickGoals.js +43 -0
- package/dist/collections/experiments/config.js +12 -2
- package/dist/collections/experiments/deleteGuard.d.ts +2 -1
- package/dist/collections/experiments/deleteGuard.js +12 -1
- package/dist/collections/experiments/editability.js +4 -2
- package/dist/collections/experiments/pickSlug.d.ts +2 -0
- package/dist/collections/experiments/pickSlug.js +8 -0
- package/dist/collections/labels.d.ts +3 -0
- package/dist/collections/labels.js +20 -0
- package/dist/collections/metrics.js +12 -2
- package/dist/collections/phases.js +1 -0
- package/dist/collections/serialize.js +7 -0
- package/dist/db/appends.d.ts +6 -2
- package/dist/db/appends.js +10 -4
- package/dist/db/clickGoals.d.ts +9 -0
- package/dist/db/clickGoals.js +22 -0
- package/dist/db/delete.d.ts +1 -0
- package/dist/db/delete.js +1 -0
- package/dist/db/locks.d.ts +14 -0
- package/dist/db/locks.js +36 -1
- package/dist/db/names.d.ts +4 -0
- package/dist/db/names.js +4 -0
- package/dist/db/pageBindings.d.ts +4 -0
- package/dist/db/pageBindings.js +17 -0
- package/dist/db/pageBusy.d.ts +2 -0
- package/dist/db/pageBusy.js +10 -0
- package/dist/db/pageContent.d.ts +10 -0
- package/dist/db/pageContent.js +79 -0
- package/dist/db/pageOccupancy.d.ts +12 -0
- package/dist/db/pageOccupancy.js +45 -0
- package/dist/db/placements.d.ts +33 -0
- package/dist/db/placements.js +54 -0
- package/dist/db/slugs.d.ts +8 -0
- package/dist/db/slugs.js +40 -0
- package/dist/db/snapshots.d.ts +6 -0
- package/dist/db/snapshots.js +9 -5
- package/dist/endpoints/clickKeys.d.ts +5 -0
- package/dist/endpoints/clickKeys.js +17 -0
- package/dist/endpoints/events.js +4 -1
- package/dist/endpoints/index.js +28 -0
- package/dist/endpoints/pages.d.ts +5 -0
- package/dist/endpoints/pages.js +120 -0
- package/dist/endpoints/placementStatus.d.ts +6 -0
- package/dist/endpoints/placementStatus.js +238 -0
- package/dist/endpoints/readBody.d.ts +2 -0
- package/dist/endpoints/readBody.js +24 -0
- package/dist/endpoints/results.js +5 -1
- package/dist/endpoints/summary.js +11 -4
- package/dist/endpoints/wrapBlock.d.ts +6 -0
- package/dist/endpoints/wrapBlock.js +76 -0
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +4 -4
- package/dist/events/rows.d.ts +1 -1
- package/dist/events/rows.js +5 -3
- package/dist/exports/adminClient.d.ts +5 -0
- package/dist/exports/adminClient.js +5 -0
- package/dist/exports/adminRsc.d.ts +1 -0
- package/dist/exports/adminRsc.js +1 -0
- package/dist/exports/blocks.d.ts +2 -0
- package/dist/exports/blocks.js +1 -0
- package/dist/exports/client.d.ts +1 -0
- package/dist/exports/client.js +1 -0
- package/dist/exports/index.d.ts +6 -1
- package/dist/exports/index.js +3 -0
- package/dist/exports/puck.d.ts +5 -2
- package/dist/exports/puck.js +3 -1
- package/dist/exports/puckEditor.d.ts +6 -1
- package/dist/exports/puckEditor.js +4 -1
- package/dist/exports/rsc.d.ts +4 -0
- package/dist/exports/rsc.js +2 -0
- package/dist/fields/xpGoal.d.ts +3 -0
- package/dist/fields/xpGoal.js +28 -0
- package/dist/globals/state.js +10 -0
- package/dist/goals/cache.d.ts +3 -0
- package/dist/goals/cache.js +35 -0
- package/dist/goals/fairness.d.ts +40 -0
- package/dist/goals/fairness.js +200 -0
- package/dist/goals/key.d.ts +4 -0
- package/dist/goals/key.js +3 -0
- package/dist/goals/picker/clickGoalPicker.model.d.ts +29 -0
- package/dist/goals/picker/clickGoalPicker.model.js +45 -0
- package/dist/goals/picker/copy.d.ts +16 -0
- package/dist/goals/picker/copy.js +15 -0
- package/dist/goals/picker/useClickGoalPicker.d.ts +30 -0
- package/dist/goals/picker/useClickGoalPicker.js +220 -0
- package/dist/hooks/pageGuard.d.ts +5 -1
- package/dist/hooks/pageGuard.js +160 -80
- package/dist/lib/fetchAllDocs.d.ts +16 -0
- package/dist/lib/fetchAllDocs.js +56 -0
- package/dist/onInit.js +29 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +43 -10
- package/dist/plugin.js +45 -28
- package/dist/puck/ExperimentPicker.js +47 -16
- package/dist/puck/ExperimentSlot.d.ts +51 -1
- package/dist/puck/ExperimentSlot.js +23 -12
- package/dist/puck/copy.d.ts +6 -4
- package/dist/puck/copy.js +6 -4
- package/dist/puck/editor/CreateExperimentDrawer.js +46 -56
- package/dist/puck/editor/ExperimentSlotEditor.d.ts +52 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +292 -137
- package/dist/puck/editor/ResultsReadout.d.ts +6 -0
- package/dist/puck/editor/ResultsReadout.js +99 -0
- package/dist/puck/editor/VersionBuilder.d.ts +34 -0
- package/dist/puck/editor/VersionBuilder.js +317 -0
- package/dist/puck/editor/armWrites.d.ts +7 -0
- package/dist/puck/editor/armWrites.js +71 -0
- package/dist/puck/editor/armsCache.d.ts +14 -0
- package/dist/puck/editor/armsCache.js +78 -0
- package/dist/puck/editor/copy.d.ts +33 -1
- package/dist/puck/editor/copy.js +45 -8
- package/dist/puck/editor/createTest.d.ts +1 -1
- package/dist/puck/editor/createTest.js +25 -14
- package/dist/puck/editor/editor.chrome.css +48 -161
- package/dist/puck/editor/editor.css +48 -161
- package/dist/puck/editor/editor.model.d.ts +8 -3
- package/dist/puck/editor/editor.model.js +16 -10
- package/dist/puck/editor/experimentOutlinePlugin.d.ts +3 -0
- package/dist/puck/editor/experimentOutlinePlugin.js +89 -0
- package/dist/puck/editor/integration.d.ts +10 -0
- package/dist/puck/editor/integration.js +30 -0
- package/dist/puck/editor/xpGoalPuckEditorField.d.ts +7 -0
- package/dist/puck/editor/xpGoalPuckEditorField.js +134 -0
- package/dist/puck/experimentSlotField.d.ts +2 -0
- package/dist/puck/experimentSlotField.js +11 -3
- package/dist/puck/hostContext.d.ts +10 -0
- package/dist/puck/hostContext.js +12 -0
- package/dist/puck/integration.d.ts +6 -0
- package/dist/puck/integration.js +21 -0
- package/dist/puck/routes.d.ts +12 -0
- package/dist/puck/routes.js +11 -0
- package/dist/puck/slotConfig.d.ts +1 -1
- package/dist/puck/slotConfig.js +2 -2
- package/dist/puck/xpGoalField.d.ts +3 -0
- package/dist/puck/xpGoalField.js +6 -0
- package/dist/results/health.d.ts +4 -0
- package/dist/results/health.js +27 -0
- package/dist/results/snapshot.js +15 -2
- package/dist/sanitizeReadinessDetail.js +51 -1
- package/dist/server/metadata.js +9 -2
- package/dist/server/normaliseContentRelationships.d.ts +7 -0
- package/dist/server/normaliseContentRelationships.js +62 -0
- package/dist/server/pageKindSeoContract.d.ts +27 -0
- package/dist/server/pageKindSeoContract.js +80 -0
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +72 -13
- package/dist/server/resolveExperimentBlocks.d.ts +5 -0
- package/dist/server/resolveExperimentBlocks.js +54 -0
- package/dist/server/runResults.js +92 -19
- package/dist/server/toClientAssignments.js +2 -1
- package/dist/transitions/addMetric.d.ts +2 -1
- package/dist/transitions/addMetric.js +28 -1
- package/dist/transitions/checkStart.d.ts +17 -1
- package/dist/transitions/checkStart.js +99 -7
- package/dist/transitions/decide.js +40 -1
- package/dist/transitions/deleteExperiment.d.ts +3 -1
- package/dist/transitions/deleteExperiment.js +27 -1
- package/dist/transitions/kernel.js +4 -0
- package/dist/transitions/makeContent.d.ts +5 -0
- package/dist/transitions/makeContent.js +39 -11
- package/dist/transitions/pageCollection.d.ts +10 -0
- package/dist/transitions/pageCollection.js +20 -0
- package/dist/transitions/pageVersions.d.ts +10 -0
- package/dist/transitions/pageVersions.js +44 -0
- package/dist/transitions/phaseRecord.d.ts +1 -0
- package/dist/transitions/placementInteractions.d.ts +40 -0
- package/dist/transitions/placementInteractions.js +94 -0
- package/dist/transitions/placements.d.ts +10 -6
- package/dist/transitions/placements.js +156 -2
- package/dist/transitions/preflightData.d.ts +8 -0
- package/dist/transitions/preflightData.js +248 -36
- package/dist/transitions/resolveCaps.d.ts +1 -0
- package/dist/transitions/resolveCaps.js +6 -2
- package/dist/transitions/start.js +77 -3
- package/dist/types/admin.d.ts +1 -1
- package/dist/types/assignments.d.ts +1 -0
- package/dist/types/contracts.d.ts +31 -10
- package/dist/types/endpoints.d.ts +92 -5
- package/dist/types/index.d.ts +3 -0
- package/dist/types/puck.d.ts +7 -1
- package/dist/types/snapshot.d.ts +17 -4
- package/dist/types/surface.d.ts +13 -0
- package/dist/ui/Tabs.d.ts +4 -2
- package/dist/ui/Tabs.js +33 -26
- package/dist/ui/accent.d.ts +22 -3
- package/dist/ui/accent.js +74 -16
- package/package.json +12 -2
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { formatDate } from '../../format/date.js';
|
|
2
2
|
import { armLabel } from '../../labels.js';
|
|
3
3
|
import { formatCount, formatPercent } from '../../results/format.js';
|
|
4
|
+
import { RESULTS_COPY } from '../../copy/results.js';
|
|
5
|
+
import { legacyRecommendationWinner } from '../../results/legacy.js';
|
|
6
|
+
import { isLegacySnapshot } from '../../results/snapshot.js';
|
|
4
7
|
import { RECOMMENDATION_COPY as C, collectingRecommendation, guardrailRecommendation, mixedRecommendation, rolloutCollectingRecommendation, rolloutReadoutRecommendation, runningRecommendation, winnerRecommendation, worseRecommendation, storedGuardrailFinding } from '../../copy/recommendation.js';
|
|
5
8
|
function label(ctx, key, fallback = C.group) {
|
|
6
9
|
const stored = ctx.phase?.arms.find((arm)=>arm.key === key)?.label.trim();
|
|
@@ -14,7 +17,10 @@ function label(ctx, key, fallback = C.group) {
|
|
|
14
17
|
}
|
|
15
18
|
const primary = ({ snapshot })=>snapshot.metrics.find((metric)=>metric.role === 'primary');
|
|
16
19
|
const worse = (ctx)=>primary(ctx)?.comparisons.find((comparison)=>comparison.significant === 'worse' && ctx.phase?.arms.some((arm)=>arm.key === comparison.arm && arm.kind === 'variant'))?.arm;
|
|
17
|
-
const
|
|
20
|
+
const rolloutWinner = (ctx)=>isLegacySnapshot(ctx.snapshot) ? legacyRecommendationWinner(ctx.snapshot, ctx.phase) : {
|
|
21
|
+
key: ctx.snapshot.winnerArm,
|
|
22
|
+
label: label(ctx, ctx.snapshot.winnerArm)
|
|
23
|
+
};
|
|
18
24
|
/** Select stored findings and format them; never run inference in the admin. */ export const RECOMMENDATION = {
|
|
19
25
|
unavailable: ()=>C.unavailable,
|
|
20
26
|
'data-problem': ()=>C.dataProblem,
|
|
@@ -46,10 +52,11 @@ const winner = (ctx)=>label(ctx, ctx.snapshot.winnerArm ?? ctx.snapshot.verdict.
|
|
|
46
52
|
return Number.isFinite(end) ? runningRecommendation(formatDate(end)) : C.keepRunning;
|
|
47
53
|
},
|
|
48
54
|
'no-difference': ()=>C.noDifference,
|
|
49
|
-
'rollout-collecting': (ctx)=>rolloutCollectingRecommendation(
|
|
50
|
-
'rollout-readout': (ctx)=>rolloutReadoutRecommendation(
|
|
55
|
+
'rollout-collecting': (ctx)=>rolloutCollectingRecommendation(rolloutWinner(ctx).label),
|
|
56
|
+
'rollout-readout': (ctx)=>rolloutReadoutRecommendation(rolloutWinner(ctx).label, formatPercent(primary(ctx)?.comparisons.find((comparison)=>comparison.arm === rolloutWinner(ctx).key)?.lift, true))
|
|
51
57
|
};
|
|
52
58
|
export const recommendation = (ctx)=>{
|
|
59
|
+
if (!isLegacySnapshot(ctx.snapshot) && ctx.snapshot.phaseKind === 'rollout' && ctx.snapshot.winnerArm === null) return RESULTS_COPY.missingWinner;
|
|
53
60
|
const sentence = RECOMMENDATION[ctx.snapshot.verdict.code];
|
|
54
61
|
return sentence(ctx);
|
|
55
62
|
};
|
|
@@ -29,6 +29,14 @@ export declare function useResults(id: DocId, { apiRoute, canReadResults, canMan
|
|
|
29
29
|
canManage?: boolean;
|
|
30
30
|
}): {
|
|
31
31
|
api: {
|
|
32
|
+
wrapBlock: (body: import("../../../types/endpoints.js").WrapBlockBody) => Promise<ApiResult<Record<string, unknown>>>;
|
|
33
|
+
pages: (query: {
|
|
34
|
+
collection: string;
|
|
35
|
+
q?: string;
|
|
36
|
+
path?: string;
|
|
37
|
+
page?: number;
|
|
38
|
+
}, signal?: AbortSignal) => Promise<ApiResult<import("../../../types/endpoints.js").PagesResult>>;
|
|
39
|
+
placementStatus: (body: import("../../../types/endpoints.js").PlacementStatusBody) => Promise<ApiResult<import("../../../types/endpoints.js").PlacementStatusResult>>;
|
|
32
40
|
start: (id: DocId) => Promise<ApiResult<import("../../../types/endpoints.js").TransitionSuccess>>;
|
|
33
41
|
allocate: (id: DocId, body: import("../../../types/endpoints.js").AllocateBody, options?: {
|
|
34
42
|
notFound?: string;
|
|
@@ -39,7 +47,7 @@ export declare function useResults(id: DocId, { apiRoute, canReadResults, canMan
|
|
|
39
47
|
notFound?: string;
|
|
40
48
|
codes?: Readonly<Record<string, string>>;
|
|
41
49
|
fallback?: string;
|
|
42
|
-
}) => Promise<ApiResult<import("../../../types/endpoints.js").
|
|
50
|
+
}) => Promise<ApiResult<import("../../../types/endpoints.js").AddMetricResult>>;
|
|
43
51
|
stop: (id: DocId) => Promise<ApiResult<import("../../../types/endpoints.js").TransitionSuccess>>;
|
|
44
52
|
decide: (id: DocId, body: import("../../../types/endpoints.js").DecideBody) => Promise<ApiResult<import("../../../types/endpoints.js").TransitionSuccess>>;
|
|
45
53
|
releaseHoldout: (id: DocId) => Promise<ApiResult<import("../../../types/endpoints.js").TransitionSuccess>>;
|
|
@@ -48,6 +56,7 @@ export declare function useResults(id: DocId, { apiRoute, canReadResults, canMan
|
|
|
48
56
|
dismissContentEntry: (id: DocId, body: import("../../../types/endpoints.js").DismissContentEntryBody) => Promise<ApiResult<import("../../../types/endpoints.js").DismissContentEntryResult>>;
|
|
49
57
|
restoreContentEntry: (id: DocId, body: import("../../../types/endpoints.js").RestoreContentEntryBody) => Promise<ApiResult<import("../../../types/endpoints.js").RestoreContentEntryResult>>;
|
|
50
58
|
archive: (id: DocId, body: import("../../../types/endpoints.js").ArchiveBody) => Promise<ApiResult<import("../../../types/endpoints.js").TransitionSuccess>>;
|
|
59
|
+
clickKeys: (id: DocId) => Promise<ApiResult<import("../../../types/endpoints.js").ClickKeysResult>>;
|
|
51
60
|
preflight: (id: DocId) => Promise<ApiResult<import("../../../types/endpoints.js").PreflightResult>>;
|
|
52
61
|
previewToken: (id: DocId, arm: string) => Promise<ApiResult<import("../../../types/endpoints.js").PreviewTokenResult>>;
|
|
53
62
|
results: (id: DocId, options?: {
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
.xp-tests-group-chevron { align-self: center; color: var(--xp-text-3); }
|
|
44
44
|
.xp-tests-group[open] .xp-tests-group-chevron { transform: rotate(90deg); }
|
|
45
45
|
.xp-tests-group > summary + .xp-tests-list { margin-top: 10px; }
|
|
46
|
-
.xp-tests-limited { margin-top: var(--xp-space-4); color: var(--xp-text-2); font: var(--xp-text-small); }
|
|
47
46
|
.xp-tests-no-matches { display: flex; flex-wrap: wrap; align-items: center; gap: var(--xp-space-2); }
|
|
48
47
|
.xp-tests-no-matches p { margin: 0; }
|
|
49
48
|
@media (max-width: 720px) {
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { ADVANCED_COPY as C } from '../../copy/advanced.js';
|
|
4
4
|
import { exposureOptions } from './testPage.model.js';
|
|
5
5
|
import { FieldErrors, positiveInteger, ReadOnly, reasonFor, save, SelectEdit, TextEdit } from './fields.js';
|
|
6
|
+
import { PageHoldout } from './PageHoldout.js';
|
|
6
7
|
import { Section } from './Section.js';
|
|
7
8
|
const readOnlyFields = [
|
|
8
9
|
'layer',
|
|
@@ -36,125 +37,131 @@ export function AdvancedSection({ test, surface }) {
|
|
|
36
37
|
0
|
|
37
38
|
]
|
|
38
39
|
];
|
|
39
|
-
return /*#__PURE__*/
|
|
40
|
+
return /*#__PURE__*/ _jsxs(Section, {
|
|
40
41
|
test: test,
|
|
41
42
|
sectionId: "advanced",
|
|
42
|
-
children:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
options: exposureOptions(doc.kind).map((value)=>({
|
|
52
|
-
value,
|
|
53
|
-
label: C.policies[value]
|
|
54
|
-
})),
|
|
55
|
-
onCommit: (value)=>save(test, 'exposurePolicy', ()=>({
|
|
56
|
-
exposurePolicy: value
|
|
57
|
-
}))
|
|
58
|
-
}),
|
|
59
|
-
/*#__PURE__*/ _jsx("p", {
|
|
60
|
-
children: C.exposurePolicy.help
|
|
61
|
-
}),
|
|
62
|
-
/*#__PURE__*/ _jsx(FieldErrors, {
|
|
63
|
-
test: test,
|
|
64
|
-
path: "exposurePolicy"
|
|
65
|
-
})
|
|
66
|
-
]
|
|
67
|
-
}),
|
|
68
|
-
surface.isAdmin ? /*#__PURE__*/ _jsxs("div", {
|
|
69
|
-
children: [
|
|
70
|
-
/*#__PURE__*/ _jsx(SelectEdit, {
|
|
71
|
-
label: C.method.label,
|
|
72
|
-
value: doc.analysis?.method ?? 'sequential',
|
|
73
|
-
reason: reason,
|
|
74
|
-
options: [
|
|
75
|
-
{
|
|
76
|
-
value: 'sequential',
|
|
77
|
-
label: C.sequential
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
value: 'bayesian',
|
|
81
|
-
label: C.bayesian
|
|
82
|
-
}
|
|
83
|
-
],
|
|
84
|
-
onCommit: (value)=>change('method', value)
|
|
85
|
-
}),
|
|
86
|
-
/*#__PURE__*/ _jsx("p", {
|
|
87
|
-
children: C.method.help
|
|
88
|
-
}),
|
|
89
|
-
/*#__PURE__*/ _jsx(FieldErrors, {
|
|
90
|
-
test: test,
|
|
91
|
-
path: "analysis.method"
|
|
92
|
-
})
|
|
93
|
-
]
|
|
94
|
-
}) : null,
|
|
95
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
96
|
-
children: [
|
|
97
|
-
/*#__PURE__*/ _jsx(SelectEdit, {
|
|
98
|
-
label: C.cuped.label,
|
|
99
|
-
value: doc.analysis?.cuped ?? 'auto',
|
|
100
|
-
reason: reason,
|
|
101
|
-
options: [
|
|
102
|
-
{
|
|
103
|
-
value: 'auto',
|
|
104
|
-
label: C.auto
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
value: 'off',
|
|
108
|
-
label: C.off
|
|
109
|
-
}
|
|
110
|
-
],
|
|
111
|
-
onCommit: (value)=>change('cuped', value)
|
|
112
|
-
}),
|
|
113
|
-
/*#__PURE__*/ _jsx("p", {
|
|
114
|
-
children: C.cuped.help
|
|
115
|
-
}),
|
|
116
|
-
/*#__PURE__*/ _jsx(FieldErrors, {
|
|
117
|
-
test: test,
|
|
118
|
-
path: "analysis.cuped"
|
|
119
|
-
})
|
|
120
|
-
]
|
|
121
|
-
}),
|
|
122
|
-
numbers.map(([field, fallback, min])=>/*#__PURE__*/ _jsxs("div", {
|
|
43
|
+
children: [
|
|
44
|
+
doc.kind === 'page' ? /*#__PURE__*/ _jsx(PageHoldout, {
|
|
45
|
+
test: test,
|
|
46
|
+
surface: surface
|
|
47
|
+
}) : null,
|
|
48
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
49
|
+
className: "xp-field-grid",
|
|
50
|
+
children: [
|
|
51
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
123
52
|
children: [
|
|
124
|
-
/*#__PURE__*/ _jsx(
|
|
125
|
-
label: C
|
|
126
|
-
value: doc.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
53
|
+
/*#__PURE__*/ _jsx(SelectEdit, {
|
|
54
|
+
label: C.exposurePolicy.label,
|
|
55
|
+
value: doc.exposurePolicy,
|
|
56
|
+
reason: reasonFor(test, 'exposurePolicy'),
|
|
57
|
+
options: exposureOptions(doc.kind).map((value)=>({
|
|
58
|
+
value,
|
|
59
|
+
label: C.policies[value]
|
|
60
|
+
})),
|
|
61
|
+
onCommit: (value)=>save(test, 'exposurePolicy', ()=>({
|
|
62
|
+
exposurePolicy: value
|
|
63
|
+
}))
|
|
64
|
+
}),
|
|
65
|
+
/*#__PURE__*/ _jsx("p", {
|
|
66
|
+
children: C.exposurePolicy.help
|
|
67
|
+
}),
|
|
68
|
+
/*#__PURE__*/ _jsx(FieldErrors, {
|
|
69
|
+
test: test,
|
|
70
|
+
path: "exposurePolicy"
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
}),
|
|
74
|
+
surface.isAdmin ? /*#__PURE__*/ _jsxs("div", {
|
|
75
|
+
children: [
|
|
76
|
+
/*#__PURE__*/ _jsx(SelectEdit, {
|
|
77
|
+
label: C.method.label,
|
|
78
|
+
value: doc.analysis?.method ?? 'sequential',
|
|
130
79
|
reason: reason,
|
|
131
|
-
|
|
132
|
-
|
|
80
|
+
options: [
|
|
81
|
+
{
|
|
82
|
+
value: 'sequential',
|
|
83
|
+
label: C.sequential
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
value: 'bayesian',
|
|
87
|
+
label: C.bayesian
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
onCommit: (value)=>change('method', value)
|
|
133
91
|
}),
|
|
134
92
|
/*#__PURE__*/ _jsx("p", {
|
|
135
|
-
children: C
|
|
93
|
+
children: C.method.help
|
|
136
94
|
}),
|
|
137
95
|
/*#__PURE__*/ _jsx(FieldErrors, {
|
|
138
96
|
test: test,
|
|
139
|
-
path:
|
|
97
|
+
path: "analysis.method"
|
|
140
98
|
})
|
|
141
99
|
]
|
|
142
|
-
}
|
|
143
|
-
|
|
100
|
+
}) : null,
|
|
101
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
144
102
|
children: [
|
|
145
|
-
/*#__PURE__*/ _jsx(
|
|
146
|
-
label: C
|
|
147
|
-
value:
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
103
|
+
/*#__PURE__*/ _jsx(SelectEdit, {
|
|
104
|
+
label: C.cuped.label,
|
|
105
|
+
value: doc.analysis?.cuped ?? 'auto',
|
|
106
|
+
reason: reason,
|
|
107
|
+
options: [
|
|
108
|
+
{
|
|
109
|
+
value: 'auto',
|
|
110
|
+
label: C.auto
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
value: 'off',
|
|
114
|
+
label: C.off
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
onCommit: (value)=>change('cuped', value)
|
|
151
118
|
}),
|
|
152
119
|
/*#__PURE__*/ _jsx("p", {
|
|
153
|
-
children: C
|
|
120
|
+
children: C.cuped.help
|
|
121
|
+
}),
|
|
122
|
+
/*#__PURE__*/ _jsx(FieldErrors, {
|
|
123
|
+
test: test,
|
|
124
|
+
path: "analysis.cuped"
|
|
154
125
|
})
|
|
155
126
|
]
|
|
156
|
-
},
|
|
157
|
-
|
|
158
|
-
|
|
127
|
+
}),
|
|
128
|
+
numbers.map(([field, fallback, min])=>/*#__PURE__*/ _jsxs("div", {
|
|
129
|
+
children: [
|
|
130
|
+
/*#__PURE__*/ _jsx(TextEdit, {
|
|
131
|
+
label: C[field].label,
|
|
132
|
+
value: doc.analysis?.[field] ?? fallback,
|
|
133
|
+
placeholder: field === 'attributionWindowHours' ? C.inheritedWindow : field === 'sequentialTuningParameter' ? C.automaticTuning : undefined,
|
|
134
|
+
type: "number",
|
|
135
|
+
min: min,
|
|
136
|
+
reason: reason,
|
|
137
|
+
isValid: field === 'minExposuresPerArm' ? positiveInteger : undefined,
|
|
138
|
+
onCommit: (raw)=>change(field, raw.trim() ? Number(raw) : null)
|
|
139
|
+
}),
|
|
140
|
+
/*#__PURE__*/ _jsx("p", {
|
|
141
|
+
children: C[field].help
|
|
142
|
+
}),
|
|
143
|
+
/*#__PURE__*/ _jsx(FieldErrors, {
|
|
144
|
+
test: test,
|
|
145
|
+
path: `analysis.${field}`
|
|
146
|
+
})
|
|
147
|
+
]
|
|
148
|
+
}, field)),
|
|
149
|
+
readOnlyFields.map((field)=>/*#__PURE__*/ _jsxs("div", {
|
|
150
|
+
children: [
|
|
151
|
+
/*#__PURE__*/ _jsx(ReadOnly, {
|
|
152
|
+
label: C[field].label,
|
|
153
|
+
value: field === 'slug' ? /*#__PURE__*/ _jsx("code", {
|
|
154
|
+
children: String(doc.slug)
|
|
155
|
+
}) : typeof doc[field] === 'string' || typeof doc[field] === 'number' ? String(doc[field]) : C.none,
|
|
156
|
+
reason: reasonFor(test, field)
|
|
157
|
+
}),
|
|
158
|
+
/*#__PURE__*/ _jsx("p", {
|
|
159
|
+
children: C[field].help
|
|
160
|
+
})
|
|
161
|
+
]
|
|
162
|
+
}, field))
|
|
163
|
+
]
|
|
164
|
+
})
|
|
165
|
+
]
|
|
159
166
|
});
|
|
160
167
|
}
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { fetchAllDocs } from '../../../lib/fetchAllDocs.js';
|
|
3
4
|
import { Button } from '../../../ui/Button.js';
|
|
4
|
-
import { useEffect, useState } from 'react';
|
|
5
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
5
6
|
import { formatAdminURL } from 'payload/shared';
|
|
6
7
|
import { TEST_PAGE as C } from '../../copy/testPage.js';
|
|
7
|
-
import {
|
|
8
|
+
import { METRIC_KIND_LABELS } from '../../copy/metrics.js';
|
|
9
|
+
import { isClickSource } from '../../../goals/key.js';
|
|
10
|
+
import { createApi } from '../../api.js';
|
|
11
|
+
import { sourceFor } from '../../metricSource.model.js';
|
|
8
12
|
import { reviewView } from '../../review/review.model.js';
|
|
9
13
|
import { CheckboxList, FieldErrors, reasonFor, save, SelectEdit } from './fields.js';
|
|
10
14
|
import { Section } from './Section.js';
|
|
11
15
|
export function GoalSection({ test, surface }) {
|
|
16
|
+
const api = useMemo(()=>createApi(surface.apiRoute), [
|
|
17
|
+
surface.apiRoute
|
|
18
|
+
]);
|
|
19
|
+
const [clickKeys, setClickKeys] = useState([]);
|
|
12
20
|
const [metrics, setMetrics] = useState([]);
|
|
13
21
|
const [failed, setFailed] = useState(false);
|
|
14
22
|
const [loaded, setLoaded] = useState(false);
|
|
@@ -19,22 +27,13 @@ export function GoalSection({ test, surface }) {
|
|
|
19
27
|
try {
|
|
20
28
|
await Promise.resolve();
|
|
21
29
|
if (controller.signal.aborted) return;
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
signal: controller.signal
|
|
28
|
-
});
|
|
29
|
-
if (!response.ok) throw new Error();
|
|
30
|
-
const body = await response.json();
|
|
31
|
-
if (!Array.isArray(body.docs)) throw new Error();
|
|
32
|
-
all.push(...body.docs);
|
|
33
|
-
if (!body.hasNextPage) break;
|
|
34
|
-
page++;
|
|
35
|
-
}
|
|
30
|
+
const response = await fetchAllDocs(`${surface.apiRoute.replace(/\/$/, '')}/xp-metrics?depth=0`, {
|
|
31
|
+
credentials: 'include',
|
|
32
|
+
signal: controller.signal
|
|
33
|
+
});
|
|
34
|
+
if (!response.ok) throw new Error();
|
|
36
35
|
if (!controller.signal.aborted) {
|
|
37
|
-
setMetrics(
|
|
36
|
+
setMetrics(response.docs);
|
|
38
37
|
setFailed(false);
|
|
39
38
|
setLoaded(true);
|
|
40
39
|
}
|
|
@@ -48,6 +47,40 @@ export function GoalSection({ test, surface }) {
|
|
|
48
47
|
attempt
|
|
49
48
|
]);
|
|
50
49
|
const doc = test.doc;
|
|
50
|
+
useEffect(()=>{
|
|
51
|
+
if (!surface.canManage) {
|
|
52
|
+
setClickKeys([]);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
let active = true;
|
|
56
|
+
let lastReturn = -Infinity;
|
|
57
|
+
let sequence = 0;
|
|
58
|
+
async function loadKeys() {
|
|
59
|
+
const request = ++sequence;
|
|
60
|
+
const result = await api.clickKeys(doc.id);
|
|
61
|
+
if (active && request === sequence) setClickKeys(result.ok && Array.isArray(result.data?.keys) ? result.data.keys : []);
|
|
62
|
+
}
|
|
63
|
+
const focus = ()=>{
|
|
64
|
+
if (document.visibilityState !== 'visible' || Date.now() - lastReturn < 100) return;
|
|
65
|
+
lastReturn = Date.now();
|
|
66
|
+
void loadKeys();
|
|
67
|
+
};
|
|
68
|
+
const visible = ()=>{
|
|
69
|
+
if (document.visibilityState === 'visible') focus();
|
|
70
|
+
};
|
|
71
|
+
void loadKeys();
|
|
72
|
+
window.addEventListener('focus', focus);
|
|
73
|
+
document.addEventListener('visibilitychange', visible);
|
|
74
|
+
return ()=>{
|
|
75
|
+
active = false;
|
|
76
|
+
window.removeEventListener('focus', focus);
|
|
77
|
+
document.removeEventListener('visibilitychange', visible);
|
|
78
|
+
};
|
|
79
|
+
}, [
|
|
80
|
+
api,
|
|
81
|
+
doc.id,
|
|
82
|
+
surface.canManage
|
|
83
|
+
]);
|
|
51
84
|
const reason = reasonFor(test, 'metrics');
|
|
52
85
|
useEffect(()=>{
|
|
53
86
|
if (!loaded) return;
|
|
@@ -74,12 +107,23 @@ export function GoalSection({ test, surface }) {
|
|
|
74
107
|
doc.metrics,
|
|
75
108
|
test
|
|
76
109
|
]);
|
|
77
|
-
const sources = metricSourceOptions(surface.metricSources);
|
|
78
110
|
const unknownGoal = loaded ? C.missingGoal : C.goalUnavailable;
|
|
79
|
-
const options = metrics.map((metric)=>
|
|
111
|
+
const options = metrics.map((metric)=>{
|
|
112
|
+
const kind = sourceFor(metric.source, surface.metricSources)?.kind;
|
|
113
|
+
return {
|
|
80
114
|
value: String(metric.id),
|
|
81
|
-
label: `${metric.name} · ${
|
|
82
|
-
}
|
|
115
|
+
label: `${metric.name} · ${kind ? METRIC_KIND_LABELS[kind] : metric.source}`
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
const onPage = new Map(metrics.flatMap((metric)=>{
|
|
119
|
+
const found = isClickSource(metric.source) ? clickKeys.find((row)=>row.key === metric.source.slice(6)) : undefined;
|
|
120
|
+
return found ? [
|
|
121
|
+
[
|
|
122
|
+
String(metric.id),
|
|
123
|
+
`${metric.name} · ${found.label}`
|
|
124
|
+
]
|
|
125
|
+
] : [];
|
|
126
|
+
}));
|
|
83
127
|
const chosen = [
|
|
84
128
|
doc.metrics?.primary,
|
|
85
129
|
...doc.metrics?.guardrails ?? [],
|
|
@@ -102,6 +146,18 @@ export function GoalSection({ test, surface }) {
|
|
|
102
146
|
].map(String));
|
|
103
147
|
return visible.filter((option)=>!blocked.has(option.value));
|
|
104
148
|
};
|
|
149
|
+
const roleGroups = (role)=>onPage.size ? [
|
|
150
|
+
{
|
|
151
|
+
label: C.clickPageGroup,
|
|
152
|
+
options: roleOptions(role).filter((option)=>onPage.has(option.value)).map((option)=>({
|
|
153
|
+
...option,
|
|
154
|
+
label: onPage.get(option.value)
|
|
155
|
+
}))
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
options: roleOptions(role).filter((option)=>!onPage.has(option.value))
|
|
159
|
+
}
|
|
160
|
+
] : undefined;
|
|
105
161
|
const originalId = (value)=>metrics.find((metric)=>String(metric.id) === value)?.id ?? [
|
|
106
162
|
test.doc.metrics?.primary,
|
|
107
163
|
...test.doc.metrics?.guardrails ?? [],
|
|
@@ -133,7 +189,7 @@ export function GoalSection({ test, surface }) {
|
|
|
133
189
|
});
|
|
134
190
|
const display = (ids)=>ids.length ? ids.map((id)=>options.find((option)=>option.value === String(id))?.label ?? unknownGoal).join(', ') : C.noGoal;
|
|
135
191
|
const primary = metrics.find((metric)=>String(metric.id) === String(doc.metrics?.primary));
|
|
136
|
-
const kind =
|
|
192
|
+
const kind = sourceFor(primary?.source, surface.metricSources)?.kind;
|
|
137
193
|
const baseline = test.preflight?.baseline && String(test.preflight.baseline.metricId) === String(doc.metrics?.primary) ? reviewView(test.preflight, {
|
|
138
194
|
primaryMetricKind: kind
|
|
139
195
|
}).baseline : null;
|
|
@@ -179,6 +235,17 @@ export function GoalSection({ test, surface }) {
|
|
|
179
235
|
},
|
|
180
236
|
...roleOptions('primary')
|
|
181
237
|
],
|
|
238
|
+
groups: onPage.size ? [
|
|
239
|
+
{
|
|
240
|
+
options: [
|
|
241
|
+
{
|
|
242
|
+
value: '',
|
|
243
|
+
label: C.chooseGoal
|
|
244
|
+
}
|
|
245
|
+
]
|
|
246
|
+
},
|
|
247
|
+
...roleGroups('primary')
|
|
248
|
+
] : undefined,
|
|
182
249
|
reason: reason,
|
|
183
250
|
readOnlyValue: display(doc.metrics?.primary == null ? [] : [
|
|
184
251
|
doc.metrics.primary
|
|
@@ -188,6 +255,9 @@ export function GoalSection({ test, surface }) {
|
|
|
188
255
|
/*#__PURE__*/ _jsx("p", {
|
|
189
256
|
children: C.goalHelp
|
|
190
257
|
}),
|
|
258
|
+
primary && isClickSource(primary.source) ? /*#__PURE__*/ _jsx("p", {
|
|
259
|
+
children: C.clickGoalHelp
|
|
260
|
+
}) : null,
|
|
191
261
|
baseline ? /*#__PURE__*/ _jsxs("p", {
|
|
192
262
|
children: [
|
|
193
263
|
primary?.name ? `${primary.name}: ` : '',
|
|
@@ -203,6 +273,7 @@ export function GoalSection({ test, surface }) {
|
|
|
203
273
|
label: C.guardrails,
|
|
204
274
|
value: (doc.metrics?.guardrails ?? []).map(String),
|
|
205
275
|
options: roleOptions('guardrails'),
|
|
276
|
+
groups: roleGroups('guardrails'),
|
|
206
277
|
reason: reason,
|
|
207
278
|
readOnlyValue: display(doc.metrics?.guardrails ?? []),
|
|
208
279
|
onToggle: (value, checked)=>toggle('guardrails', value, checked)
|
|
@@ -219,6 +290,7 @@ export function GoalSection({ test, surface }) {
|
|
|
219
290
|
label: C.secondary,
|
|
220
291
|
value: (doc.metrics?.secondary ?? []).map(String),
|
|
221
292
|
options: roleOptions('secondary'),
|
|
293
|
+
groups: roleGroups('secondary'),
|
|
222
294
|
reason: reason,
|
|
223
295
|
readOnlyValue: display(doc.metrics?.secondary ?? []),
|
|
224
296
|
onToggle: (value, checked)=>toggle('secondary', value, checked)
|
|
@@ -227,6 +299,9 @@ export function GoalSection({ test, surface }) {
|
|
|
227
299
|
test: test,
|
|
228
300
|
path: "metrics.secondary"
|
|
229
301
|
}),
|
|
302
|
+
metrics.some((metric)=>isClickSource(metric.source)) ? /*#__PURE__*/ _jsx("p", {
|
|
303
|
+
children: C.clickGoalsNote
|
|
304
|
+
}) : null,
|
|
230
305
|
test.errors.metrics ? /*#__PURE__*/ _jsx("p", {
|
|
231
306
|
role: "alert",
|
|
232
307
|
children: test.errors.metrics
|
|
@@ -55,7 +55,7 @@ export function LengthSection({ test }) {
|
|
|
55
55
|
type: "number",
|
|
56
56
|
min: 1,
|
|
57
57
|
reason: reason,
|
|
58
|
-
|
|
58
|
+
isValid: positiveInteger,
|
|
59
59
|
onCommit: (value)=>change('plannedDurationDays', value),
|
|
60
60
|
help: weeksHint(doc.analysis?.plannedDurationDays ?? 28)
|
|
61
61
|
}),
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { TEST_PAGE as C } from '../../copy/testPage.js';
|
|
4
|
+
import { ARMS_COPY } from '../../copy/arms.js';
|
|
5
|
+
import { addHoldoutArm, removeArm, splitEvenly } from '../../arms/arms.model.js';
|
|
6
|
+
import { balanceWeight } from './testPage.model.js';
|
|
7
|
+
import { FieldErrors, reasonFor, save, TextEdit } from './fields.js';
|
|
8
|
+
import { Button } from '../../../ui/Button.js';
|
|
9
|
+
/** Whole-page holdouts have no page of their own; their controls live under Advanced. */ export function PageHoldout({ test }) {
|
|
10
|
+
const doc = test.doc;
|
|
11
|
+
const arm = doc.arms.find((item)=>item.kind === 'holdout');
|
|
12
|
+
const index = doc.arms.findIndex((item)=>item.kind === 'holdout');
|
|
13
|
+
const reason = reasonFor(test, 'arms');
|
|
14
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
15
|
+
children: [
|
|
16
|
+
arm ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
17
|
+
children: [
|
|
18
|
+
/*#__PURE__*/ _jsx(TextEdit, {
|
|
19
|
+
label: `${C.holdoutPrefix}${C.label}`,
|
|
20
|
+
value: arm.label,
|
|
21
|
+
reason: reason,
|
|
22
|
+
onCommit: (label)=>save(test, 'arms', ()=>({
|
|
23
|
+
arms: doc.arms.map((item)=>item.key === arm.key ? {
|
|
24
|
+
...item,
|
|
25
|
+
label
|
|
26
|
+
} : item)
|
|
27
|
+
}))
|
|
28
|
+
}),
|
|
29
|
+
/*#__PURE__*/ _jsx(TextEdit, {
|
|
30
|
+
label: `${C.holdoutPrefix}${C.weight}`,
|
|
31
|
+
type: "number",
|
|
32
|
+
min: 0,
|
|
33
|
+
max: 100,
|
|
34
|
+
value: arm.weight,
|
|
35
|
+
reason: reason,
|
|
36
|
+
isValid: (value)=>value.trim() !== '' && Number.isInteger(Number(value)) && Number(value) >= 0 && Number(value) <= 100,
|
|
37
|
+
invalidMessage: C.invalidShare,
|
|
38
|
+
onCommit: (value)=>save(test, 'arms', ()=>({
|
|
39
|
+
arms: balanceWeight(doc.arms, arm.key, Number(value))
|
|
40
|
+
}))
|
|
41
|
+
}),
|
|
42
|
+
/*#__PURE__*/ _jsx(FieldErrors, {
|
|
43
|
+
test: test,
|
|
44
|
+
path: `arms.${index}`
|
|
45
|
+
}),
|
|
46
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
47
|
+
disabled: !!reason,
|
|
48
|
+
onClick: ()=>save(test, 'arms', ()=>({
|
|
49
|
+
arms: splitEvenly(removeArm(doc.arms, arm.key))
|
|
50
|
+
})),
|
|
51
|
+
children: C.remove
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
}) : /*#__PURE__*/ _jsx(Button, {
|
|
55
|
+
disabled: !!reason,
|
|
56
|
+
onClick: ()=>save(test, 'arms', ()=>({
|
|
57
|
+
arms: addHoldoutArm(doc.arms)
|
|
58
|
+
})),
|
|
59
|
+
children: C.addHoldout
|
|
60
|
+
}),
|
|
61
|
+
/*#__PURE__*/ _jsx("p", {
|
|
62
|
+
className: "xp-ui-help",
|
|
63
|
+
children: ARMS_COPY.holdout
|
|
64
|
+
})
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
@@ -23,7 +23,8 @@ import './testPage.css';
|
|
|
23
23
|
export function TestPage({ id, surface, onTitleChange }) {
|
|
24
24
|
const [barHeight, setBarHeight] = useState();
|
|
25
25
|
const test = useTestDocument(id, {
|
|
26
|
-
apiRoute: surface.apiRoute
|
|
26
|
+
apiRoute: surface.apiRoute,
|
|
27
|
+
refetchPreflightOnFocus: true
|
|
27
28
|
});
|
|
28
29
|
useEffect(()=>{
|
|
29
30
|
if (test.doc?.name) onTitleChange?.(test.doc.name);
|