@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
|
@@ -33,6 +33,7 @@ async function body(req) {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
const only = (value, keys)=>Object.keys(value).every((key)=>keys.includes(key));
|
|
36
|
+
const validPhase = (phase)=>phase === undefined || typeof phase === 'number' && Number.isSafeInteger(phase) && phase >= 0;
|
|
36
37
|
async function respond(req, action) {
|
|
37
38
|
const id = routeId(req);
|
|
38
39
|
if (id === undefined) return Response.json({
|
|
@@ -63,15 +64,18 @@ async function respond(req, action) {
|
|
|
63
64
|
}
|
|
64
65
|
]
|
|
65
66
|
}, {
|
|
66
|
-
status: cause.status === 409 ? 422 : cause.status
|
|
67
|
+
status: cause.status === 409 && cause.code !== 'round-changed' ? 422 : cause.status
|
|
67
68
|
});
|
|
68
69
|
throw cause;
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
export async function handleStart(req, ctx) {
|
|
72
73
|
const value = await body(req);
|
|
73
|
-
if (!value || !only(value, [
|
|
74
|
+
if (!value || !only(value, [
|
|
75
|
+
'phase'
|
|
76
|
+
]) || !validPhase(value.phase)) return invalidBody();
|
|
74
77
|
return respond(req, (id)=>start(req, {
|
|
78
|
+
...value,
|
|
75
79
|
experimentId: id,
|
|
76
80
|
options: ctx.options
|
|
77
81
|
}));
|
|
@@ -79,32 +83,34 @@ export async function handleStart(req, ctx) {
|
|
|
79
83
|
export async function handleAllocate(req, _ctx) {
|
|
80
84
|
const value = await body(req);
|
|
81
85
|
if (!value || !only(value, [
|
|
82
|
-
'allocation'
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
'allocation',
|
|
87
|
+
'phase'
|
|
88
|
+
]) || !validPhase(value.phase) || typeof value.allocation !== 'number' || !Number.isInteger(value.allocation) || value.allocation < 1 || value.allocation > 100) return invalidBody();
|
|
85
89
|
return respond(req, (id)=>allocate(req, {
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
...value,
|
|
91
|
+
experimentId: id
|
|
88
92
|
}));
|
|
89
93
|
}
|
|
90
94
|
export async function handleAddMetric(req, ctx) {
|
|
91
95
|
const value = await body(req);
|
|
92
96
|
if (!value || !only(value, [
|
|
93
97
|
'metric',
|
|
94
|
-
'role'
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
'role',
|
|
99
|
+
'phase'
|
|
100
|
+
]) || !validPhase(value.phase) || !(typeof value.metric === 'string' && value.metric.trim() || typeof value.metric === 'number' && Number.isSafeInteger(value.metric)) || value.role !== 'secondary' && value.role !== 'guardrail') return invalidBody();
|
|
97
101
|
return respond(req, (id)=>addMetric(req, {
|
|
102
|
+
...value,
|
|
98
103
|
experimentId: id,
|
|
99
|
-
metric,
|
|
100
|
-
role,
|
|
101
104
|
options: ctx.options
|
|
102
105
|
}));
|
|
103
106
|
}
|
|
104
107
|
export async function handleStop(req, _ctx) {
|
|
105
108
|
const value = await body(req);
|
|
106
|
-
if (!value || !only(value, [
|
|
109
|
+
if (!value || !only(value, [
|
|
110
|
+
'phase'
|
|
111
|
+
]) || !validPhase(value.phase)) return invalidBody();
|
|
107
112
|
return respond(req, (id)=>stop(req, {
|
|
113
|
+
...value,
|
|
108
114
|
experimentId: id
|
|
109
115
|
}));
|
|
110
116
|
}
|
|
@@ -113,35 +119,42 @@ export async function handleDecide(req, _ctx) {
|
|
|
113
119
|
if (!value || !only(value, [
|
|
114
120
|
'winnerArm',
|
|
115
121
|
'note',
|
|
116
|
-
'confirmation'
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
'confirmation',
|
|
123
|
+
'phase'
|
|
124
|
+
]) || !validPhase(value.phase) || typeof value.winnerArm !== 'string' || value.note !== undefined && typeof value.note !== 'string' || value.confirmation !== undefined && typeof value.confirmation !== 'string') return invalidBody();
|
|
119
125
|
return respond(req, (id)=>decide(req, {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
note,
|
|
123
|
-
confirmation
|
|
126
|
+
...value,
|
|
127
|
+
experimentId: id
|
|
124
128
|
}));
|
|
125
129
|
}
|
|
126
130
|
export async function handleReleaseHoldout(req, _ctx) {
|
|
127
131
|
const value = await body(req);
|
|
128
|
-
if (!value || !only(value, [
|
|
132
|
+
if (!value || !only(value, [
|
|
133
|
+
'phase'
|
|
134
|
+
]) || !validPhase(value.phase)) return invalidBody();
|
|
129
135
|
return respond(req, (id)=>releaseHoldout(req, {
|
|
136
|
+
...value,
|
|
130
137
|
experimentId: id
|
|
131
138
|
}));
|
|
132
139
|
}
|
|
133
140
|
export async function handleMakeContent(req, ctx) {
|
|
134
141
|
const value = await body(req);
|
|
135
|
-
if (!value || !only(value, [
|
|
142
|
+
if (!value || !only(value, [
|
|
143
|
+
'phase'
|
|
144
|
+
]) || !validPhase(value.phase)) return invalidBody();
|
|
136
145
|
return respond(req, (id)=>makeContent(req, {
|
|
146
|
+
...value,
|
|
137
147
|
experimentId: id,
|
|
138
148
|
options: ctx.options
|
|
139
149
|
}));
|
|
140
150
|
}
|
|
141
151
|
export async function handleReleasePages(req, _ctx) {
|
|
142
152
|
const value = await body(req);
|
|
143
|
-
if (!value || !only(value, [
|
|
153
|
+
if (!value || !only(value, [
|
|
154
|
+
'phase'
|
|
155
|
+
]) || !validPhase(value.phase)) return invalidBody();
|
|
144
156
|
return respond(req, (id)=>releasePages(req, {
|
|
157
|
+
...value,
|
|
145
158
|
experimentId: id
|
|
146
159
|
}));
|
|
147
160
|
}
|
|
@@ -175,17 +188,16 @@ export async function handleArchive(req, _ctx) {
|
|
|
175
188
|
const value = await body(req);
|
|
176
189
|
if (!value || !only(value, [
|
|
177
190
|
'mode',
|
|
178
|
-
'confirmation'
|
|
179
|
-
|
|
191
|
+
'confirmation',
|
|
192
|
+
'phase'
|
|
193
|
+
]) || !validPhase(value.phase) || ![
|
|
180
194
|
'stopped',
|
|
181
195
|
'after-content',
|
|
182
196
|
'discard',
|
|
183
197
|
'hard-coded'
|
|
184
198
|
].includes(value.mode) || value.confirmation !== undefined && typeof value.confirmation !== 'string') return invalidBody();
|
|
185
|
-
const { mode, confirmation } = value;
|
|
186
199
|
return respond(req, (id)=>archive(req, {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
confirmation
|
|
200
|
+
...value,
|
|
201
|
+
experimentId: id
|
|
190
202
|
}));
|
|
191
203
|
}
|
package/dist/errors.d.ts
CHANGED
|
@@ -17,11 +17,16 @@ export declare class XpNoTransactionError extends Error {
|
|
|
17
17
|
name: string;
|
|
18
18
|
constructor(message?: string);
|
|
19
19
|
}
|
|
20
|
+
export declare class XpStartTransactionOpen extends Error {
|
|
21
|
+
name: string;
|
|
22
|
+
constructor();
|
|
23
|
+
}
|
|
20
24
|
export declare class XpRefusal extends Error {
|
|
21
25
|
readonly code: RefusalCode;
|
|
22
26
|
readonly detail: unknown | undefined;
|
|
23
27
|
readonly status: 409 | 413 | 422 | 500 | 404;
|
|
24
28
|
name: string;
|
|
29
|
+
readonly isOperational = true;
|
|
25
30
|
readonly isPublic = true;
|
|
26
31
|
constructor(code: RefusalCode, message: string, detail: unknown | undefined, status: 409 | 413 | 422 | 500 | 404, options?: ErrorOptions);
|
|
27
32
|
}
|
package/dist/errors.js
CHANGED
|
@@ -21,11 +21,19 @@ export class XpNoTransactionError extends Error {
|
|
|
21
21
|
super(message);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
export class XpStartTransactionOpen extends Error {
|
|
25
|
+
name = 'XpStartTransactionOpen';
|
|
26
|
+
constructor(){
|
|
27
|
+
super('Call startExperiment after your transaction commits.');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
24
30
|
export class XpRefusal extends Error {
|
|
25
31
|
code;
|
|
26
32
|
detail;
|
|
27
33
|
status;
|
|
28
34
|
name = 'XpRefusal';
|
|
35
|
+
// Payload-compatible marker used by Puck's public-error response mapper.
|
|
36
|
+
isOperational = true;
|
|
29
37
|
isPublic = true;
|
|
30
38
|
constructor(code, message, detail, status, options){
|
|
31
39
|
super(message, options), this.code = code, this.detail = detail, this.status = status;
|
package/dist/events/request.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { NextRequest } from 'next/server.js';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
export declare function publicEventOrigin(value: string | undefined): string | undefined;
|
|
3
|
+
/** Fetch Metadata wins. For older clients, use only the deployment's configured origin. */
|
|
4
|
+
export declare function eventRequestContext(request: NextRequest, publicOrigin: string | undefined): {
|
|
5
|
+
allowed: boolean;
|
|
6
|
+
source: NextRequest | null;
|
|
7
|
+
};
|
package/dist/events/request.js
CHANGED
|
@@ -1,14 +1,41 @@
|
|
|
1
1
|
import { NextRequest } from 'next/server.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (!referrer) return null;
|
|
2
|
+
function webUrl(value) {
|
|
3
|
+
if (!value) return null;
|
|
5
4
|
try {
|
|
6
|
-
const url = new URL(
|
|
7
|
-
|
|
8
|
-
return new NextRequest(url, {
|
|
9
|
-
headers: request.headers
|
|
10
|
-
});
|
|
5
|
+
const url = new URL(value);
|
|
6
|
+
return (url.protocol === 'http:' || url.protocol === 'https:') && !url.username && !url.password ? url : null;
|
|
11
7
|
} catch {
|
|
12
8
|
return null;
|
|
13
9
|
}
|
|
14
10
|
}
|
|
11
|
+
export function publicEventOrigin(value) {
|
|
12
|
+
if (typeof value === 'string' && /^https?:\/\/[^/?#\\\s]+\/?$/i.test(value)) return webUrl(value)?.origin;
|
|
13
|
+
}
|
|
14
|
+
function browserRequestOrigin(request) {
|
|
15
|
+
// Next can construct the URL from its listener address behind a reverse proxy.
|
|
16
|
+
// Use the forwarded authority only to recover page context after Fetch Metadata passed.
|
|
17
|
+
const host = request.headers.get('x-forwarded-host') ?? request.headers.get('host');
|
|
18
|
+
const protocol = request.headers.get('x-forwarded-proto') ?? request.nextUrl.protocol.slice(0, -1);
|
|
19
|
+
if (host && /^[^\s,/?#@\\]+$/.test(host) && (protocol === 'http' || protocol === 'https')) {
|
|
20
|
+
const origin = publicEventOrigin(`${protocol}://${host}`);
|
|
21
|
+
if (origin) return origin;
|
|
22
|
+
}
|
|
23
|
+
return request.nextUrl.origin;
|
|
24
|
+
}
|
|
25
|
+
/** Fetch Metadata wins. For older clients, use only the deployment's configured origin. */ export function eventRequestContext(request, publicOrigin) {
|
|
26
|
+
const site = request.headers.get('sec-fetch-site');
|
|
27
|
+
const origin = request.headers.get('origin');
|
|
28
|
+
const referrer = request.headers.get('referer');
|
|
29
|
+
const page = webUrl(referrer);
|
|
30
|
+
// Same-site can include siblings. None describes direct navigation, not a page beacon.
|
|
31
|
+
const allowed = site !== null ? site === 'same-origin' : origin !== null ? origin === publicOrigin : referrer === null || page !== null && page.origin === publicOrigin;
|
|
32
|
+
const pageOrigin = site === 'same-origin' ? browserRequestOrigin(request) : publicOrigin;
|
|
33
|
+
const senderOrigin = publicEventOrigin(origin ?? undefined);
|
|
34
|
+
const source = allowed && page && page.origin === pageOrigin && (!senderOrigin || senderOrigin === pageOrigin) ? new NextRequest(page, {
|
|
35
|
+
headers: request.headers
|
|
36
|
+
}) : null;
|
|
37
|
+
return {
|
|
38
|
+
allowed,
|
|
39
|
+
source
|
|
40
|
+
};
|
|
41
|
+
}
|
package/dist/events/rows.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ import type { ResolvedOptions } from '../types/contracts.js';
|
|
|
4
4
|
import type { Manifest } from '../types/manifest.js';
|
|
5
5
|
export declare function eventRows<TUser extends {
|
|
6
6
|
id: string | number;
|
|
7
|
-
}>(events: unknown[], manifest: Manifest, assignments: AssignmentResult, options: ResolvedOptions<TUser>, visitorId: string, userId: string | undefined, ts: string, requestAttributes?: Readonly<Record<string, unknown>>, clickKeys?: ReadonlySet<string>): EventRow[];
|
|
7
|
+
}>(events: unknown[], manifest: Manifest, assignments: AssignmentResult, options: ResolvedOptions<TUser>, visitorId: string | undefined, userId: string | undefined, ts: string, unitAgeMs: number | 'legacy' | null, requestAttributes?: Readonly<Record<string, unknown>>, clickKeys?: ReadonlySet<string>): EventRow[];
|
package/dist/events/rows.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isClickSource } from '../goals/key.js';
|
|
2
2
|
import { exposureDimensions } from './dimensions.js';
|
|
3
|
+
import { browserWritableEvent } from './writable.js';
|
|
4
|
+
import { USER_BROWSER_CONVERSION_PREFIX } from '../constants.js';
|
|
3
5
|
function record(value) {
|
|
4
6
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
5
7
|
}
|
|
@@ -10,8 +12,13 @@ function record(value) {
|
|
|
10
12
|
return definition && typeof item === definition.type && (typeof item !== 'number' || Number.isFinite(item)) && (!definition.values || typeof item === 'string' && definition.values.includes(item));
|
|
11
13
|
}));
|
|
12
14
|
}
|
|
13
|
-
export function eventRows(events, manifest, assignments, options, visitorId, userId, ts, requestAttributes = {}, clickKeys) {
|
|
15
|
+
export function eventRows(events, manifest, assignments, options, visitorId, userId, ts, unitAgeMs, requestAttributes = {}, clickKeys) {
|
|
14
16
|
const rows = new Map();
|
|
17
|
+
const telemetry = {
|
|
18
|
+
_xp: {
|
|
19
|
+
unitAgeMs
|
|
20
|
+
}
|
|
21
|
+
};
|
|
15
22
|
for (const event of events){
|
|
16
23
|
if (!record(event)) continue;
|
|
17
24
|
let row;
|
|
@@ -37,26 +44,35 @@ export function eventRows(events, manifest, assignments, options, visitorId, use
|
|
|
37
44
|
userId,
|
|
38
45
|
ts,
|
|
39
46
|
dimensions: mismatch ? null : exposureDimensions(requestAttributes, options.events?.dimensions),
|
|
47
|
+
attributes: telemetry,
|
|
40
48
|
// §5.5 / §11: diagnostics are separate rows, never exposure denominators or multi-arm counts.
|
|
41
49
|
dedupeKey: mismatch ? `mismatch:${experiment.id}:${experiment.phase}:${unitId}:${ts.slice(0, 10)}` : `exposure:${experiment.id}:${experiment.phase}:${event.arm}:${unitId}:${ts.slice(0, 10)}`
|
|
42
50
|
};
|
|
43
51
|
} else if (event.type === 'conversion') {
|
|
44
52
|
if (typeof event.eventName !== 'string' || typeof event.idempotencyKey !== 'string' || !event.idempotencyKey.trim() || event.value !== undefined && (typeof event.value !== 'number' || !Number.isFinite(event.value))) continue;
|
|
45
|
-
const source = options.metricSources?.find((source)=>source.id === event.eventName);
|
|
46
53
|
const click = isClickSource(event.eventName);
|
|
47
|
-
if (
|
|
54
|
+
if (!browserWritableEvent(event.eventName, options) || click && !clickKeys?.has(event.eventName.slice(6))) continue;
|
|
55
|
+
const unitId = visitorId ?? userId;
|
|
56
|
+
if (!unitId) continue;
|
|
48
57
|
row = {
|
|
49
58
|
type: 'conversion',
|
|
50
59
|
eventName: event.eventName,
|
|
51
60
|
value: 1,
|
|
52
|
-
unitId
|
|
53
|
-
unitType: 'visitor',
|
|
61
|
+
unitId,
|
|
62
|
+
unitType: visitorId ? 'visitor' : 'user',
|
|
54
63
|
userId,
|
|
55
64
|
ts,
|
|
56
65
|
dimensions: null,
|
|
57
|
-
attributes:
|
|
66
|
+
attributes: {
|
|
67
|
+
...click ? undefined : attributes(event.attributes, options.attributeKeys),
|
|
68
|
+
...telemetry
|
|
69
|
+
},
|
|
58
70
|
// §5.5: scoped by unit and event so one client can never pre-claim another's key.
|
|
59
|
-
dedupeKey: `conversion:c:${visitorId}:${event.eventName}:${event.idempotencyKey}`
|
|
71
|
+
dedupeKey: visitorId ? `conversion:c:${visitorId}:${event.eventName}:${event.idempotencyKey}` : USER_BROWSER_CONVERSION_PREFIX + JSON.stringify([
|
|
72
|
+
unitId,
|
|
73
|
+
event.eventName,
|
|
74
|
+
event.idempotencyKey
|
|
75
|
+
])
|
|
60
76
|
};
|
|
61
77
|
} else continue;
|
|
62
78
|
rows.set(row.dedupeKey, row);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MetricSource, ResolvedOptions } from '../types/contracts.js';
|
|
2
|
+
type Sources = Pick<ResolvedOptions, 'eventSources'> & {
|
|
3
|
+
metricSources?: ReadonlyArray<Pick<MetricSource, 'id' | 'kind' | 'clientWritable'>>;
|
|
4
|
+
};
|
|
5
|
+
/** Checks source configuration. Ingestion separately checks that the click key exists. */
|
|
6
|
+
export declare function browserWritableEvent(eventName: string, options: Sources): boolean;
|
|
7
|
+
/** Built-in event metrics use the event name after the `events:` prefix. */
|
|
8
|
+
export declare function browserWritableMetric(source: string | undefined, options: Sources): boolean;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { validClickSource } from '../goals/key.js';
|
|
2
|
+
/** Checks source configuration. Ingestion separately checks that the click key exists. */ export function browserWritableEvent(eventName, options) {
|
|
3
|
+
if (eventName.startsWith('click:')) return validClickSource(eventName);
|
|
4
|
+
const metric = options.metricSources?.find((source)=>source.id === eventName);
|
|
5
|
+
if (metric) return metric.clientWritable === true && metric.kind !== 'revenue';
|
|
6
|
+
return options.eventSources?.some((source)=>source.name === eventName && source.clientWritable) ?? false;
|
|
7
|
+
}
|
|
8
|
+
/** Built-in event metrics use the event name after the `events:` prefix. */ export function browserWritableMetric(source, options) {
|
|
9
|
+
if (!source) return false;
|
|
10
|
+
if (!source.startsWith('events:')) return browserWritableEvent(source, options);
|
|
11
|
+
const eventName = source.slice(7);
|
|
12
|
+
return options.eventSources?.some((event)=>event.name === eventName) === true && browserWritableEvent(eventName, options);
|
|
13
|
+
}
|
|
@@ -3,7 +3,7 @@ export { LayerUsage } from '../admin/LayerUsage.js';
|
|
|
3
3
|
export { MetricSourceSelect } from '../admin/MetricSourceSelect.js';
|
|
4
4
|
export { ArmSelectField } from '../admin/armSelect/ArmSelectField.js';
|
|
5
5
|
export { TestsNavLink } from '../admin/TestsNavLink.js';
|
|
6
|
-
export { TestsSurface } from '../admin/
|
|
6
|
+
export { TestsSurface } from '../admin/views/TestsSurfaceClient.js';
|
|
7
7
|
export { TestsDashboardCards } from '../admin/TestsDashboardCards.js';
|
|
8
8
|
export { PlacementStatus } from '../admin/PlacementStatus.js';
|
|
9
9
|
export { wrapExperimentBlock, syncExperimentSlots, copyOriginalIntoVersion, unwrapExperimentBlock, findRegisteredBlocksField } from '../blocks/formState.js';
|
|
@@ -4,7 +4,7 @@ export { LayerUsage } from '../admin/LayerUsage.js';
|
|
|
4
4
|
export { MetricSourceSelect } from '../admin/MetricSourceSelect.js';
|
|
5
5
|
export { ArmSelectField } from '../admin/armSelect/ArmSelectField.js';
|
|
6
6
|
export { TestsNavLink } from '../admin/TestsNavLink.js';
|
|
7
|
-
export { TestsSurface } from '../admin/
|
|
7
|
+
export { TestsSurface } from '../admin/views/TestsSurfaceClient.js';
|
|
8
8
|
export { TestsDashboardCards } from '../admin/TestsDashboardCards.js';
|
|
9
9
|
export { PlacementStatus } from '../admin/PlacementStatus.js';
|
|
10
10
|
export { wrapExperimentBlock, syncExperimentSlots, copyOriginalIntoVersion, unwrapExperimentBlock, findRegisteredBlocksField } from '../blocks/formState.js';
|
|
@@ -2,3 +2,6 @@ export { ExperimentsRootView } from '../admin/views/ExperimentsRootView.js';
|
|
|
2
2
|
export { CollectionListRedirect } from '../admin/views/CollectionListRedirect.js';
|
|
3
3
|
export { CollectionEditRedirect } from '../admin/views/CollectionEditRedirect.js';
|
|
4
4
|
export { TestsNavLinkServer } from '../admin/views/TestsNavLinkServer.js';
|
|
5
|
+
export { TestsCollectionListView } from '../admin/views/TestsCollectionListView.js';
|
|
6
|
+
export { GoalsCollectionListView } from '../admin/views/GoalsCollectionListView.js';
|
|
7
|
+
export { GoalEditRedirect } from '../admin/views/GoalEditRedirect.js';
|
package/dist/exports/adminRsc.js
CHANGED
|
@@ -2,3 +2,6 @@ export { ExperimentsRootView } from '../admin/views/ExperimentsRootView.js';
|
|
|
2
2
|
export { CollectionListRedirect } from '../admin/views/CollectionListRedirect.js';
|
|
3
3
|
export { CollectionEditRedirect } from '../admin/views/CollectionEditRedirect.js';
|
|
4
4
|
export { TestsNavLinkServer } from '../admin/views/TestsNavLinkServer.js';
|
|
5
|
+
export { TestsCollectionListView } from '../admin/views/TestsCollectionListView.js';
|
|
6
|
+
export { GoalsCollectionListView } from '../admin/views/GoalsCollectionListView.js';
|
|
7
|
+
export { GoalEditRedirect } from '../admin/views/GoalEditRedirect.js';
|
package/dist/exports/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { createExperimentsPlugin } from '../plugin.js';
|
|
|
2
2
|
export { defineFlagPoint, defineMetricSource } from '../define.js';
|
|
3
3
|
export { contentDone } from '../contentDone.js';
|
|
4
4
|
export { createArmSelectField } from '../fields/armSelect.js';
|
|
5
|
-
export type { SerializedFlagPoint, SerializedMetricSource, SerializedAttributeKeys, EditableField, Assignment, Assignments, FlagPointResult, ClientAssignments, RenderedExposure, DocId, PreviewPlacement, Attributes, ExposurePolicy, ExperimentKind, Status, UnitType, ArmKey, ArmKind, TargetingRule, Arm, ParamField, MetricSource, FlagPoint, RateLimiter, ExperimentsAccess, ExperimentsPluginOptions, ExperimentsPageCollection, ArmIssueCode, RefusalCode, ReadinessCode, ErrorEnvelope, TransitionSuccess, AllocateBody, AddMetricBody, AddMetricWarning, AddMetricResult, ClickKeysResult, DecideBody, ArchiveBody, MakeContentResult, DismissContentEntryBody, DismissContentEntryResult, RestoreContentEntryBody, RestoreContentEntryResult, ContentReport, PreflightResult, PreviewTokenResult, PhaseSummary, ResultsResponse, SummaryResponse, EventBody, FlagDefault, Manifest, ManifestExperiment, ArmSlot, ExperimentRef, ExperimentSlotProps, ExperimentsProxyRuntimeOptions, ExperimentsProxyRuntime, ExperimentsServerRuntimeOptions, ExperimentsServerRuntime, VerdictCode, Snapshot, MetricUnavailableReason, ContentReportReason, } from '../types/index.js';
|
|
5
|
+
export type { SerializedFlagPoint, SerializedMetricSource, SerializedAttributeKeys, EditableField, Assignment, Assignments, FlagPointResult, ClientAssignments, RenderedExposure, DocId, PreviewPlacement, Attributes, ExposurePolicy, ExperimentKind, Status, UnitType, ArmKey, ArmKind, TargetingRule, Arm, ParamField, MetricSource, FlagPoint, RateLimiter, ExperimentsAccess, ExperimentsPluginOptions, ExperimentsPageCollection, ArmIssueCode, RefusalCode, ReadinessCode, ErrorEnvelope, TransitionSuccess, StartExperimentFirstStartDetail, StartExperimentResult, StartExperimentWarning, AllocateBody, AddMetricBody, AddMetricWarning, AddMetricResult, ClickKeysResult, PageRow, PagesResult, CopyPagePlan, CopyPageResult, PlacementStatusResult, PageTestStatus, DeleteImpactResult, RoundBody, DecideBody, ArchiveBody, MakeContentResult, DismissContentEntryBody, DismissContentEntryResult, RestoreContentEntryBody, RestoreContentEntryResult, ContentReport, PreflightResult, PreviewTokenResult, PhaseSummary, ResultsResponse, SummaryResponse, EventBody, FlagDefault, Manifest, ManifestExperiment, ArmSlot, ExperimentRef, ExperimentSlotProps, ExperimentsProxyRuntimeOptions, ExperimentsProxyRuntime, ExperimentsServerRuntimeOptions, ExperimentsServerRuntime, VerdictCode, Snapshot, MetricUnavailableReason, ContentReportReason, } from '../types/index.js';
|
|
6
6
|
export { createExperimentBlock } from '../blocks/createExperimentBlock.js';
|
|
7
7
|
export { EXPERIMENT_BLOCK_SLUG } from '../blocks/model.js';
|
|
8
8
|
export type { HostBlock, ExperimentBlock, ExperimentBlockGroup, ResolvedHostBlock, ResolvedExperimentBlocks } from '../blocks/model.js';
|
package/dist/exports/rsc.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { eraseUser } from '../server/eraseUser.js';
|
|
|
8
8
|
export type { MetricUnavailableReason, ContentReportReason } from '../types/reasons.js';
|
|
9
9
|
export type { PreviewPlacement } from '../types/contracts.js';
|
|
10
10
|
export { runResults } from '../server/runResults.js';
|
|
11
|
+
export { startExperiment } from '../server/startExperiment.js';
|
|
11
12
|
export { recordContentChange } from '../server/recordContentChange.js';
|
|
12
13
|
export { experimentSitemapFilter } from '../server/sitemap.js';
|
|
13
14
|
export { experimentMetadata } from '../server/metadata.js';
|
package/dist/exports/rsc.js
CHANGED
|
@@ -6,6 +6,7 @@ export { linkIdentity } from '../server/linkIdentity.js';
|
|
|
6
6
|
export { trackConversion } from '../server/trackConversion.js';
|
|
7
7
|
export { eraseUser } from '../server/eraseUser.js';
|
|
8
8
|
export { runResults } from '../server/runResults.js';
|
|
9
|
+
export { startExperiment } from '../server/startExperiment.js';
|
|
9
10
|
export { recordContentChange } from '../server/recordContentChange.js';
|
|
10
11
|
export { experimentSitemapFilter } from '../server/sitemap.js';
|
|
11
12
|
export { experimentMetadata } from '../server/metadata.js';
|
package/dist/fields/xpGoal.js
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
import { XP_GOAL_FIELD } from '../admin/paths.js';
|
|
2
|
-
import {
|
|
3
|
-
import { pooledExecutor } from '../db/executor.js';
|
|
4
|
-
import { clickKeys } from '../goals/cache.js';
|
|
5
|
-
import { CLICK_KEY } from '../goals/key.js';
|
|
2
|
+
import { validateClickGoal } from '../goals/validate.js';
|
|
6
3
|
/** The host renders this value as data-xp-goal on its interactive element. */ export function xpGoalField() {
|
|
7
4
|
return {
|
|
8
5
|
name: 'xpGoal',
|
|
9
6
|
label: 'Click goal',
|
|
10
7
|
type: 'text',
|
|
11
8
|
admin: {
|
|
12
|
-
description: 'Choose the
|
|
9
|
+
description: 'Choose the click goal to count here.',
|
|
13
10
|
components: {
|
|
14
11
|
Field: XP_GOAL_FIELD
|
|
15
12
|
}
|
|
16
13
|
},
|
|
17
|
-
validate:
|
|
18
|
-
if (!value) return true;
|
|
19
|
-
if (!CLICK_KEY.test(value)) return 'Use a click goal short name.';
|
|
20
|
-
const options = req.payload.config.custom?.xp;
|
|
21
|
-
if (!options || await options.access.manage({
|
|
22
|
-
req
|
|
23
|
-
}) !== true) return true;
|
|
24
|
-
const keys = await clickKeys(req.payload);
|
|
25
|
-
return !keys || keys.has(value) || (await definedClickKeys(pooledExecutor(req.payload))).has(value) || 'No click goal has this name yet. Create it with "+ New click goal".';
|
|
26
|
-
}
|
|
14
|
+
validate: (value, { req })=>validateClickGoal(value, req)
|
|
27
15
|
};
|
|
28
16
|
}
|
package/dist/goals/fairness.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PayloadRequest } from 'payload';
|
|
2
2
|
import type { Arm, DocId, ResolvedOptions } from '../types/contracts.js';
|
|
3
3
|
import type { PlacementDoc } from '../db/placements.js';
|
|
4
|
-
export declare const OUTSIDE_GOAL
|
|
4
|
+
export declare const OUTSIDE_GOAL: (name?: string, kind?: string) => string;
|
|
5
5
|
export declare const LEGACY_FAIRNESS = "Goal fairness isn't checked for tests started before this update.";
|
|
6
6
|
export interface GoalPlacement {
|
|
7
7
|
collection?: string;
|
package/dist/goals/fairness.js
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
|
+
import { placementReader } from '../blocks/placementLocale.js';
|
|
2
|
+
import { puckExperimentSlug } from '../puck/experimentSlug.js';
|
|
3
|
+
import { puckVisibility } from '../puck/visibility.js';
|
|
1
4
|
import { clickGoalContent } from '../db/clickGoals.js';
|
|
2
5
|
import { safeError } from '../log.js';
|
|
3
|
-
import {
|
|
6
|
+
import { puckCollections } from '../options.js';
|
|
4
7
|
import { EXPERIMENT_BLOCK_SLUG, hostBlocks, isObject, slotBlocks } from '../blocks/model.js';
|
|
5
8
|
import { resolvePageCollection } from '../transitions/pageCollection.js';
|
|
6
9
|
import { scanPlacements, uniquePlacementDocs } from '../transitions/placementInteractions.js';
|
|
7
10
|
import { CLICK_KEY } from './key.js';
|
|
8
|
-
export const OUTSIDE_GOAL =
|
|
11
|
+
export const OUTSIDE_GOAL = (name = 'Selected goal', kind = 'block')=>kind === 'block' ? `Heads up: the click goal “${name}” is outside this test's block, so every version shows the same button. The test can still start. To compare different buttons, move the goal inside each version.` : `Heads up: the click goal “${name}” isn't on any of this test's pages. The test can still start. Add the goal to every version's page to measure those clicks.`;
|
|
9
12
|
export const LEGACY_FAIRNESS = "Goal fairness isn't checked for tests started before this update.";
|
|
10
|
-
/** Inspect inline JSON only; depth-zero relationship ids never dereference another document. */ function collect(value, into, label = '', labels) {
|
|
13
|
+
/** Inspect inline JSON only; depth-zero relationship ids never dereference another document. */ function collect(value, into, label = '', labels, visibility) {
|
|
11
14
|
if (Array.isArray(value)) {
|
|
12
|
-
value.forEach((item)=>collect(item, into, label, labels));
|
|
15
|
+
value.forEach((item)=>collect(item, into, label, labels, visibility));
|
|
13
16
|
return;
|
|
14
17
|
}
|
|
15
|
-
if (!isObject(value)) return;
|
|
18
|
+
if (!isObject(value) || visibility?.get(value)?.hidden) return;
|
|
16
19
|
const blockType = typeof value.blockType === 'string' ? value.blockType : typeof value.type === 'string' ? value.type : '';
|
|
17
20
|
const containing = labels.get(blockType) ?? (blockType || label);
|
|
18
21
|
if (typeof value.xpGoal === 'string' && CLICK_KEY.test(value.xpGoal)) into.set(value.xpGoal, containing || value.xpGoal);
|
|
19
|
-
Object.values(value).forEach((item)=>collect(item, into, containing, labels));
|
|
22
|
+
Object.values(value).forEach((item)=>collect(item, into, containing, labels, visibility));
|
|
20
23
|
}
|
|
21
24
|
function blockLabels(req) {
|
|
22
25
|
const labels = new Map();
|
|
@@ -91,7 +94,8 @@ function blockLabels(req) {
|
|
|
91
94
|
unchecked.push(placement);
|
|
92
95
|
continue;
|
|
93
96
|
}
|
|
94
|
-
|
|
97
|
+
const reader = placementReader(req, collection.slug, options);
|
|
98
|
+
for (const view of reader.documentViews)collect(collection.contentOf(reader.read(doc, 'all-locales', view).doc), byArm.get(arm.key), '', labels);
|
|
95
99
|
readArms.add(arm.key);
|
|
96
100
|
} catch (error) {
|
|
97
101
|
failed(error, placement);
|
|
@@ -119,36 +123,41 @@ function blockLabels(req) {
|
|
|
119
123
|
}
|
|
120
124
|
for (const placement of docs){
|
|
121
125
|
try {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
if (!
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const walk = (value)=>{
|
|
136
|
-
if (Array.isArray(value)) {
|
|
137
|
-
value.forEach(walk);
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
if (!isObject(value)) return;
|
|
141
|
-
const props = isObject(value.props) ? value.props : undefined;
|
|
142
|
-
const ref = props?.experiment;
|
|
143
|
-
if (value.type === 'ExperimentSlot' && props && (typeof ref === 'string' ? ref : isObject(ref) ? ref.slug : undefined) === experiment.slug) {
|
|
144
|
-
for (const arm of experiment.arms.filter((a)=>a.kind !== 'holdout'))collect(props[arm.slot ?? arm.key], byArm.get(arm.key), '', labels);
|
|
145
|
-
return;
|
|
126
|
+
const raw = await clickGoalContent(req, placement.collection, placement.id);
|
|
127
|
+
const reader = placementReader(req, placement.collection, options);
|
|
128
|
+
for (const view of reader.views){
|
|
129
|
+
const localized = reader.read(raw, 'all-locales', view);
|
|
130
|
+
const doc = localized.doc;
|
|
131
|
+
if (!doc) continue;
|
|
132
|
+
const editor = localized.editor;
|
|
133
|
+
if (editor === 'blocks') {
|
|
134
|
+
const registration = options.blocks?.collections.find((c)=>c.slug === placement.collection);
|
|
135
|
+
if (!registration) continue;
|
|
136
|
+
for (const block of hostBlocks(doc[registration.field])){
|
|
137
|
+
if (block.blockType !== (registration.blockSlug ?? EXPERIMENT_BLOCK_SLUG) || block.experiment !== experiment.slug) continue;
|
|
138
|
+
for (const arm of experiment.arms.filter((a)=>a.kind !== 'holdout'))collect(slotBlocks(block, arm.key), byArm.get(arm.key), '', labels);
|
|
146
139
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
140
|
+
} else {
|
|
141
|
+
const registration = puckCollections(options).find((c)=>c.slug === placement.collection);
|
|
142
|
+
if (!registration) continue;
|
|
143
|
+
const visibility = puckVisibility(doc[registration.field]);
|
|
144
|
+
const walk = (value)=>{
|
|
145
|
+
if (Array.isArray(value)) {
|
|
146
|
+
value.forEach(walk);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (!isObject(value) || visibility.get(value)?.hidden) return;
|
|
150
|
+
const props = isObject(value.props) ? value.props : undefined;
|
|
151
|
+
if (value.type === 'ExperimentSlot' && props && puckExperimentSlug(props.experiment) === experiment.slug) {
|
|
152
|
+
for (const arm of experiment.arms.filter((a)=>a.kind !== 'holdout'))collect(props[arm.key], byArm.get(arm.key), '', labels, visibility);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
Object.values(value).forEach(walk);
|
|
156
|
+
};
|
|
157
|
+
walk(doc[registration.field]);
|
|
158
|
+
}
|
|
159
|
+
for (const arm of byArm.keys())readArms.add(arm);
|
|
150
160
|
}
|
|
151
|
-
for (const arm of byArm.keys())readArms.add(arm);
|
|
152
161
|
} catch (error) {
|
|
153
162
|
failed(error, placement);
|
|
154
163
|
}
|
|
@@ -8,7 +8,14 @@ export type PickerStatus = 'loading' | 'ready' | 'not-manager' | 'error';
|
|
|
8
8
|
export declare function goalSlug(name: string): string;
|
|
9
9
|
export declare function clickGoalSlug(name: string): string;
|
|
10
10
|
export declare function definedClickGoals(rows: readonly ClickGoal[]): ClickGoal[];
|
|
11
|
-
|
|
11
|
+
/** Keep legacy values visible without changing stored data during a read. */
|
|
12
|
+
export declare function clickGoalOptions(status: PickerStatus, goals: readonly ClickGoal[], value: string): {
|
|
13
|
+
options: {
|
|
14
|
+
value: string;
|
|
15
|
+
label: string;
|
|
16
|
+
}[];
|
|
17
|
+
missing: boolean;
|
|
18
|
+
};
|
|
12
19
|
export declare function clickGoalBody(name: string, slug: string): {
|
|
13
20
|
name: string;
|
|
14
21
|
slug: string;
|
|
@@ -9,8 +9,26 @@ export function clickGoalSlug(name) {
|
|
|
9
9
|
export function definedClickGoals(rows) {
|
|
10
10
|
return rows.filter((row)=>isClickSource(row.source));
|
|
11
11
|
}
|
|
12
|
-
export function
|
|
13
|
-
|
|
12
|
+
/** Keep legacy values visible without changing stored data during a read. */ export function clickGoalOptions(status, goals, value) {
|
|
13
|
+
const missing = status === 'ready' && Boolean(value) && !goals.some((goal)=>goal.slug === value);
|
|
14
|
+
const options = [
|
|
15
|
+
{
|
|
16
|
+
value: '',
|
|
17
|
+
label: C.none
|
|
18
|
+
},
|
|
19
|
+
...goals.map((goal)=>({
|
|
20
|
+
value: goal.slug,
|
|
21
|
+
label: goal.name
|
|
22
|
+
}))
|
|
23
|
+
];
|
|
24
|
+
if (value && !goals.some((goal)=>goal.slug === value)) options.push({
|
|
25
|
+
value,
|
|
26
|
+
label: missing ? `${value} (missing)` : value
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
options,
|
|
30
|
+
missing
|
|
31
|
+
};
|
|
14
32
|
}
|
|
15
33
|
export function clickGoalBody(name, slug) {
|
|
16
34
|
return {
|