@delmaredigital/payload-experiments 0.4.0-rc.1 → 0.4.0-rc.10
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 +284 -772
- package/dist/admin/LayerUsage.js +1 -1
- package/dist/admin/MetricSourceSelect.js +2 -2
- package/dist/admin/PlacementStatus.js +1 -1
- package/dist/admin/TestsDashboardCards.d.ts +1 -0
- package/dist/admin/TestsDashboardCards.js +5 -9
- package/dist/admin/TestsNavLink.d.ts +1 -0
- package/dist/admin/TestsNavLink.js +5 -11
- package/dist/admin/blocks/BlockPanel.d.ts +1 -0
- package/dist/admin/blocks/BlockPanel.js +129 -37
- package/dist/admin/blocks/TestBlockField.js +3 -3
- package/dist/admin/blocks/formApi.d.ts +3 -0
- package/dist/admin/blocks/formApi.js +10 -4
- package/dist/admin/blocks/inject.js +1 -0
- package/dist/admin/blocks/model.d.ts +3 -2
- package/dist/admin/blocks/model.js +10 -6
- package/dist/admin/blocks/statusCache.d.ts +2 -0
- package/dist/admin/blocks/statusCache.js +12 -3
- package/dist/admin/components/RootViewMessage.js +1 -1
- package/dist/admin/copy/blocks.d.ts +21 -1
- package/dist/admin/copy/blocks.js +40 -6
- package/dist/admin/copy/goals.d.ts +6 -1
- package/dist/admin/copy/goals.js +10 -3
- package/dist/admin/copy/newTest.d.ts +6 -7
- package/dist/admin/copy/newTest.js +9 -7
- package/dist/admin/goals/XpGoalField.d.ts +2 -0
- package/dist/admin/goals/XpGoalField.js +156 -114
- package/dist/admin/goals/xpGoalField.css +47 -0
- package/dist/admin/pageCollections.d.ts +1 -0
- package/dist/admin/pageCollections.js +3 -0
- package/dist/admin/paths.d.ts +3 -0
- package/dist/admin/paths.js +3 -0
- package/dist/admin/placementStatus.model.js +1 -1
- package/dist/admin/status.model.js +1 -1
- package/dist/admin/surface/ResultsRoute.d.ts +2 -1
- package/dist/admin/surface/ResultsRoute.js +20 -24
- package/dist/admin/surface/SurfaceShell.js +5 -2
- package/dist/admin/surface/TestRowMenu.d.ts +6 -0
- package/dist/admin/surface/TestRowMenu.js +156 -0
- package/dist/admin/surface/TestsHome.d.ts +5 -3
- package/dist/admin/surface/TestsHome.js +266 -58
- package/dist/admin/surface/TestsSurface.js +8 -7
- package/dist/admin/surface/goals/GoalForm.d.ts +1 -1
- package/dist/admin/surface/goals/GoalForm.js +95 -54
- package/dist/admin/surface/goals/GoalsList.d.ts +1 -1
- package/dist/admin/surface/goals/GoalsList.js +5 -4
- package/dist/admin/surface/goals/data.js +2 -2
- package/dist/admin/surface/goals/goals.css +7 -0
- package/dist/admin/surface/goals/goals.model.d.ts +11 -1
- package/dist/admin/surface/goals/goals.model.js +43 -0
- package/dist/admin/surface/home.model.d.ts +9 -8
- package/dist/admin/surface/home.model.js +22 -21
- package/dist/admin/surface/newTest/NewTest.d.ts +4 -4
- package/dist/admin/surface/newTest/NewTest.js +98 -94
- package/dist/admin/surface/newTest/PageWizard.d.ts +2 -1
- package/dist/admin/surface/newTest/PageWizard.js +111 -76
- package/dist/admin/surface/newTest/newTest.css +28 -9
- package/dist/admin/surface/results/ResultsHeader.d.ts +2 -2
- package/dist/admin/surface/results/ResultsHeader.js +58 -54
- package/dist/admin/surface/surface.css +10 -0
- package/dist/admin/surface/test/TestPage.d.ts +1 -2
- package/dist/admin/surface/test/TestPage.js +42 -162
- package/dist/admin/theme.css +2 -0
- package/dist/admin/views/CollectionListRedirect.d.ts +1 -0
- package/dist/admin/views/CollectionListRedirect.js +1 -1
- package/dist/admin/views/ExperimentsRootView.js +18 -165
- package/dist/admin/views/GoalEditRedirect.d.ts +4 -0
- package/dist/admin/views/GoalEditRedirect.js +14 -0
- package/dist/admin/views/GoalsCollectionListView.d.ts +2 -0
- package/dist/admin/views/GoalsCollectionListView.js +4 -0
- package/dist/admin/views/TestsCollectionListView.d.ts +2 -0
- package/dist/admin/views/TestsCollectionListView.js +4 -0
- package/dist/admin/views/TestsNavLinkServer.d.ts +1 -0
- package/dist/admin/views/TestsNavLinkServer.js +2 -2
- package/dist/admin/views/TestsSurfaceClient.d.ts +3 -0
- package/dist/admin/views/TestsSurfaceClient.js +11 -0
- package/dist/admin/views/buildSurfaceProps.d.ts +8 -0
- package/dist/admin/views/buildSurfaceProps.js +102 -0
- package/dist/admin/views/renderCollectionList.d.ts +2 -0
- package/dist/admin/views/renderCollectionList.js +34 -0
- package/dist/admin/views/renderTestsSurface.d.ts +3 -0
- package/dist/admin/views/renderTestsSurface.js +34 -0
- package/dist/blocks/bindings.js +8 -14
- package/dist/blocks/formState.js +1 -1
- package/dist/blocks/placementLanguages.d.ts +7 -0
- package/dist/blocks/placementLanguages.js +27 -0
- package/dist/blocks/placementLocale.d.ts +37 -0
- package/dist/blocks/placementLocale.js +270 -0
- package/dist/collections/experiments/config.js +17 -8
- package/dist/collections/experiments/deleteGuard.js +2 -2
- package/dist/collections/experiments/lockHook.js +21 -2
- package/dist/collections/experiments/pickSlug.js +2 -0
- package/dist/collections/metrics.js +16 -4
- package/dist/collections/metricsGuards.js +2 -0
- package/dist/collections/serialize.js +5 -4
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/db/adapter.d.ts +9 -1
- package/dist/db/adapter.js +77 -1
- package/dist/db/appends.d.ts +13 -0
- package/dist/db/appends.js +49 -0
- package/dist/db/bulkPlacementRemoval.d.ts +30 -0
- package/dist/db/bulkPlacementRemoval.js +111 -0
- package/dist/db/delete.d.ts +1 -1
- package/dist/db/delete.js +2 -4
- package/dist/db/events.d.ts +9 -0
- package/dist/db/events.js +42 -8
- package/dist/db/executor.d.ts +7 -1
- package/dist/db/executor.js +7 -3
- package/dist/db/pageCopies.d.ts +5 -0
- package/dist/db/pageCopies.js +31 -0
- package/dist/db/placements.d.ts +2 -0
- package/dist/db/placements.js +8 -0
- package/dist/db/results.d.ts +5 -1
- package/dist/db/results.js +21 -5
- package/dist/db/snapshots.d.ts +1 -0
- package/dist/endpoints/contentLocale.d.ts +6 -0
- package/dist/endpoints/contentLocale.js +15 -0
- package/dist/endpoints/deleteImpact.d.ts +6 -0
- package/dist/endpoints/deleteImpact.js +207 -0
- package/dist/endpoints/duplicateOriginal.d.ts +38 -0
- package/dist/endpoints/duplicateOriginal.js +407 -0
- package/dist/endpoints/editorSurface.d.ts +3 -0
- package/dist/endpoints/editorSurface.js +31 -0
- package/dist/endpoints/events.js +103 -39
- package/dist/endpoints/index.js +57 -9
- package/dist/endpoints/pages.js +247 -64
- package/dist/endpoints/placementStatus.js +13 -5
- package/dist/endpoints/preflight.d.ts +1 -1
- package/dist/endpoints/preflight.js +17 -2
- package/dist/endpoints/results.d.ts +1 -1
- package/dist/endpoints/results.js +6 -2
- package/dist/endpoints/routeId.d.ts +2 -2
- package/dist/endpoints/routeId.js +11 -5
- package/dist/endpoints/summary.js +46 -12
- package/dist/endpoints/testVersion.d.ts +2 -0
- package/dist/endpoints/testVersion.js +38 -0
- package/dist/endpoints/transitions.js +41 -29
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +8 -0
- package/dist/events/request.d.ts +6 -2
- package/dist/events/request.js +35 -8
- package/dist/events/rows.d.ts +1 -1
- package/dist/events/rows.js +24 -8
- package/dist/events/writable.d.ts +9 -0
- package/dist/events/writable.js +13 -0
- package/dist/exports/adminClient.d.ts +1 -1
- package/dist/exports/adminClient.js +1 -1
- package/dist/exports/adminRsc.d.ts +3 -0
- package/dist/exports/adminRsc.js +3 -0
- package/dist/exports/index.d.ts +1 -1
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.js +1 -0
- package/dist/fields/xpGoal.js +3 -15
- package/dist/goals/fairness.d.ts +1 -1
- package/dist/goals/fairness.js +44 -35
- package/dist/goals/picker/clickGoalPicker.model.d.ts +8 -1
- package/dist/goals/picker/clickGoalPicker.model.js +20 -2
- package/dist/goals/picker/copy.d.ts +6 -2
- package/dist/goals/picker/copy.js +11 -2
- package/dist/goals/picker/useClickGoalPicker.d.ts +1 -1
- package/dist/goals/picker/useClickGoalPicker.js +4 -2
- package/dist/goals/validate.d.ts +3 -0
- package/dist/goals/validate.js +15 -0
- package/dist/hooks/blockRemovalRule.d.ts +30 -0
- package/dist/hooks/blockRemovalRule.js +165 -0
- package/dist/hooks/hostHook.js +6 -2
- package/dist/hooks/pageGuard.d.ts +27 -2
- package/dist/hooks/pageGuard.js +213 -45
- package/dist/hooks/puckGoals.d.ts +5 -0
- package/dist/hooks/puckGoals.js +62 -0
- package/dist/hooks/puckNestedTests.d.ts +8 -0
- package/dist/hooks/puckNestedTests.js +36 -0
- package/dist/hooks/trackPageCopies.d.ts +11 -0
- package/dist/hooks/trackPageCopies.js +7 -0
- package/dist/lib/fetchAllDocs.d.ts +1 -1
- package/dist/lib/placementPages.d.ts +10 -0
- package/dist/{admin/previewLinks.model.js → lib/placementPages.js} +10 -5
- package/dist/manifest/compile.d.ts +2 -1
- package/dist/manifest/compile.js +13 -6
- package/dist/onInit.js +36 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +23 -2
- package/dist/plugin.js +19 -20
- package/dist/proxy/pageNavigation.d.ts +4 -0
- package/dist/proxy/pageNavigation.js +28 -0
- package/dist/proxy/resolve.js +52 -25
- package/dist/puck/ExperimentPicker.d.ts +2 -1
- package/dist/puck/ExperimentPicker.js +62 -40
- package/dist/puck/ExperimentSlot.js +3 -1
- package/dist/puck/copy.d.ts +5 -1
- package/dist/puck/copy.js +5 -1
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +25 -0
- package/dist/puck/editor/ConfigureTestDrawer.js +150 -0
- package/dist/puck/editor/CreateExperimentDrawer.d.ts +12 -2
- package/dist/puck/editor/CreateExperimentDrawer.js +89 -21
- package/dist/puck/editor/EditorControls.d.ts +14 -0
- package/dist/puck/editor/EditorControls.js +99 -0
- package/dist/puck/editor/ExperimentSlotEditor.js +951 -179
- package/dist/puck/editor/LeftoverVersions.d.ts +15 -0
- package/dist/puck/editor/LeftoverVersions.js +79 -0
- package/dist/puck/editor/PlacementNotice.d.ts +8 -0
- package/dist/puck/editor/PlacementNotice.js +22 -0
- package/dist/puck/editor/QuickTestActions.d.ts +6 -0
- package/dist/puck/editor/QuickTestActions.js +57 -0
- package/dist/puck/editor/ResultsReadout.d.ts +2 -1
- package/dist/puck/editor/ResultsReadout.js +10 -6
- package/dist/puck/editor/VersionBuilder.d.ts +66 -12
- package/dist/puck/editor/VersionBuilder.js +554 -231
- package/dist/puck/editor/armWrites.d.ts +11 -2
- package/dist/puck/editor/armWrites.js +43 -4
- package/dist/puck/editor/armsCache.d.ts +3 -1
- package/dist/puck/editor/armsCache.js +20 -4
- package/dist/puck/editor/blockClipboard.d.ts +16 -0
- package/dist/puck/editor/blockClipboard.js +20 -0
- package/dist/puck/editor/cloneSlot.d.ts +2 -0
- package/dist/puck/editor/cloneSlot.js +7 -0
- package/dist/puck/editor/copy.d.ts +64 -19
- package/dist/puck/editor/copy.js +72 -20
- package/dist/puck/editor/createTest.d.ts +3 -0
- package/dist/puck/editor/createTest.js +33 -0
- package/dist/puck/editor/editor.chrome.css +191 -19
- package/dist/puck/editor/editor.css +328 -24
- package/dist/puck/editor/editor.model.d.ts +17 -1
- package/dist/puck/editor/editor.model.js +61 -4
- package/dist/puck/editor/editorSurface.d.ts +10 -0
- package/dist/puck/editor/editorSurface.js +65 -0
- package/dist/puck/editor/experimentOutlinePlugin.js +96 -28
- package/dist/puck/editor/localPlacements.d.ts +5 -0
- package/dist/puck/editor/localPlacements.js +43 -0
- package/dist/puck/editor/outlineVersion.d.ts +5 -0
- package/dist/puck/editor/outlineVersion.js +36 -0
- package/dist/puck/editor/placementsCache.d.ts +60 -0
- package/dist/puck/editor/placementsCache.js +263 -0
- package/dist/puck/editor/sidebar.d.ts +8 -0
- package/dist/puck/editor/sidebar.js +74 -0
- package/dist/puck/editor/usePageSaveReadiness.d.ts +6 -0
- package/dist/puck/editor/usePageSaveReadiness.js +31 -0
- package/dist/puck/editor/usePlacementNotice.d.ts +3 -0
- package/dist/puck/editor/usePlacementNotice.js +15 -0
- package/dist/puck/editor/xpGoalPuckEditorField.js +105 -86
- package/dist/puck/experimentSlotField.d.ts +3 -0
- package/dist/puck/experimentSlotField.js +15 -4
- package/dist/puck/experimentSlug.d.ts +2 -0
- package/dist/puck/experimentSlug.js +3 -0
- package/dist/puck/nestedTestCopy.d.ts +8 -0
- package/dist/puck/nestedTestCopy.js +22 -0
- package/dist/puck/nestedTests.d.ts +17 -0
- package/dist/puck/nestedTests.js +30 -0
- package/dist/puck/slotConfig.d.ts +1 -1
- package/dist/puck/slotConfig.js +17 -4
- package/dist/puck/visibility.d.ts +20 -0
- package/dist/puck/visibility.js +81 -0
- package/dist/results/aggregate.d.ts +6 -3
- package/dist/results/aggregate.js +9 -9
- package/dist/results/health.d.ts +8 -0
- package/dist/results/health.js +28 -0
- package/dist/results/identityCredit.d.ts +1 -0
- package/dist/results/identityCredit.js +4 -1
- package/dist/results/verdict.js +2 -1
- package/dist/runtime/cookie.d.ts +10 -2
- package/dist/runtime/cookie.js +38 -6
- package/dist/runtime/cookieOptions.d.ts +6 -0
- package/dist/runtime/cookieOptions.js +14 -0
- package/dist/runtime/proxyRuntime.d.ts +1 -0
- package/dist/runtime/proxyRuntime.js +18 -8
- package/dist/runtime/signing.d.ts +1 -0
- package/dist/runtime/signing.js +5 -0
- package/dist/sanitizeReadinessDetail.d.ts +2 -2
- package/dist/sanitizeReadinessDetail.js +22 -2
- package/dist/server/getAssignments.js +11 -10
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +48 -22
- package/dist/server/resolveExperimentBlocks.js +2 -4
- package/dist/server/resolveExperimentData.js +8 -8
- package/dist/server/runResults.js +52 -14
- package/dist/server/startExperiment.d.ts +20 -0
- package/dist/server/startExperiment.js +70 -0
- package/dist/server/trackConversion.js +10 -13
- package/dist/{admin → testSurface}/PreviewLinks.js +6 -2
- package/dist/testSurface/actions/DecideDialog.d.ts +16 -0
- package/dist/{admin → testSurface}/actions/DecideDialog.js +78 -55
- package/dist/testSurface/actions/LifecycleAction.d.ts +16 -0
- package/dist/testSurface/actions/LifecycleAction.js +105 -0
- package/dist/{admin → testSurface}/actions/MakeContentResult.d.ts +4 -3
- package/dist/{admin → testSurface}/actions/MakeContentResult.js +10 -2
- package/dist/{admin → testSurface}/actions/actions.model.d.ts +13 -5
- package/dist/testSurface/actions/actions.model.js +122 -0
- package/dist/{admin → testSurface}/api.d.ts +20 -7
- package/dist/{admin → testSurface}/api.js +72 -22
- package/dist/testSurface/contentLocaleURL.d.ts +2 -0
- package/dist/testSurface/contentLocaleURL.js +3 -0
- package/dist/{admin → testSurface}/copy/actions.d.ts +28 -8
- package/dist/{admin → testSurface}/copy/actions.js +31 -11
- package/dist/{admin → testSurface}/copy/common.d.ts +13 -4
- package/dist/{admin → testSurface}/copy/common.js +18 -8
- package/dist/testSurface/copy/languages.d.ts +12 -0
- package/dist/testSurface/copy/languages.js +8 -0
- package/dist/{admin → testSurface}/copy/metrics.d.ts +1 -0
- package/dist/{admin → testSurface}/copy/metrics.js +1 -0
- package/dist/testSurface/copy/pages.d.ts +84 -0
- package/dist/testSurface/copy/pages.js +90 -0
- package/dist/{admin → testSurface}/copy/readiness.d.ts +38 -4
- package/dist/{admin → testSurface}/copy/readiness.js +52 -7
- package/dist/{admin → testSurface}/copy/results.d.ts +6 -3
- package/dist/{admin → testSurface}/copy/results.js +6 -3
- package/dist/{admin → testSurface}/copy/review.d.ts +1 -1
- package/dist/{admin → testSurface}/copy/review.js +1 -1
- package/dist/{admin → testSurface}/copy/surface.d.ts +11 -2
- package/dist/{admin → testSurface}/copy/surface.js +13 -10
- package/dist/{admin → testSurface}/copy/testPage.d.ts +53 -8
- package/dist/testSurface/copy/testPage.js +165 -0
- package/dist/testSurface/format/adminURL.d.ts +7 -0
- package/dist/testSurface/format/adminURL.js +9 -0
- package/dist/testSurface/placementLabel.d.ts +8 -0
- package/dist/testSurface/placementLabel.js +24 -0
- package/dist/{admin → testSurface}/placements/placementLabels.d.ts +2 -0
- package/dist/{admin → testSurface}/placements/placementLabels.js +3 -2
- package/dist/{admin → testSurface}/previewLinks.model.d.ts +1 -6
- package/dist/testSurface/previewLinks.model.js +4 -0
- package/dist/testSurface/readPreflight.d.ts +13 -0
- package/dist/testSurface/readPreflight.js +44 -0
- package/dist/testSurface/readinessRead.d.ts +53 -0
- package/dist/testSurface/readinessRead.js +50 -0
- package/dist/{admin → testSurface}/results/VerdictHero.d.ts +2 -1
- package/dist/{admin → testSurface}/results/VerdictHero.js +5 -1
- package/dist/testSurface/results/results.css +64 -0
- package/dist/{admin → testSurface}/results/results.model.js +6 -2
- package/dist/{admin → testSurface}/surface/contracts.d.ts +17 -3
- package/dist/testSurface/surface/editorPlacement.d.ts +26 -0
- package/dist/testSurface/surface/editorPlacement.js +78 -0
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +9 -0
- package/dist/{admin → testSurface}/surface/pageBlock/parts.js +39 -11
- package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +13 -0
- package/dist/testSurface/surface/pagePicker/CopyRoute.js +273 -0
- package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +21 -0
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +503 -0
- package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -0
- package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.d.ts +7 -3
- package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.js +17 -2
- package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.d.ts +8 -4
- package/dist/testSurface/surface/readiness/ActionDialogs.js +351 -0
- package/dist/{admin → testSurface}/surface/readiness/Banner.d.ts +2 -3
- package/dist/testSurface/surface/readiness/Banner.js +187 -0
- package/dist/testSurface/surface/readiness/BlockerList.d.ts +11 -0
- package/dist/testSurface/surface/readiness/BlockerList.js +31 -0
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +10 -0
- package/dist/testSurface/surface/readiness/SaveStatus.js +66 -0
- package/dist/{admin → testSurface}/surface/readiness/parts.js +0 -2
- package/dist/{admin → testSurface}/surface/readiness/readiness.model.d.ts +28 -2
- package/dist/testSurface/surface/readiness/readiness.model.js +377 -0
- package/dist/testSurface/surface/readiness/useTransition.d.ts +16 -0
- package/dist/testSurface/surface/readiness/useTransition.js +141 -0
- package/dist/{admin → testSurface}/surface/results/ReleasePages.d.ts +6 -3
- package/dist/{admin → testSurface}/surface/results/ReleasePages.js +40 -40
- package/dist/{admin → testSurface}/surface/results/ResultsBody.d.ts +7 -3
- package/dist/{admin → testSurface}/surface/results/ResultsBody.js +108 -44
- package/dist/{admin → testSurface}/surface/results/useResults.d.ts +26 -8
- package/dist/{admin → testSurface}/surface/results/useResults.js +3 -2
- package/dist/{admin → testSurface}/surface/setting/parts.js +58 -18
- package/dist/testSurface/surface/setting/setting.css +17 -0
- package/dist/{admin → testSurface}/surface/test/AdvancedSection.js +2 -0
- package/dist/testSurface/surface/test/DeleteTest.d.ts +23 -0
- package/dist/testSurface/surface/test/DeleteTest.js +270 -0
- package/dist/testSurface/surface/test/GoalSection.d.ts +4 -0
- package/dist/{admin → testSurface}/surface/test/GoalSection.js +116 -86
- package/dist/testSurface/surface/test/LengthSection.d.ts +2 -0
- package/dist/{admin → testSurface}/surface/test/LengthSection.js +5 -1
- package/dist/{admin → testSurface}/surface/test/PageHoldout.js +4 -1
- package/dist/{admin → testSurface}/surface/test/Rail.js +7 -4
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.d.ts +1 -0
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.js +2 -3
- package/dist/{admin → testSurface}/surface/test/Section.d.ts +3 -1
- package/dist/testSurface/surface/test/Section.js +80 -0
- package/dist/{admin → testSurface}/surface/test/TargetingSection.js +82 -12
- package/dist/testSurface/surface/test/TestSurface.d.ts +19 -0
- package/dist/testSurface/surface/test/TestSurface.js +265 -0
- package/dist/testSurface/surface/test/VersionsSection.d.ts +5 -0
- package/dist/{admin → testSurface}/surface/test/VersionsSection.js +69 -35
- package/dist/{admin → testSurface}/surface/test/fields.d.ts +30 -7
- package/dist/testSurface/surface/test/fields.js +306 -0
- package/dist/{admin → testSurface}/surface/test/pageParts.js +27 -43
- package/dist/testSurface/surface/test/testPage.css +103 -0
- package/dist/{admin → testSurface}/surface/test/testPage.model.d.ts +1 -0
- package/dist/{admin → testSurface}/surface/test/testPage.model.js +6 -0
- package/dist/{admin → testSurface}/surface/testDocument.model.d.ts +3 -0
- package/dist/{admin → testSurface}/surface/testDocument.model.js +4 -1
- package/dist/testSurface/surface/useTestDocument.d.ts +60 -0
- package/dist/testSurface/surface/useTestDocument.js +782 -0
- package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
- package/dist/testSurface/surface/watchTestDocument.js +181 -0
- package/dist/testSurface/surfaceUrls.d.ts +7 -0
- package/dist/testSurface/surfaceUrls.js +19 -0
- package/dist/{admin → testSurface}/useApi.d.ts +21 -5
- package/dist/testSurface/useOnTestReturn.d.ts +2 -0
- package/dist/testSurface/useOnTestReturn.js +27 -0
- package/dist/testSurface/useReadinessPolling.d.ts +3 -0
- package/dist/testSurface/useReadinessPolling.js +26 -0
- package/dist/transitions/addMetric.d.ts +2 -5
- package/dist/transitions/addMetric.js +5 -1
- package/dist/transitions/allocate.d.ts +2 -2
- package/dist/transitions/allocate.js +3 -1
- package/dist/transitions/archive.d.ts +1 -1
- package/dist/transitions/archive.js +3 -2
- package/dist/transitions/checkStart.d.ts +6 -1
- package/dist/transitions/checkStart.js +133 -17
- package/dist/transitions/contentFields.js +9 -5
- package/dist/transitions/decide.d.ts +1 -1
- package/dist/transitions/decide.js +6 -3
- package/dist/transitions/deleteExperiment.d.ts +2 -2
- package/dist/transitions/deleteExperiment.js +17 -7
- package/dist/transitions/kernel.d.ts +4 -0
- package/dist/transitions/kernel.js +9 -4
- package/dist/transitions/makeContent.d.ts +2 -1
- package/dist/transitions/makeContent.js +41 -17
- package/dist/transitions/nestedPlacementNames.d.ts +5 -0
- package/dist/transitions/nestedPlacementNames.js +32 -0
- package/dist/transitions/pageAddress.d.ts +6 -0
- package/dist/transitions/pageAddress.js +71 -0
- package/dist/transitions/pageVersions.js +3 -1
- package/dist/transitions/phaseRecord.d.ts +2 -0
- package/dist/transitions/phaseRecord.js +5 -0
- package/dist/transitions/placementInteractions.d.ts +3 -3
- package/dist/transitions/placementInteractions.js +16 -12
- package/dist/transitions/placements.d.ts +54 -8
- package/dist/transitions/placements.js +304 -81
- package/dist/transitions/preflightData.d.ts +5 -3
- package/dist/transitions/preflightData.js +137 -40
- package/dist/transitions/releaseHoldout.d.ts +2 -1
- package/dist/transitions/releaseHoldout.js +3 -1
- package/dist/transitions/releasePages.d.ts +2 -1
- package/dist/transitions/releasePages.js +3 -1
- package/dist/transitions/resolveCaps.d.ts +2 -4
- package/dist/transitions/start.d.ts +6 -8
- package/dist/transitions/start.js +72 -35
- package/dist/transitions/startReads.d.ts +7 -0
- package/dist/transitions/startReads.js +28 -0
- package/dist/transitions/stop.d.ts +2 -1
- package/dist/transitions/stop.js +3 -2
- package/dist/types/contracts.d.ts +15 -3
- package/dist/types/endpoints.d.ts +121 -17
- package/dist/types/puck.d.ts +1 -0
- package/dist/types/runtime.d.ts +15 -9
- package/dist/types/snapshot.d.ts +2 -0
- package/dist/types/surface.d.ts +9 -9
- package/dist/ui/Button.js +2 -2
- package/dist/ui/Card.d.ts +2 -1
- package/dist/ui/Card.js +4 -4
- package/dist/ui/ChipsInput.d.ts +8 -1
- package/dist/ui/ChipsInput.js +17 -4
- package/dist/ui/Dialog.d.ts +24 -2
- package/dist/ui/Dialog.js +116 -6
- package/dist/ui/Drawer.d.ts +10 -0
- package/dist/ui/Drawer.js +29 -0
- package/dist/ui/Inputs.d.ts +4 -3
- package/dist/ui/Inputs.js +7 -4
- package/dist/ui/SelectControl.d.ts +33 -0
- package/dist/ui/SelectControl.js +504 -0
- package/dist/ui/Tabs.d.ts +4 -4
- package/dist/ui/Tabs.js +35 -32
- package/dist/ui/ui.css +49 -5
- package/package.json +3 -2
- package/dist/admin/actions/ConfirmDialog.d.ts +0 -19
- package/dist/admin/actions/ConfirmDialog.js +0 -149
- package/dist/admin/actions/DecideDialog.d.ts +0 -10
- package/dist/admin/actions/actions.model.js +0 -70
- package/dist/admin/copy/pages.d.ts +0 -26
- package/dist/admin/copy/pages.js +0 -26
- package/dist/admin/copy/testPage.js +0 -104
- package/dist/admin/results/results.css +0 -64
- package/dist/admin/styles.css +0 -10
- package/dist/admin/styles.d.ts +0 -2
- package/dist/admin/styles.js +0 -3
- package/dist/admin/surface/pageBlock/pageBlock.model.js +0 -8
- package/dist/admin/surface/pagePicker/CopyRoute.d.ts +0 -6
- package/dist/admin/surface/pagePicker/CopyRoute.js +0 -53
- package/dist/admin/surface/pagePicker/PagePicker.d.ts +0 -10
- package/dist/admin/surface/pagePicker/PagePicker.js +0 -172
- package/dist/admin/surface/readiness/ActionDialogs.js +0 -337
- package/dist/admin/surface/readiness/Banner.js +0 -190
- package/dist/admin/surface/readiness/SaveStatus.d.ts +0 -5
- package/dist/admin/surface/readiness/SaveStatus.js +0 -53
- package/dist/admin/surface/readiness/readiness.model.js +0 -205
- package/dist/admin/surface/readiness/useTransition.d.ts +0 -11
- package/dist/admin/surface/readiness/useTransition.js +0 -35
- package/dist/admin/surface/setting/setting.css +0 -17
- package/dist/admin/surface/test/GoalSection.d.ts +0 -2
- package/dist/admin/surface/test/LengthSection.d.ts +0 -2
- package/dist/admin/surface/test/Section.js +0 -47
- package/dist/admin/surface/test/VersionsSection.d.ts +0 -4
- package/dist/admin/surface/test/fields.js +0 -216
- package/dist/admin/surface/test/testPage.css +0 -97
- package/dist/admin/surface/useTestDocument.d.ts +0 -32
- package/dist/admin/surface/useTestDocument.js +0 -415
- /package/dist/{admin → testSurface}/PreviewLinks.d.ts +0 -0
- /package/dist/{admin → testSurface}/actions/decide.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/actions/decide.model.js +0 -0
- /package/dist/{admin → testSurface}/allocation.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/allocation.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/arms.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/arms.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/pageTarget.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/pageTarget.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/params.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/params.model.js +0 -0
- /package/dist/{admin → testSurface}/copy/advanced.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/advanced.js +0 -0
- /package/dist/{admin → testSurface}/copy/arms.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/arms.js +0 -0
- /package/dist/{admin → testSurface}/copy/audience.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/audience.js +0 -0
- /package/dist/{admin → testSurface}/copy/recommendation.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/recommendation.js +0 -0
- /package/dist/{admin → testSurface}/copy/setting.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/setting.js +0 -0
- /package/dist/{admin → testSurface}/format/date.d.ts +0 -0
- /package/dist/{admin → testSurface}/format/date.js +0 -0
- /package/dist/{admin → testSurface}/labels.d.ts +0 -0
- /package/dist/{admin → testSurface}/labels.js +0 -0
- /package/dist/{admin → testSurface}/lockedNotice.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/lockedNotice.model.js +0 -0
- /package/dist/{admin → testSurface}/metricSource.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/metricSource.model.js +0 -0
- /package/dist/{admin → testSurface}/placements/placementLabels.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/placements/placementLabels.model.js +0 -0
- /package/dist/{admin → testSurface}/placements/usePlacementLabels.d.ts +0 -0
- /package/dist/{admin → testSurface}/placements/usePlacementLabels.js +0 -0
- /package/dist/{admin → testSurface}/reload.d.ts +0 -0
- /package/dist/{admin → testSurface}/reload.js +0 -0
- /package/dist/{admin → testSurface}/results/CappedCell.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/CappedCell.js +0 -0
- /package/dist/{admin → testSurface}/results/CiChart.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/CiChart.js +0 -0
- /package/dist/{admin → testSurface}/results/DataQualityPanel.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/DataQualityPanel.js +0 -0
- /package/dist/{admin → testSurface}/results/DataTable.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/DataTable.js +0 -0
- /package/dist/{admin → testSurface}/results/StatTile.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/StatTile.js +0 -0
- /package/dist/{admin → testSurface}/results/chart.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/chart.model.js +0 -0
- /package/dist/{admin → testSurface}/results/format.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/format.js +0 -0
- /package/dist/{admin → testSurface}/results/legacy.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/legacy.js +0 -0
- /package/dist/{admin → testSurface}/results/releasePages.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/releasePages.model.js +0 -0
- /package/dist/{admin → testSurface}/results/results.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.js +0 -0
- /package/dist/{admin → testSurface}/review/review.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/review/review.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/contracts.js +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/pageBlock.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/recommendation.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/recommendation.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/setting/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/setting.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/setting.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/AdvancedSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/PageHoldout.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/Rail.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/TargetingSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/jumpToSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/jumpToSection.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/pageParts.d.ts +0 -0
- /package/dist/{admin → testSurface}/targeting/targeting.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/targeting/targeting.model.js +0 -0
- /package/dist/{admin → testSurface}/theme.d.ts +0 -0
- /package/dist/{admin → testSurface}/theme.js +0 -0
- /package/dist/{admin → testSurface}/useApi.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { asymmetricGoal, goalContent, goalPlacementDetail, LEGACY_FAIRNESS } from '../goals/fairness.js';
|
|
2
2
|
import { XpAnalysisError } from '../errors.js';
|
|
3
|
-
import { canonicalHealth, mergePageHealth } from '../results/health.js';
|
|
3
|
+
import { canonicalHealth, mergePageHealth, rapidBrowserEvents } from '../results/health.js';
|
|
4
4
|
import { safeError } from '../log.js';
|
|
5
5
|
import { createLocalReq } from 'payload';
|
|
6
6
|
import { resultsCandidates, resultsExecutor, writeSnapshots } from '../db/snapshots.js';
|
|
@@ -11,6 +11,14 @@ import { analysePhase } from '../results/analyse.js';
|
|
|
11
11
|
import { firstExposures, perUnitValues, timestampMs } from '../results/aggregate.js';
|
|
12
12
|
import { rolloutAnalysisUnits } from '../results/rolloutUnits.js';
|
|
13
13
|
import { creditUserEvents, eligibleIdentityLinks } from '../results/identityCredit.js';
|
|
14
|
+
function* convertingUnits(units, values, ages) {
|
|
15
|
+
for (const [id, value] of values){
|
|
16
|
+
if (value > 0) yield {
|
|
17
|
+
arm: units.get(id).arm,
|
|
18
|
+
unitAgeMs: ages.get(id)?.unitAgeMs
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
14
22
|
async function analyseCandidate(exec, candidate, options, now, deadline, unavailableMetrics, logger) {
|
|
15
23
|
const { phase } = candidate;
|
|
16
24
|
// Rollout assignment preserves the original test ranges, but its SRM compares
|
|
@@ -53,6 +61,10 @@ async function analyseCandidate(exec, candidate, options, now, deadline, unavail
|
|
|
53
61
|
...units
|
|
54
62
|
].filter(([id])=>eligible.has(id)));
|
|
55
63
|
}
|
|
64
|
+
const comparedArms = new Set(analysisPhase.arms.filter((arm)=>phase.phaseKind === 'rollout' || arm.kind !== 'holdout').map((arm)=>arm.key));
|
|
65
|
+
// An age on an exposure is only written by browser ingestion, including
|
|
66
|
+
// browser-side manual exposures. Server-recorded exposures have unknown age.
|
|
67
|
+
let rapidActivity = rapidBrowserEvents(comparedArms, units.values());
|
|
56
68
|
const ids = [
|
|
57
69
|
...units.keys()
|
|
58
70
|
];
|
|
@@ -93,9 +105,8 @@ async function analyseCandidate(exec, candidate, options, now, deadline, unavail
|
|
|
93
105
|
// browser even if an earlier linked browser saw another arm or is ineligible.
|
|
94
106
|
const direct = userKeyed ? [] : events.filter((event)=>units.has(event.unitId) || event.userId == null || !linked.has(event.userId));
|
|
95
107
|
const userEvents = events.filter((event)=>userKeyed || !units.has(event.unitId) && event.userId != null && linked.has(event.userId)).map((event)=>({
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
ts: event.ts
|
|
108
|
+
...event,
|
|
109
|
+
userId: String(event.userId ?? event.unitId)
|
|
99
110
|
}));
|
|
100
111
|
const credited = creditUserEvents(units, identities, userEvents, (userId)=>identityConflicts.add(userId)).events;
|
|
101
112
|
for (const event of direct)if (event.userId != null && linked.has(event.userId)) {
|
|
@@ -121,8 +132,10 @@ async function analyseCandidate(exec, candidate, options, now, deadline, unavail
|
|
|
121
132
|
...units.values()
|
|
122
133
|
].reduce((earliest, unit)=>Math.min(earliest, +unit.firstTs), timestampMs(phase.startedAt)));
|
|
123
134
|
const preFrom = new Date(+from - 14 * 86_400_000);
|
|
135
|
+
const storedEvents = definition.source.startsWith('events:') || definition.source.startsWith('click:');
|
|
136
|
+
const readAge = storedEvents && definition.role === 'primary' && !rapidActivity;
|
|
124
137
|
let events, covariates;
|
|
125
|
-
if (
|
|
138
|
+
if (storedEvents) {
|
|
126
139
|
const eventName = definition.source.startsWith('click:') ? definition.source : definition.source.slice(7);
|
|
127
140
|
if (!definition.source.startsWith('click:') && !options.eventSources?.some((source)=>source.name === eventName)) throw new XpAnalysisError('source-unavailable');
|
|
128
141
|
const read = async (start)=>{
|
|
@@ -130,19 +143,24 @@ async function analyseCandidate(exec, candidate, options, now, deadline, unavail
|
|
|
130
143
|
eventName,
|
|
131
144
|
userIds: ids,
|
|
132
145
|
from: start,
|
|
133
|
-
to
|
|
146
|
+
to,
|
|
147
|
+
readAge
|
|
134
148
|
});
|
|
135
149
|
const direct = await metricEventRows(exec, {
|
|
136
150
|
eventName,
|
|
137
151
|
unitIds: ids,
|
|
138
152
|
from: start,
|
|
139
|
-
to
|
|
153
|
+
to,
|
|
154
|
+
readAge,
|
|
155
|
+
forVisitors: true
|
|
140
156
|
});
|
|
141
157
|
const signedIn = await metricEventRows(exec, {
|
|
142
158
|
eventName,
|
|
143
159
|
userIds,
|
|
144
160
|
from: start,
|
|
145
|
-
to
|
|
161
|
+
to,
|
|
162
|
+
readAge,
|
|
163
|
+
forVisitors: true
|
|
146
164
|
});
|
|
147
165
|
// The two lookups overlap when a linked user's own browser was exposed.
|
|
148
166
|
return [
|
|
@@ -226,13 +244,26 @@ async function analyseCandidate(exec, candidate, options, now, deadline, unavail
|
|
|
226
244
|
// The click-goal delta supersedes whole-phase attribution for mid-test adds.
|
|
227
245
|
// Retain pre-period events for CUPED above; exclude them from the outcome.
|
|
228
246
|
const outcomeEvents = definition.source.startsWith('click:') && definition.addedAt ? events.filter((event)=>timestampMs(event.ts) >= timestampMs(definition.addedAt)) : events;
|
|
247
|
+
const ages = new Map();
|
|
248
|
+
const values = perUnitValues(units, outcomeEvents, {
|
|
249
|
+
kind,
|
|
250
|
+
windowHours,
|
|
251
|
+
endedAt: to,
|
|
252
|
+
onAttributed: readAge ? (event, ts)=>{
|
|
253
|
+
if (event.unitAgeMs === undefined) return;
|
|
254
|
+
const previous = ages.get(event.unitId);
|
|
255
|
+
if (!previous || ts < previous.ts || ts === previous.ts && event.unitAgeMs > previous.unitAgeMs) {
|
|
256
|
+
ages.set(event.unitId, {
|
|
257
|
+
ts,
|
|
258
|
+
unitAgeMs: event.unitAgeMs
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
} : undefined
|
|
262
|
+
});
|
|
263
|
+
if (ages.size) rapidActivity = rapidBrowserEvents(comparedArms, convertingUnits(units, values, ages));
|
|
229
264
|
metricData.push({
|
|
230
265
|
metricId: definition.metricId,
|
|
231
|
-
values
|
|
232
|
-
kind,
|
|
233
|
-
windowHours,
|
|
234
|
-
endedAt: to
|
|
235
|
-
}),
|
|
266
|
+
values,
|
|
236
267
|
...covariates ? {
|
|
237
268
|
covariates
|
|
238
269
|
} : {}
|
|
@@ -287,6 +318,11 @@ async function analyseCandidate(exec, candidate, options, now, deadline, unavail
|
|
|
287
318
|
winnerArm: phase.arms.find((arm)=>arm.kind !== 'holdout').key
|
|
288
319
|
} : {}
|
|
289
320
|
});
|
|
321
|
+
if (rapidActivity) snapshot.health = [
|
|
322
|
+
{
|
|
323
|
+
code: 'rapid-browser-events'
|
|
324
|
+
}
|
|
325
|
+
];
|
|
290
326
|
return snapshot;
|
|
291
327
|
}
|
|
292
328
|
export async function runResults(payload, { budgetMs = 20_000, experimentId, sweep = true } = {}) {
|
|
@@ -407,10 +443,12 @@ export async function runResults(payload, { budgetMs = 20_000, experimentId, swe
|
|
|
407
443
|
for (const [index, snapshot] of snapshots.entries()){
|
|
408
444
|
const previous = phases[index].previousHealth ?? phases[index].frozenSnapshot?.health ?? [];
|
|
409
445
|
const unjudged = previous.filter((row)=>row.code === 'goal-in-some-versions' && content && content.unchecked.length > 0 && clicks.some((metric)=>metric.metricId === row.metricId && !asymmetricGoal(content, metric.source, arms)));
|
|
446
|
+
const activity = snapshot.health?.filter((row)=>row.code === 'rapid-browser-events') ?? [];
|
|
410
447
|
snapshot.health = mergePageHealth(unjudged, [
|
|
411
448
|
...health,
|
|
412
449
|
...goals,
|
|
413
|
-
...unchecked
|
|
450
|
+
...unchecked,
|
|
451
|
+
...activity
|
|
414
452
|
]);
|
|
415
453
|
if (content?.skipped && current.kind === 'block') snapshot.goalFairnessNotice = LEGACY_FAIRNESS;
|
|
416
454
|
else delete snapshot.goalFairnessNotice;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Payload, type PayloadRequest } from 'payload';
|
|
2
|
+
import type { DocId } from '../types/contracts.js';
|
|
3
|
+
import type { StartExperimentResult } from '../types/endpoints.js';
|
|
4
|
+
/** Start a test from trusted host code. Call this after your own transaction commits.
|
|
5
|
+
* Pass the caller's Payload request if available so an open transaction can be refused.
|
|
6
|
+
* Without it, Start can hang waiting for a lock your transaction already holds.
|
|
7
|
+
* If a thrown error has code `commit-unverified`, read the test's status before retrying.
|
|
8
|
+
* Start may have committed even though it could not verify the commit.
|
|
9
|
+
*/
|
|
10
|
+
export declare function startExperiment(payload: Payload, { experiment, req, onlyIfNeverStarted }: {
|
|
11
|
+
experiment: {
|
|
12
|
+
id: DocId;
|
|
13
|
+
} | {
|
|
14
|
+
slug: string;
|
|
15
|
+
};
|
|
16
|
+
/** Pass the caller's request, if available, to detect an open transaction. */
|
|
17
|
+
req?: Pick<PayloadRequest, 'transactionID'>;
|
|
18
|
+
/** Require a draft with no prior round. By default, a stopped test can start a new round. */
|
|
19
|
+
onlyIfNeverStarted?: boolean;
|
|
20
|
+
}): Promise<StartExperimentResult>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createLocalReq } from 'payload';
|
|
2
|
+
import { experimentId } from '../endpoints/routeId.js';
|
|
3
|
+
import { XpRefusal, XpStartTransactionOpen } from '../errors.js';
|
|
4
|
+
import { xpOptionsFromReq } from '../options/fromReq.js';
|
|
5
|
+
import { start } from '../transitions/start.js';
|
|
6
|
+
import { findStartDocuments } from '../transitions/startReads.js';
|
|
7
|
+
/** Start a test from trusted host code. Call this after your own transaction commits.
|
|
8
|
+
* Pass the caller's Payload request if available so an open transaction can be refused.
|
|
9
|
+
* Without it, Start can hang waiting for a lock your transaction already holds.
|
|
10
|
+
* If a thrown error has code `commit-unverified`, read the test's status before retrying.
|
|
11
|
+
* Start may have committed even though it could not verify the commit.
|
|
12
|
+
*/ export async function startExperiment(payload, { experiment, req, onlyIfNeverStarted }) {
|
|
13
|
+
try {
|
|
14
|
+
if (req?.transactionID != null) throw new XpStartTransactionOpen();
|
|
15
|
+
const systemReq = await createLocalReq({}, payload);
|
|
16
|
+
const options = xpOptionsFromReq(systemReq);
|
|
17
|
+
const id = 'id' in experiment ? experimentId(systemReq, experiment.id) : (await findStartDocuments(systemReq, {
|
|
18
|
+
collection: 'xp-experiments',
|
|
19
|
+
depth: 0,
|
|
20
|
+
limit: 1,
|
|
21
|
+
where: {
|
|
22
|
+
slug: {
|
|
23
|
+
equals: experiment.slug
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}, true)).docs[0]?.id;
|
|
27
|
+
if (id === undefined) return {
|
|
28
|
+
status: 'not-found'
|
|
29
|
+
};
|
|
30
|
+
const { doc, revision, detail } = await start(systemReq, {
|
|
31
|
+
experimentId: id,
|
|
32
|
+
options,
|
|
33
|
+
system: true,
|
|
34
|
+
onlyIfNeverStarted
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
status: 'started',
|
|
38
|
+
phase: doc.phase,
|
|
39
|
+
revision,
|
|
40
|
+
warnings: detail ?? []
|
|
41
|
+
};
|
|
42
|
+
} catch (error) {
|
|
43
|
+
if (error instanceof XpStartTransactionOpen) return {
|
|
44
|
+
status: 'refused',
|
|
45
|
+
code: 'transaction-open',
|
|
46
|
+
message: error.message
|
|
47
|
+
};
|
|
48
|
+
if (!(error instanceof XpRefusal) || error.status === 500 || error.code === 'commit-unverified') throw error;
|
|
49
|
+
if (error.code === 'not-found') return {
|
|
50
|
+
status: 'not-found'
|
|
51
|
+
};
|
|
52
|
+
const { code, message, detail } = error;
|
|
53
|
+
if (code === 'first-start-only') {
|
|
54
|
+
return {
|
|
55
|
+
status: 'refused',
|
|
56
|
+
code,
|
|
57
|
+
message,
|
|
58
|
+
detail: detail
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
status: 'refused',
|
|
63
|
+
code,
|
|
64
|
+
message,
|
|
65
|
+
...detail === undefined ? {} : {
|
|
66
|
+
detail
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { safeError } from '../log.js';
|
|
2
2
|
import { NextRequest } from 'next/server.js';
|
|
3
3
|
import { pooledExecutor } from '../db/executor.js';
|
|
4
|
-
import {
|
|
4
|
+
import { insertServerConversion } from '../db/events.js';
|
|
5
5
|
import { readUnitCookie } from '../runtime/cookie.js';
|
|
6
6
|
export async function trackConversion(serverRuntime, event) {
|
|
7
7
|
let payload;
|
|
@@ -46,18 +46,15 @@ export async function trackConversion(serverRuntime, event) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
if (!visitorId && !userId) return;
|
|
49
|
-
await
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
ts: new Date().toISOString()
|
|
59
|
-
}
|
|
60
|
-
], (message)=>payload.logger.error(message));
|
|
49
|
+
await insertServerConversion(pooledExecutor(payload), {
|
|
50
|
+
eventName: event.eventName,
|
|
51
|
+
value: event.value ?? 1,
|
|
52
|
+
unitId: visitorId ?? userId,
|
|
53
|
+
unitType: visitorId ? 'visitor' : 'user',
|
|
54
|
+
userId,
|
|
55
|
+
idempotencyKey: event.idempotencyKey,
|
|
56
|
+
ts: new Date().toISOString()
|
|
57
|
+
}, (message)=>payload.logger.error(message));
|
|
61
58
|
} catch (error) {
|
|
62
59
|
try {
|
|
63
60
|
payload?.logger.error({
|
|
@@ -5,6 +5,7 @@ import { Button } from '../ui/Button.js';
|
|
|
5
5
|
import { armLabel } from './labels.js';
|
|
6
6
|
import { useApi } from './useApi.js';
|
|
7
7
|
import { REVIEW_COPY as C } from './copy/review.js';
|
|
8
|
+
import { placementLabel } from './placementLabel.js';
|
|
8
9
|
import { TEST_PAGE } from './copy/testPage.js';
|
|
9
10
|
import { API_MESSAGES, refusalMessage } from './copy/common.js';
|
|
10
11
|
import { actionablePreviewPages } from './previewLinks.model.js';
|
|
@@ -55,15 +56,16 @@ export function PreviewLinks({ experimentId, placements, arms, flagPoint, apiRou
|
|
|
55
56
|
setBusy(false);
|
|
56
57
|
}
|
|
57
58
|
}
|
|
59
|
+
const pages = actionablePreviewPages(placements, flagPoint);
|
|
58
60
|
return /*#__PURE__*/ _jsxs("div", {
|
|
59
61
|
className: "xp-preview-links",
|
|
60
62
|
children: [
|
|
61
|
-
|
|
63
|
+
pages.map((placement)=>/*#__PURE__*/ _jsxs("div", {
|
|
62
64
|
className: "xp-preview-row",
|
|
63
65
|
children: [
|
|
64
66
|
/*#__PURE__*/ _jsxs("p", {
|
|
65
67
|
children: [
|
|
66
|
-
placement
|
|
68
|
+
placementLabel(placement),
|
|
67
69
|
placement.slotCount > 1 ? ` ${C.placedTimes(placement.slotCount)}` : null
|
|
68
70
|
]
|
|
69
71
|
}),
|
|
@@ -73,6 +75,7 @@ export function PreviewLinks({ experimentId, placements, arms, flagPoint, apiRou
|
|
|
73
75
|
placement.url ? arms.filter((arm)=>arm.kind !== 'holdout' && arm.key !== 'holdout').map((arm)=>/*#__PURE__*/ _jsxs(Button, {
|
|
74
76
|
variant: "secondary",
|
|
75
77
|
size: "sm",
|
|
78
|
+
"aria-label": pages.length > 1 ? `${C.preview} ${arm.label?.trim() || armLabel(arm.key)}: ${placementLabel(placement)}` : undefined,
|
|
76
79
|
disabled: busy,
|
|
77
80
|
onClick: ()=>{
|
|
78
81
|
void preview(placement.url, arm.key);
|
|
@@ -87,6 +90,7 @@ export function PreviewLinks({ experimentId, placements, arms, flagPoint, apiRou
|
|
|
87
90
|
variant: "link",
|
|
88
91
|
size: "sm",
|
|
89
92
|
href: placement.editorUrl,
|
|
93
|
+
"aria-label": pages.length > 1 ? `${TEST_PAGE.editOnPage}: ${placementLabel(placement)}` : undefined,
|
|
90
94
|
children: TEST_PAGE.editOnPage
|
|
91
95
|
}) : null
|
|
92
96
|
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DocId } from '../../types/contracts.js';
|
|
2
|
+
import type { PreflightResult } from '../../types/endpoints.js';
|
|
3
|
+
import { type ActionGroup } from './actions.model.js';
|
|
4
|
+
export declare function DecideDialog({ id, name, phase, arms, checks, unavailable, pending, onClose, apiRoute, onSuccess, onRefusal }: {
|
|
5
|
+
apiRoute: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
phase?: number;
|
|
8
|
+
onRefusal?: () => void;
|
|
9
|
+
unavailable?: boolean;
|
|
10
|
+
pending?: boolean;
|
|
11
|
+
onSuccess?: (doc?: Record<string, unknown>) => void;
|
|
12
|
+
id: DocId;
|
|
13
|
+
arms?: readonly ActionGroup[];
|
|
14
|
+
checks?: PreflightResult['checks'];
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
}): import("react").JSX.Element;
|
|
@@ -7,13 +7,19 @@ import { unsupportedContentCopy } from '../copy/readiness.js';
|
|
|
7
7
|
import { useApi } from '../useApi.js';
|
|
8
8
|
import { reloadPage } from '../reload.js';
|
|
9
9
|
import { RESULTS_COPY } from '../copy/results.js';
|
|
10
|
-
import { ACTIONS_COPY as C, decideCopy } from '../copy/actions.js';
|
|
10
|
+
import { ACTIONS_COPY as C, actionTitle, decideCopy } from '../copy/actions.js';
|
|
11
|
+
import { READINESS_COPY } from '../copy/readiness.js';
|
|
12
|
+
import { isDestructiveAction } from './actions.model.js';
|
|
11
13
|
import { decideState } from './decide.model.js';
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
+
import { ConfirmDialog } from '../../ui/Dialog.js';
|
|
15
|
+
import { notifyTestDocument } from '../surface/watchTestDocument.js';
|
|
16
|
+
export function DecideDialog({ id, name, phase, arms, checks = [], unavailable, pending, onClose, apiRoute, onSuccess, onRefusal }) {
|
|
14
17
|
const api = useApi(apiRoute);
|
|
15
18
|
const [snapshot, setSnapshot] = useState(null);
|
|
16
|
-
const [
|
|
19
|
+
const [roundArms, setRoundArms] = useState();
|
|
20
|
+
const frozenArms = roundArms ?? arms;
|
|
21
|
+
const [chosen, setChosenArm] = useState();
|
|
22
|
+
const chosenArm = chosen === undefined ? snapshot?.verdict.recommendedArm ?? null : chosen;
|
|
17
23
|
const [note, setNote] = useState('');
|
|
18
24
|
const [typed, setTyped] = useState('');
|
|
19
25
|
const [loading, setLoading] = useState(true);
|
|
@@ -22,21 +28,29 @@ export function DecideDialog({ id, arms, checks = [], onClose, apiRoute }) {
|
|
|
22
28
|
const refreshing = useRef(false);
|
|
23
29
|
const [error, setError] = useState(null);
|
|
24
30
|
const [loadFailed, setLoadFailed] = useState(false);
|
|
31
|
+
const accessRefused = !!error && [
|
|
32
|
+
401,
|
|
33
|
+
403,
|
|
34
|
+
404
|
|
35
|
+
].includes(error.status);
|
|
36
|
+
const statusRefused = accessRefused || error?.code === 'round-changed' || error?.code === 'invalid-status';
|
|
25
37
|
const state = decideState({
|
|
26
38
|
snapshot,
|
|
27
|
-
arms,
|
|
39
|
+
arms: frozenArms ?? [],
|
|
28
40
|
chosenArm,
|
|
29
41
|
note,
|
|
30
42
|
typed
|
|
31
43
|
});
|
|
32
44
|
useEffect(()=>{
|
|
33
45
|
let current = true;
|
|
34
|
-
void api.results(id
|
|
46
|
+
void api.results(id, {
|
|
47
|
+
phase
|
|
48
|
+
}).then((result)=>{
|
|
35
49
|
if (!current) return;
|
|
36
50
|
if (result.ok) {
|
|
37
51
|
const next = result.data?.snapshot ?? null;
|
|
38
52
|
setSnapshot(next);
|
|
39
|
-
|
|
53
|
+
setRoundArms(result.data?.phases?.find((round)=>round.phase === phase && round.phaseKind === 'test')?.arms);
|
|
40
54
|
} else {
|
|
41
55
|
setError(result);
|
|
42
56
|
setLoadFailed(true);
|
|
@@ -48,17 +62,21 @@ export function DecideDialog({ id, arms, checks = [], onClose, apiRoute }) {
|
|
|
48
62
|
};
|
|
49
63
|
}, [
|
|
50
64
|
api,
|
|
51
|
-
id
|
|
65
|
+
id,
|
|
66
|
+
phase
|
|
52
67
|
]);
|
|
53
68
|
async function refresh() {
|
|
54
69
|
if (refreshing.current) return;
|
|
55
70
|
refreshing.current = true;
|
|
56
71
|
setLoading(true);
|
|
57
|
-
const result = await api.results(id
|
|
72
|
+
const result = await api.results(id, {
|
|
73
|
+
phase
|
|
74
|
+
});
|
|
58
75
|
refreshing.current = false;
|
|
59
76
|
setLoading(false);
|
|
60
77
|
if (result.ok) {
|
|
61
78
|
setSnapshot(result.data?.snapshot ?? null);
|
|
79
|
+
setRoundArms(result.data?.phases?.find((round)=>round.phase === phase && round.phaseKind === 'test')?.arms);
|
|
62
80
|
setLoadFailed(false);
|
|
63
81
|
} else {
|
|
64
82
|
setSnapshot(null);
|
|
@@ -67,33 +85,59 @@ export function DecideDialog({ id, arms, checks = [], onClose, apiRoute }) {
|
|
|
67
85
|
}
|
|
68
86
|
}
|
|
69
87
|
async function submit() {
|
|
70
|
-
if (inFlight.current || loading || busy || !state.canSubmit || loadFailed) return;
|
|
88
|
+
if (unavailable || pending || statusRefused || inFlight.current || loading || busy || !state.canSubmit || loadFailed) return;
|
|
71
89
|
inFlight.current = true;
|
|
90
|
+
setChosenArm(chosenArm);
|
|
72
91
|
setBusy(true);
|
|
73
92
|
setError(null);
|
|
74
|
-
const result = await api.decide(id,
|
|
93
|
+
const result = await api.decide(id, {
|
|
94
|
+
...state.body,
|
|
95
|
+
phase
|
|
96
|
+
});
|
|
75
97
|
if (result.ok) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (result.code === 'confirmation-required') {
|
|
81
|
-
setTyped('');
|
|
82
|
-
await refresh();
|
|
98
|
+
if (onSuccess) onSuccess(result.data?.doc);
|
|
99
|
+
else {
|
|
100
|
+
notifyTestDocument(apiRoute, id);
|
|
101
|
+
reloadPage();
|
|
83
102
|
}
|
|
103
|
+
return;
|
|
84
104
|
}
|
|
105
|
+
setError(result);
|
|
106
|
+
if (result.code === 'confirmation-required') {
|
|
107
|
+
await refresh();
|
|
108
|
+
} else if (result.status === 409 || result.code === 'invalid-status') onRefusal?.();
|
|
85
109
|
inFlight.current = false;
|
|
86
110
|
setBusy(false);
|
|
87
111
|
}
|
|
88
|
-
const enabled = !busy && !loading && !loadFailed && state.canSubmit;
|
|
112
|
+
const enabled = !unavailable && !pending && !statusRefused && !busy && !loading && !loadFailed && state.canSubmit;
|
|
89
113
|
const label = state.options.find((option)=>option.value === chosenArm)?.label;
|
|
90
|
-
return /*#__PURE__*/ _jsxs(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
title: C.decide,
|
|
114
|
+
return /*#__PURE__*/ _jsxs(ConfirmDialog, {
|
|
115
|
+
title: name ? actionTitle(C.titleLead.decide, name) : C.decide,
|
|
116
|
+
description: C.decideBody,
|
|
94
117
|
onClose: ()=>{
|
|
95
|
-
|
|
118
|
+
onClose();
|
|
119
|
+
if (accessRefused) onRefusal?.();
|
|
120
|
+
},
|
|
121
|
+
busy: busy,
|
|
122
|
+
busyLabel: READINESS_COPY.changing,
|
|
123
|
+
cancelLabel: C.cancel,
|
|
124
|
+
error: error?.message ?? (unavailable ? C.decisionUnavailable : !loading && !frozenArms ? C.decideRoundMissing : null),
|
|
125
|
+
confirm: {
|
|
126
|
+
label: C.decide,
|
|
127
|
+
disabled: !enabled,
|
|
128
|
+
destructive: isDestructiveAction('decide'),
|
|
129
|
+
onClick: submit
|
|
96
130
|
},
|
|
131
|
+
secondaryAction: !unavailable && error?.retryable ? /*#__PURE__*/ _jsx(Button, {
|
|
132
|
+
disabled: busy || pending || loading || !loadFailed && !state.canSubmit,
|
|
133
|
+
onClick: ()=>{
|
|
134
|
+
if (loadFailed) {
|
|
135
|
+
setError(null);
|
|
136
|
+
void refresh();
|
|
137
|
+
} else void submit();
|
|
138
|
+
},
|
|
139
|
+
children: C.retry
|
|
140
|
+
}) : null,
|
|
97
141
|
children: [
|
|
98
142
|
loading ? /*#__PURE__*/ _jsx("p", {
|
|
99
143
|
role: "status",
|
|
@@ -122,7 +166,7 @@ export function DecideDialog({ id, arms, checks = [], onClose, apiRoute }) {
|
|
|
122
166
|
]
|
|
123
167
|
}),
|
|
124
168
|
label ? /*#__PURE__*/ _jsx("p", {
|
|
125
|
-
children: decideCopy(label,
|
|
169
|
+
children: decideCopy(label, !!frozenArms?.some((group)=>group.key === 'holdout'), chosenArm === 'control')
|
|
126
170
|
}) : null,
|
|
127
171
|
checks.filter((check)=>check.code === 'make-content-unsupported' && check.warning).map((check)=>/*#__PURE__*/ _jsx("p", {
|
|
128
172
|
children: unsupportedContentCopy(typeof check.detail === 'string' ? check.detail : 'This page')
|
|
@@ -136,7 +180,10 @@ export function DecideDialog({ id, arms, checks = [], onClose, apiRoute }) {
|
|
|
136
180
|
value: note,
|
|
137
181
|
required: state.guarded,
|
|
138
182
|
readOnly: busy,
|
|
139
|
-
onChange: (event)=>
|
|
183
|
+
onChange: (event)=>{
|
|
184
|
+
if (chosenArm !== null) setChosenArm(chosenArm);
|
|
185
|
+
setNote(event.target.value);
|
|
186
|
+
}
|
|
140
187
|
}),
|
|
141
188
|
state.guarded && label ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
142
189
|
children: [
|
|
@@ -154,37 +201,13 @@ export function DecideDialog({ id, arms, checks = [], onClose, apiRoute }) {
|
|
|
154
201
|
label: C.confirmation,
|
|
155
202
|
value: typed,
|
|
156
203
|
readOnly: busy,
|
|
157
|
-
onChange: (event)=>
|
|
204
|
+
onChange: (event)=>{
|
|
205
|
+
setChosenArm(chosenArm);
|
|
206
|
+
setTyped(event.target.value);
|
|
207
|
+
}
|
|
158
208
|
})
|
|
159
209
|
]
|
|
160
|
-
}) : null
|
|
161
|
-
error ? /*#__PURE__*/ _jsx("p", {
|
|
162
|
-
role: "alert",
|
|
163
|
-
children: error.message
|
|
164
|
-
}) : null,
|
|
165
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
166
|
-
disabled: !enabled,
|
|
167
|
-
onClick: ()=>{
|
|
168
|
-
void submit();
|
|
169
|
-
},
|
|
170
|
-
children: C.decide
|
|
171
|
-
}),
|
|
172
|
-
error?.retryable ? /*#__PURE__*/ _jsx(Button, {
|
|
173
|
-
disabled: busy || loading || !loadFailed && !state.canSubmit,
|
|
174
|
-
onClick: ()=>{
|
|
175
|
-
if (loadFailed) {
|
|
176
|
-
setError(null);
|
|
177
|
-
void refresh();
|
|
178
|
-
} else void submit();
|
|
179
|
-
},
|
|
180
|
-
children: C.retry
|
|
181
|
-
}) : null,
|
|
182
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
183
|
-
"data-dialog-cancel": true,
|
|
184
|
-
disabled: busy,
|
|
185
|
-
onClick: onClose,
|
|
186
|
-
children: C.cancel
|
|
187
|
-
})
|
|
210
|
+
}) : null
|
|
188
211
|
]
|
|
189
212
|
});
|
|
190
213
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ActionTestApi, SurfaceProps } from '../surface/contracts.js';
|
|
2
|
+
import { type ExperimentAction } from './actions.model.js';
|
|
3
|
+
export declare function LifecycleButton({ action, reason, showReason, disabled, busy, onClick }: {
|
|
4
|
+
action: ExperimentAction;
|
|
5
|
+
reason?: string;
|
|
6
|
+
showReason?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
busy?: boolean;
|
|
9
|
+
onClick: () => void;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
11
|
+
export declare function LifecycleDialog({ action, test, surface, onClose }: {
|
|
12
|
+
action: ExperimentAction;
|
|
13
|
+
test: ActionTestApi;
|
|
14
|
+
surface: SurfaceProps;
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
}): import("react").JSX.Element;
|