@delmaredigital/payload-experiments 0.0.0-stage → 0.1.0-rc.6
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/LICENSE +21 -0
- package/README.md +590 -2
- package/dist/access.d.ts +1 -0
- package/dist/access.js +2 -0
- package/dist/admin/AllocationField.d.ts +2 -0
- package/dist/admin/AllocationField.js +80 -0
- package/dist/admin/FlagPointSelect.d.ts +2 -0
- package/dist/admin/FlagPointSelect.js +54 -0
- package/dist/admin/LayerUsage.d.ts +2 -0
- package/dist/admin/LayerUsage.js +24 -0
- package/dist/admin/LockedFieldNotice.d.ts +2 -0
- package/dist/admin/LockedFieldNotice.js +26 -0
- package/dist/admin/MetricSourceSelect.d.ts +2 -0
- package/dist/admin/MetricSourceSelect.js +32 -0
- package/dist/admin/PhaseHistory.d.ts +2 -0
- package/dist/admin/PhaseHistory.js +76 -0
- package/dist/admin/PreviewLinks.d.ts +11 -0
- package/dist/admin/PreviewLinks.js +69 -0
- package/dist/admin/StatusCell.d.ts +3 -0
- package/dist/admin/StatusCell.js +19 -0
- package/dist/admin/SummaryCell.d.ts +2 -0
- package/dist/admin/SummaryCell.js +32 -0
- package/dist/admin/actions/AddMetricDialog.d.ts +6 -0
- package/dist/admin/actions/AddMetricDialog.js +138 -0
- package/dist/admin/actions/AllocateDialog.d.ts +6 -0
- package/dist/admin/actions/AllocateDialog.js +81 -0
- package/dist/admin/actions/ConfirmDialog.d.ts +14 -0
- package/dist/admin/actions/ConfirmDialog.js +192 -0
- package/dist/admin/actions/DecideDialog.d.ts +7 -0
- package/dist/admin/actions/DecideDialog.js +173 -0
- package/dist/admin/actions/ExperimentActions.d.ts +3 -0
- package/dist/admin/actions/ExperimentActions.js +110 -0
- package/dist/admin/actions/MakeContentResult.d.ts +6 -0
- package/dist/admin/actions/MakeContentResult.js +50 -0
- package/dist/admin/actions/actions.model.d.ts +37 -0
- package/dist/admin/actions/actions.model.js +71 -0
- package/dist/admin/actions/decide.model.d.ts +21 -0
- package/dist/admin/actions/decide.model.js +38 -0
- package/dist/admin/allocation.model.d.ts +20 -0
- package/dist/admin/allocation.model.js +38 -0
- package/dist/admin/api.d.ts +32 -0
- package/dist/admin/api.js +95 -0
- package/dist/admin/armSelect/ArmSelectField.d.ts +2 -0
- package/dist/admin/armSelect/ArmSelectField.js +185 -0
- package/dist/admin/armSelect/armSelect.model.d.ts +30 -0
- package/dist/admin/armSelect/armSelect.model.js +20 -0
- package/dist/admin/arms/ArmsField.d.ts +2 -0
- package/dist/admin/arms/ArmsField.js +310 -0
- package/dist/admin/arms/ParamsEditor.d.ts +16 -0
- package/dist/admin/arms/ParamsEditor.js +79 -0
- package/dist/admin/arms/arms.model.d.ts +21 -0
- package/dist/admin/arms/arms.model.js +153 -0
- package/dist/admin/arms/pageTarget.model.d.ts +4 -0
- package/dist/admin/arms/pageTarget.model.js +19 -0
- package/dist/admin/arms/params.model.d.ts +7 -0
- package/dist/admin/arms/params.model.js +35 -0
- package/dist/admin/copy/actions.d.ts +38 -0
- package/dist/admin/copy/actions.js +38 -0
- package/dist/admin/copy/armSelect.d.ts +11 -0
- package/dist/admin/copy/armSelect.js +11 -0
- package/dist/admin/copy/arms.d.ts +37 -0
- package/dist/admin/copy/arms.js +47 -0
- package/dist/admin/copy/common.d.ts +20 -0
- package/dist/admin/copy/common.js +27 -0
- package/dist/admin/copy/history.d.ts +9 -0
- package/dist/admin/copy/history.js +9 -0
- package/dist/admin/copy/metrics.d.ts +9 -0
- package/dist/admin/copy/metrics.js +9 -0
- package/dist/admin/copy/results.d.ts +78 -0
- package/dist/admin/copy/results.js +81 -0
- package/dist/admin/copy/review.d.ts +33 -0
- package/dist/admin/copy/review.js +127 -0
- package/dist/admin/copy/status.d.ts +8 -0
- package/dist/admin/copy/status.js +8 -0
- package/dist/admin/copy/tabs.d.ts +7 -0
- package/dist/admin/copy/tabs.js +7 -0
- package/dist/admin/copy/who.d.ts +36 -0
- package/dist/admin/copy/who.js +36 -0
- package/dist/admin/labels.d.ts +45 -0
- package/dist/admin/labels.js +53 -0
- package/dist/admin/layerUsage.model.d.ts +15 -0
- package/dist/admin/layerUsage.model.js +18 -0
- package/dist/admin/lockedNotice.model.d.ts +3 -0
- package/dist/admin/lockedNotice.model.js +18 -0
- package/dist/admin/metricSource.model.d.ts +7 -0
- package/dist/admin/metricSource.model.js +11 -0
- package/dist/admin/paths.d.ts +16 -0
- package/dist/admin/paths.js +16 -0
- package/dist/admin/permissions.model.d.ts +10 -0
- package/dist/admin/permissions.model.js +4 -0
- package/dist/admin/phaseHistory.model.d.ts +19 -0
- package/dist/admin/phaseHistory.model.js +19 -0
- package/dist/admin/reload.d.ts +1 -0
- package/dist/admin/reload.js +1 -0
- package/dist/admin/results/ArmTable.d.ts +8 -0
- package/dist/admin/results/ArmTable.js +112 -0
- package/dist/admin/results/CappedCell.d.ts +4 -0
- package/dist/admin/results/CappedCell.js +24 -0
- package/dist/admin/results/CiChart.d.ts +10 -0
- package/dist/admin/results/CiChart.js +178 -0
- package/dist/admin/results/DataQualityPanel.d.ts +4 -0
- package/dist/admin/results/DataQualityPanel.js +40 -0
- package/dist/admin/results/ResultsView.d.ts +3 -0
- package/dist/admin/results/ResultsView.js +312 -0
- package/dist/admin/results/VerdictCard.d.ts +9 -0
- package/dist/admin/results/VerdictCard.js +49 -0
- package/dist/admin/results/chart.model.d.ts +32 -0
- package/dist/admin/results/chart.model.js +52 -0
- package/dist/admin/results/format.d.ts +10 -0
- package/dist/admin/results/format.js +55 -0
- package/dist/admin/results/results.model.d.ts +105 -0
- package/dist/admin/results/results.model.js +175 -0
- package/dist/admin/review/ReviewPanel.d.ts +2 -0
- package/dist/admin/review/ReviewPanel.js +268 -0
- package/dist/admin/review/review.model.d.ts +31 -0
- package/dist/admin/review/review.model.js +40 -0
- package/dist/admin/status.model.d.ts +16 -0
- package/dist/admin/status.model.js +17 -0
- package/dist/admin/styles.css +10 -0
- package/dist/admin/styles.d.ts +1 -0
- package/dist/admin/styles.js +2 -0
- package/dist/admin/summaryBatcher.d.ts +8 -0
- package/dist/admin/summaryBatcher.js +33 -0
- package/dist/admin/targeting/TargetingAttributeField.d.ts +2 -0
- package/dist/admin/targeting/TargetingAttributeField.js +31 -0
- package/dist/admin/targeting/TargetingOpField.d.ts +2 -0
- package/dist/admin/targeting/TargetingOpField.js +45 -0
- package/dist/admin/targeting/TargetingValueField.d.ts +2 -0
- package/dist/admin/targeting/TargetingValueField.js +142 -0
- package/dist/admin/targeting/targeting.model.d.ts +18 -0
- package/dist/admin/targeting/targeting.model.js +48 -0
- package/dist/admin/useApi.d.ts +20 -0
- package/dist/admin/useApi.js +10 -0
- package/dist/admin/useLayerUsage.d.ts +15 -0
- package/dist/admin/useLayerUsage.js +92 -0
- package/dist/client/ExperimentPageview.d.ts +1 -0
- package/dist/client/ExperimentPageview.js +27 -0
- package/dist/client/ExperimentsProvider.d.ts +6 -0
- package/dist/client/ExperimentsProvider.js +22 -0
- package/dist/client/ViewportExposure.d.ts +9 -0
- package/dist/client/ViewportExposure.js +69 -0
- package/dist/client/beacon.d.ts +17 -0
- package/dist/client/beacon.js +71 -0
- package/dist/client/context.d.ts +2 -0
- package/dist/client/context.js +2 -0
- package/dist/client/idempotency.d.ts +2 -0
- package/dist/client/idempotency.js +13 -0
- package/dist/client/trackConversionBeacon.d.ts +3 -0
- package/dist/client/trackConversionBeacon.js +16 -0
- package/dist/client/useExperiment.d.ts +5 -0
- package/dist/client/useExperiment.js +27 -0
- package/dist/client/useFlagPoint.d.ts +9 -0
- package/dist/client/useFlagPoint.js +32 -0
- package/dist/collections/access.d.ts +21 -0
- package/dist/collections/access.js +25 -0
- package/dist/collections/events.d.ts +3 -0
- package/dist/collections/events.js +117 -0
- package/dist/collections/experiments/armInvariants.d.ts +12 -0
- package/dist/collections/experiments/armInvariants.js +89 -0
- package/dist/collections/experiments/config.d.ts +3 -0
- package/dist/collections/experiments/config.js +574 -0
- package/dist/collections/experiments/createDefaults.d.ts +2 -0
- package/dist/collections/experiments/createDefaults.js +7 -0
- package/dist/collections/experiments/deleteGuard.d.ts +3 -0
- package/dist/collections/experiments/deleteGuard.js +8 -0
- package/dist/collections/experiments/editability.d.ts +4 -0
- package/dist/collections/experiments/editability.js +35 -0
- package/dist/collections/experiments/flagControlParams.d.ts +2 -0
- package/dist/collections/experiments/flagControlParams.js +32 -0
- package/dist/collections/experiments/lockHook.d.ts +2 -0
- package/dist/collections/experiments/lockHook.js +134 -0
- package/dist/collections/identities.d.ts +3 -0
- package/dist/collections/identities.js +30 -0
- package/dist/collections/index.d.ts +6 -0
- package/dist/collections/index.js +24 -0
- package/dist/collections/layers.d.ts +3 -0
- package/dist/collections/layers.js +77 -0
- package/dist/collections/metrics.d.ts +3 -0
- package/dist/collections/metrics.js +115 -0
- package/dist/collections/phases.d.ts +3 -0
- package/dist/collections/phases.js +59 -0
- package/dist/collections/serialize.d.ts +5 -0
- package/dist/collections/serialize.js +40 -0
- package/dist/collections/snapshots.d.ts +3 -0
- package/dist/collections/snapshots.js +47 -0
- package/dist/constants.d.ts +7 -0
- package/dist/constants.js +7 -0
- package/dist/db/adapter.d.ts +3 -0
- package/dist/db/adapter.js +9 -0
- package/dist/db/appends.d.ts +58 -0
- package/dist/db/appends.js +116 -0
- package/dist/db/delete.d.ts +17 -0
- package/dist/db/delete.js +35 -0
- package/dist/db/erase.d.ts +12 -0
- package/dist/db/erase.js +55 -0
- package/dist/db/events.d.ts +21 -0
- package/dist/db/events.js +100 -0
- package/dist/db/executor.d.ts +10 -0
- package/dist/db/executor.js +37 -0
- package/dist/db/identities.d.ts +11 -0
- package/dist/db/identities.js +29 -0
- package/dist/db/locks.d.ts +15 -0
- package/dist/db/locks.js +23 -0
- package/dist/db/manifest.d.ts +8 -0
- package/dist/db/manifest.js +8 -0
- package/dist/db/names.d.ts +271 -0
- package/dist/db/names.js +270 -0
- package/dist/db/pgExecutor.d.ts +41 -0
- package/dist/db/pgExecutor.js +250 -0
- package/dist/db/results.d.ts +53 -0
- package/dist/db/results.js +103 -0
- package/dist/db/slices.d.ts +18 -0
- package/dist/db/slices.js +51 -0
- package/dist/db/snapshots.d.ts +47 -0
- package/dist/db/snapshots.js +89 -0
- package/dist/db/sql.d.ts +5 -0
- package/dist/db/sql.js +5 -0
- package/dist/db/state.d.ts +12 -0
- package/dist/db/state.js +27 -0
- package/dist/db/sweep.d.ts +13 -0
- package/dist/db/sweep.js +90 -0
- package/dist/db/txid.d.ts +7 -0
- package/dist/db/txid.js +12 -0
- package/dist/define.d.ts +3 -0
- package/dist/define.js +6 -0
- package/dist/endpoints/events.d.ts +7 -0
- package/dist/endpoints/events.js +98 -0
- package/dist/endpoints/index.d.ts +18 -0
- package/dist/endpoints/index.js +160 -0
- package/dist/endpoints/manifest.d.ts +7 -0
- package/dist/endpoints/manifest.js +30 -0
- package/dist/endpoints/preflight.d.ts +8 -0
- package/dist/endpoints/preflight.js +25 -0
- package/dist/endpoints/previewToken.d.ts +7 -0
- package/dist/endpoints/previewToken.js +54 -0
- package/dist/endpoints/recompute.d.ts +7 -0
- package/dist/endpoints/recompute.js +41 -0
- package/dist/endpoints/results.d.ts +24 -0
- package/dist/endpoints/results.js +136 -0
- package/dist/endpoints/summary.d.ts +7 -0
- package/dist/endpoints/summary.js +40 -0
- package/dist/endpoints/transitions.d.ts +42 -0
- package/dist/endpoints/transitions.js +154 -0
- package/dist/errors.d.ts +27 -0
- package/dist/errors.js +33 -0
- package/dist/events/body.d.ts +7 -0
- package/dist/events/body.js +43 -0
- package/dist/events/dimensions.d.ts +4 -0
- package/dist/events/dimensions.js +51 -0
- package/dist/events/preview.d.ts +2 -0
- package/dist/events/preview.js +9 -0
- package/dist/events/request.d.ts +3 -0
- package/dist/events/request.js +14 -0
- package/dist/events/rows.d.ts +7 -0
- package/dist/events/rows.js +65 -0
- package/dist/exports/adminClient.d.ts +16 -0
- package/dist/exports/adminClient.js +17 -0
- package/dist/exports/client.d.ts +7 -0
- package/dist/exports/client.js +7 -0
- package/dist/exports/index.d.ts +4 -0
- package/dist/exports/index.js +3 -0
- package/dist/exports/proxy.d.ts +4 -0
- package/dist/exports/proxy.js +3 -0
- package/dist/exports/puck.d.ts +4 -0
- package/dist/exports/puck.js +3 -0
- package/dist/exports/puckEditor.d.ts +1 -0
- package/dist/exports/puckEditor.js +2 -0
- package/dist/exports/rsc.d.ts +13 -0
- package/dist/exports/rsc.js +13 -0
- package/dist/exports/runtimeProxy.d.ts +4 -0
- package/dist/exports/runtimeProxy.js +2 -0
- package/dist/exports/runtimeServer.d.ts +2 -0
- package/dist/exports/runtimeServer.js +1 -0
- package/dist/fields/armSelect.d.ts +7 -0
- package/dist/fields/armSelect.js +33 -0
- package/dist/globals/state.d.ts +3 -0
- package/dist/globals/state.js +31 -0
- package/dist/hooks/contentChanges.d.ts +3 -0
- package/dist/hooks/contentChanges.js +10 -0
- package/dist/hooks/hostHook.d.ts +5 -0
- package/dist/hooks/hostHook.js +20 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -0
- package/dist/manifest/cache.d.ts +10 -0
- package/dist/manifest/cache.js +51 -0
- package/dist/manifest/compile.d.ts +63 -0
- package/dist/manifest/compile.js +237 -0
- package/dist/onInit.d.ts +5 -0
- package/dist/onInit.js +13 -0
- package/dist/options/fromReq.d.ts +3 -0
- package/dist/options/fromReq.js +5 -0
- package/dist/options.d.ts +9 -0
- package/dist/options.js +107 -0
- package/dist/plugin.d.ts +7 -0
- package/dist/plugin.js +62 -0
- package/dist/proxy/apply.d.ts +3 -0
- package/dist/proxy/apply.js +5 -0
- package/dist/proxy/consentFallback.d.ts +5 -0
- package/dist/proxy/consentFallback.js +27 -0
- package/dist/proxy/control.d.ts +6 -0
- package/dist/proxy/control.js +36 -0
- package/dist/proxy/createProxy.d.ts +3 -0
- package/dist/proxy/createProxy.js +15 -0
- package/dist/proxy/pageRewrite.d.ts +4 -0
- package/dist/proxy/pageRewrite.js +41 -0
- package/dist/proxy/resolve.d.ts +13 -0
- package/dist/proxy/resolve.js +163 -0
- package/dist/proxy/skip.d.ts +1 -0
- package/dist/proxy/skip.js +9 -0
- package/dist/puck/ExperimentPicker.d.ts +5 -0
- package/dist/puck/ExperimentPicker.js +88 -0
- package/dist/puck/ExperimentSlot.d.ts +3 -0
- package/dist/puck/ExperimentSlot.js +16 -0
- package/dist/puck/copy.d.ts +14 -0
- package/dist/puck/copy.js +14 -0
- package/dist/puck/editor/CreateExperimentDrawer.d.ts +5 -0
- package/dist/puck/editor/CreateExperimentDrawer.js +120 -0
- package/dist/puck/editor/ExperimentSlotEditor.d.ts +3 -0
- package/dist/puck/editor/ExperimentSlotEditor.js +225 -0
- package/dist/puck/editor/cloneSlot.d.ts +3 -0
- package/dist/puck/editor/cloneSlot.js +41 -0
- package/dist/puck/editor/copy.d.ts +25 -0
- package/dist/puck/editor/copy.js +25 -0
- package/dist/puck/editor/editor.model.d.ts +16 -0
- package/dist/puck/editor/editor.model.js +33 -0
- package/dist/puck/experimentSlotField.d.ts +5 -0
- package/dist/puck/experimentSlotField.js +13 -0
- package/dist/puck/slot.model.d.ts +2 -0
- package/dist/puck/slot.model.js +11 -0
- package/dist/puck/slotConfig.d.ts +5 -0
- package/dist/puck/slotConfig.js +25 -0
- package/dist/results/aggregate.d.ts +34 -0
- package/dist/results/aggregate.js +66 -0
- package/dist/results/analyse.d.ts +79 -0
- package/dist/results/analyse.js +378 -0
- package/dist/results/cuped.d.ts +16 -0
- package/dist/results/cuped.js +31 -0
- package/dist/results/decideGuard.d.ts +3 -0
- package/dist/results/decideGuard.js +8 -0
- package/dist/results/guardrails.d.ts +17 -0
- package/dist/results/guardrails.js +10 -0
- package/dist/results/history.d.ts +13 -0
- package/dist/results/history.js +39 -0
- package/dist/results/identityCredit.d.ts +16 -0
- package/dist/results/identityCredit.js +46 -0
- package/dist/results/power.d.ts +15 -0
- package/dist/results/power.js +60 -0
- package/dist/results/rolloutUnits.d.ts +17 -0
- package/dist/results/rolloutUnits.js +26 -0
- package/dist/results/snapshot.d.ts +9 -0
- package/dist/results/snapshot.js +154 -0
- package/dist/results/srm.d.ts +9 -0
- package/dist/results/srm.js +22 -0
- package/dist/results/verdict.d.ts +82 -0
- package/dist/results/verdict.js +85 -0
- package/dist/runtime/assign.d.ts +23 -0
- package/dist/runtime/assign.js +104 -0
- package/dist/runtime/bot.d.ts +1 -0
- package/dist/runtime/bot.js +7 -0
- package/dist/runtime/cookie.d.ts +17 -0
- package/dist/runtime/cookie.js +35 -0
- package/dist/runtime/eligibility.d.ts +22 -0
- package/dist/runtime/eligibility.js +20 -0
- package/dist/runtime/header.d.ts +17 -0
- package/dist/runtime/header.js +97 -0
- package/dist/runtime/loaders.d.ts +17 -0
- package/dist/runtime/loaders.js +29 -0
- package/dist/runtime/normalisePath.d.ts +7 -0
- package/dist/runtime/normalisePath.js +15 -0
- package/dist/runtime/previewToken.d.ts +9 -0
- package/dist/runtime/previewToken.js +23 -0
- package/dist/runtime/proxyRuntime.d.ts +2 -0
- package/dist/runtime/proxyRuntime.js +22 -0
- package/dist/runtime/seed.d.ts +2 -0
- package/dist/runtime/seed.js +4 -0
- package/dist/runtime/signing.d.ts +3 -0
- package/dist/runtime/signing.js +16 -0
- package/dist/runtime/targeting.d.ts +6 -0
- package/dist/runtime/targeting.js +9 -0
- package/dist/server/context.d.ts +10 -0
- package/dist/server/context.js +59 -0
- package/dist/server/eraseUser.d.ts +7 -0
- package/dist/server/eraseUser.js +4 -0
- package/dist/server/getAssignments.d.ts +9 -0
- package/dist/server/getAssignments.js +227 -0
- package/dist/server/getFlagPoint.d.ts +11 -0
- package/dist/server/getFlagPoint.js +36 -0
- package/dist/server/headerRevision.d.ts +6 -0
- package/dist/server/headerRevision.js +10 -0
- package/dist/server/linkIdentity.d.ts +9 -0
- package/dist/server/linkIdentity.js +34 -0
- package/dist/server/metadata.d.ts +7 -0
- package/dist/server/metadata.js +24 -0
- package/dist/server/previewDraft.d.ts +7 -0
- package/dist/server/previewDraft.js +51 -0
- package/dist/server/recordContentChange.d.ts +7 -0
- package/dist/server/recordContentChange.js +150 -0
- package/dist/server/recordExposures.d.ts +7 -0
- package/dist/server/recordExposures.js +56 -0
- package/dist/server/request.d.ts +7 -0
- package/dist/server/request.js +39 -0
- package/dist/server/resolveExperimentData.d.ts +6 -0
- package/dist/server/resolveExperimentData.js +64 -0
- package/dist/server/runResults.d.ts +22 -0
- package/dist/server/runResults.js +307 -0
- package/dist/server/serverRuntime.d.ts +7 -0
- package/dist/server/serverRuntime.js +20 -0
- package/dist/server/sitemap.d.ts +3 -0
- package/dist/server/sitemap.js +6 -0
- package/dist/server/toClientAssignments.d.ts +7 -0
- package/dist/server/toClientAssignments.js +56 -0
- package/dist/server/trackConversion.d.ts +12 -0
- package/dist/server/trackConversion.js +69 -0
- package/dist/targeting/ops.d.ts +8 -0
- package/dist/targeting/ops.js +58 -0
- package/dist/transitions/addMetric.d.ts +16 -0
- package/dist/transitions/addMetric.js +126 -0
- package/dist/transitions/allocate.d.ts +9 -0
- package/dist/transitions/allocate.js +84 -0
- package/dist/transitions/archive.d.ts +9 -0
- package/dist/transitions/archive.js +46 -0
- package/dist/transitions/checkStart.d.ts +61 -0
- package/dist/transitions/checkStart.js +104 -0
- package/dist/transitions/confirmPhrases.d.ts +5 -0
- package/dist/transitions/confirmPhrases.js +18 -0
- package/dist/transitions/decide.d.ts +9 -0
- package/dist/transitions/decide.js +138 -0
- package/dist/transitions/deleteExperiment.d.ts +5 -0
- package/dist/transitions/deleteExperiment.js +66 -0
- package/dist/transitions/kernel.d.ts +31 -0
- package/dist/transitions/kernel.js +69 -0
- package/dist/transitions/makeContent.d.ts +20 -0
- package/dist/transitions/makeContent.js +411 -0
- package/dist/transitions/phaseRecord.d.ts +27 -0
- package/dist/transitions/phaseRecord.js +81 -0
- package/dist/transitions/placements.d.ts +26 -0
- package/dist/transitions/placements.js +89 -0
- package/dist/transitions/preflightData.d.ts +21 -0
- package/dist/transitions/preflightData.js +317 -0
- package/dist/transitions/releaseHoldout.d.ts +8 -0
- package/dist/transitions/releaseHoldout.js +30 -0
- package/dist/transitions/resolveCaps.d.ts +28 -0
- package/dist/transitions/resolveCaps.js +68 -0
- package/dist/transitions/start.d.ts +26 -0
- package/dist/transitions/start.js +220 -0
- package/dist/transitions/stop.d.ts +8 -0
- package/dist/transitions/stop.js +25 -0
- package/dist/types/admin.d.ts +20 -0
- package/dist/types/admin.js +1 -0
- package/dist/types/assignments.d.ts +57 -0
- package/dist/types/assignments.js +1 -0
- package/dist/types/contracts.d.ts +141 -0
- package/dist/types/contracts.js +1 -0
- package/dist/types/endpoints.d.ts +135 -0
- package/dist/types/endpoints.js +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.js +8 -0
- package/dist/types/manifest.d.ts +42 -0
- package/dist/types/manifest.js +1 -0
- package/dist/types/puck.d.ts +23 -0
- package/dist/types/puck.js +1 -0
- package/dist/types/runtime.d.ts +59 -0
- package/dist/types/runtime.js +1 -0
- package/dist/types/snapshot.d.ts +117 -0
- package/dist/types/snapshot.js +1 -0
- package/package.json +138 -3
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Selects stored primary comparisons and display domains; performs no inference. */ export function chartModel({ series = [], metricId, phase, contentChanges = [] }) {
|
|
2
|
+
const variants = phase.arms.filter((arm)=>arm.kind === 'variant').map((arm)=>({
|
|
3
|
+
arm: arm.key,
|
|
4
|
+
label: arm.label,
|
|
5
|
+
points: series.filter((point)=>point.metricId === metricId && point.arm === arm.key).map((point)=>({
|
|
6
|
+
t: Date.parse(point.computedAt),
|
|
7
|
+
lift: point.lift,
|
|
8
|
+
lo: point.ci[0] !== null && Number.isFinite(point.ci[0]) ? point.ci[0] : null,
|
|
9
|
+
hi: point.ci[1] !== null && Number.isFinite(point.ci[1]) ? point.ci[1] : null
|
|
10
|
+
})).filter((point)=>Number.isFinite(point.t) && Number.isFinite(point.lift)).sort((a, b)=>a.t - b.t)
|
|
11
|
+
})).filter((variant)=>variant.points.length > 0);
|
|
12
|
+
const points = variants.flatMap((variant)=>variant.points);
|
|
13
|
+
if (points.length < 2) return {
|
|
14
|
+
empty: true
|
|
15
|
+
};
|
|
16
|
+
let from = points[0].t, to = from, low = 0, high = 0;
|
|
17
|
+
for (const point of points){
|
|
18
|
+
from = Math.min(from, point.t);
|
|
19
|
+
to = Math.max(to, point.t);
|
|
20
|
+
for (const value of [
|
|
21
|
+
point.lift,
|
|
22
|
+
point.lo,
|
|
23
|
+
point.hi
|
|
24
|
+
])if (value !== null) {
|
|
25
|
+
low = Math.min(low, value);
|
|
26
|
+
high = Math.max(high, value);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (from === to) return {
|
|
30
|
+
empty: true
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
empty: false,
|
|
34
|
+
xDomain: [
|
|
35
|
+
from,
|
|
36
|
+
to
|
|
37
|
+
],
|
|
38
|
+
yDomain: low === high ? [
|
|
39
|
+
-1,
|
|
40
|
+
1
|
|
41
|
+
] : [
|
|
42
|
+
low,
|
|
43
|
+
high
|
|
44
|
+
],
|
|
45
|
+
variants,
|
|
46
|
+
// Opaque editor ids never enter the chart model or its accessible text.
|
|
47
|
+
markers: contentChanges.map(({ at })=>({
|
|
48
|
+
t: Date.parse(at),
|
|
49
|
+
at
|
|
50
|
+
})).filter((marker)=>Number.isFinite(marker.t) && marker.t >= from && marker.t <= to)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MetricSource } from '../../types/contracts.js';
|
|
2
|
+
export declare function formatCount(value: number | null | undefined): string;
|
|
3
|
+
export declare function formatNumber(value: number | null | undefined): string;
|
|
4
|
+
/** Increase precision near zero so a finite, nonzero bound never loses its sign. */
|
|
5
|
+
export declare function formatPercent(value: number | null | undefined, signed?: boolean): string;
|
|
6
|
+
export declare function formatCurrency(value: number | null | undefined, currency?: string): string;
|
|
7
|
+
/** Revenue alone is money; counts and conversion metrics never receive a currency symbol. */
|
|
8
|
+
export declare function formatMetric(value: number | null | undefined, kind: MetricSource['kind'], currency?: string): string;
|
|
9
|
+
export declare function formatProbability(value: number | null | undefined): string;
|
|
10
|
+
export declare function formatCI(ci: readonly [number | null, number | null] | undefined): string;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { atLeast, atMost, intervalCopy } from '../copy/results.js';
|
|
2
|
+
const locale = 'en-US';
|
|
3
|
+
const missing = '—';
|
|
4
|
+
const finite = (value)=>typeof value === 'number' && Number.isFinite(value);
|
|
5
|
+
const minus = (value)=>value.replace(/-/g, '−');
|
|
6
|
+
export function formatCount(value) {
|
|
7
|
+
return finite(value) ? new Intl.NumberFormat(locale, {
|
|
8
|
+
maximumFractionDigits: 0
|
|
9
|
+
}).format(value) : missing;
|
|
10
|
+
}
|
|
11
|
+
export function formatNumber(value) {
|
|
12
|
+
return finite(value) ? minus(new Intl.NumberFormat(locale, {
|
|
13
|
+
maximumFractionDigits: 2
|
|
14
|
+
}).format(value)) : missing;
|
|
15
|
+
}
|
|
16
|
+
/** Increase precision near zero so a finite, nonzero bound never loses its sign. */ export function formatPercent(value, signed = false) {
|
|
17
|
+
if (!finite(value)) return missing;
|
|
18
|
+
const magnitude = Math.abs(value) * 100;
|
|
19
|
+
const digits = magnitude > 0 ? Math.max(1, 1 - Math.floor(Math.log10(magnitude))) : 1;
|
|
20
|
+
const options = digits > 20 ? {
|
|
21
|
+
style: 'percent',
|
|
22
|
+
notation: 'scientific',
|
|
23
|
+
maximumSignificantDigits: 3
|
|
24
|
+
} : {
|
|
25
|
+
style: 'percent',
|
|
26
|
+
minimumFractionDigits: 1,
|
|
27
|
+
maximumFractionDigits: digits
|
|
28
|
+
};
|
|
29
|
+
return minus(new Intl.NumberFormat(locale, {
|
|
30
|
+
...options,
|
|
31
|
+
signDisplay: signed ? 'exceptZero' : 'auto'
|
|
32
|
+
}).format(value));
|
|
33
|
+
}
|
|
34
|
+
export function formatCurrency(value, currency = 'USD') {
|
|
35
|
+
return finite(value) ? minus(new Intl.NumberFormat(locale, {
|
|
36
|
+
style: 'currency',
|
|
37
|
+
currency
|
|
38
|
+
}).format(value)) : missing;
|
|
39
|
+
}
|
|
40
|
+
/** Revenue alone is money; counts and conversion metrics never receive a currency symbol. */ export function formatMetric(value, kind, currency = 'USD') {
|
|
41
|
+
return kind === 'revenue' ? formatCurrency(value, currency) : kind === 'binomial' ? formatPercent(value) : formatNumber(value);
|
|
42
|
+
}
|
|
43
|
+
export function formatProbability(value) {
|
|
44
|
+
return finite(value) ? new Intl.NumberFormat(locale, {
|
|
45
|
+
maximumSignificantDigits: 3
|
|
46
|
+
}).format(value) : missing;
|
|
47
|
+
}
|
|
48
|
+
export function formatCI(ci) {
|
|
49
|
+
if (!ci || ci.some((bound)=>bound !== null && !finite(bound))) return missing;
|
|
50
|
+
const [low, high] = ci;
|
|
51
|
+
if (low === null && high === null) return missing;
|
|
52
|
+
if (high === null) return atLeast(formatPercent(low, true));
|
|
53
|
+
if (low === null) return atMost(formatPercent(high, true));
|
|
54
|
+
return intervalCopy(formatPercent(low, true), formatPercent(high, true));
|
|
55
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { DocId, Status } from '../../types/contracts.js';
|
|
2
|
+
import type { PhaseSummary, ResultsResponse } from '../../types/endpoints.js';
|
|
3
|
+
import type { Snapshot } from '../../types/snapshot.js';
|
|
4
|
+
type Metric = Snapshot['metrics'][number];
|
|
5
|
+
type Arm = Metric['perArm'][number];
|
|
6
|
+
type Decision = {
|
|
7
|
+
phase: number;
|
|
8
|
+
winnerArm?: string;
|
|
9
|
+
};
|
|
10
|
+
type DisplaySnapshot = Snapshot;
|
|
11
|
+
export declare function defaultRound({ phases, decision, status }: Pick<ResultsResponse, 'phases'> & {
|
|
12
|
+
decision?: Decision | null;
|
|
13
|
+
status: Status;
|
|
14
|
+
}): number | null;
|
|
15
|
+
export declare function roundOptions(phases: PhaseSummary[]): {
|
|
16
|
+
value: number;
|
|
17
|
+
label: string;
|
|
18
|
+
}[];
|
|
19
|
+
export type VerdictCardModel = {
|
|
20
|
+
title: string;
|
|
21
|
+
finding: string | null;
|
|
22
|
+
detail: string | null;
|
|
23
|
+
} | {
|
|
24
|
+
headline: string;
|
|
25
|
+
detail: string;
|
|
26
|
+
guardrailLine?: string;
|
|
27
|
+
};
|
|
28
|
+
export declare function verdictCard({ snapshot, decisionSnapshot, isDecidedTestRound, winnerLabel }: {
|
|
29
|
+
snapshot: Snapshot;
|
|
30
|
+
decisionSnapshot?: Snapshot;
|
|
31
|
+
isDecidedTestRound: boolean;
|
|
32
|
+
winnerLabel: string;
|
|
33
|
+
}): VerdictCardModel;
|
|
34
|
+
export declare function rolloutLine(snapshot: DisplaySnapshot, phase: PhaseSummary, phases: PhaseSummary[], decision?: Pick<Decision, 'winnerArm'>): string | null;
|
|
35
|
+
export interface CappedCellModel {
|
|
36
|
+
statistic: string;
|
|
37
|
+
totalLine?: string;
|
|
38
|
+
cappedLine?: string;
|
|
39
|
+
notice?: string;
|
|
40
|
+
}
|
|
41
|
+
export declare function cappedCell({ metric, arm, caps }: {
|
|
42
|
+
metric: Pick<Metric, 'metricId' | 'kind'> & {
|
|
43
|
+
capNotice?: 'no-history';
|
|
44
|
+
};
|
|
45
|
+
arm?: Arm;
|
|
46
|
+
caps?: Snapshot['params']['caps'];
|
|
47
|
+
}): CappedCellModel;
|
|
48
|
+
export type ComparisonModel = {
|
|
49
|
+
method: 'sequential';
|
|
50
|
+
lift: string;
|
|
51
|
+
ci: string;
|
|
52
|
+
adjustedCI?: string;
|
|
53
|
+
pValue: string;
|
|
54
|
+
pValueAdjusted?: string;
|
|
55
|
+
significance: string;
|
|
56
|
+
} | {
|
|
57
|
+
method: 'bayesian';
|
|
58
|
+
chanceToWin: string;
|
|
59
|
+
ci: string;
|
|
60
|
+
risk: string;
|
|
61
|
+
significance: string;
|
|
62
|
+
};
|
|
63
|
+
export interface ArmRow {
|
|
64
|
+
key: string;
|
|
65
|
+
label: string;
|
|
66
|
+
n: string;
|
|
67
|
+
value: string;
|
|
68
|
+
capped: CappedCellModel;
|
|
69
|
+
baseline?: string;
|
|
70
|
+
comparison?: ComparisonModel;
|
|
71
|
+
}
|
|
72
|
+
export declare function armRows({ snapshot, phase, metricId }: {
|
|
73
|
+
snapshot: Snapshot;
|
|
74
|
+
phase: PhaseSummary;
|
|
75
|
+
metricId: DocId;
|
|
76
|
+
}): ArmRow[];
|
|
77
|
+
export declare function guardrailChips(snapshot: Snapshot): {
|
|
78
|
+
name: string;
|
|
79
|
+
status: "Failing" | "OK" | "Watch" | "Too little data";
|
|
80
|
+
}[];
|
|
81
|
+
interface RoundLineInput {
|
|
82
|
+
snapshot: DisplaySnapshot;
|
|
83
|
+
phaseKind: Snapshot['phaseKind'];
|
|
84
|
+
status: Status;
|
|
85
|
+
}
|
|
86
|
+
export declare function powerLine({ snapshot, phaseKind, status }: RoundLineInput): string | null;
|
|
87
|
+
export interface ResultsContext {
|
|
88
|
+
phase?: PhaseSummary;
|
|
89
|
+
minExposuresPerArm?: number;
|
|
90
|
+
inLayer?: boolean;
|
|
91
|
+
layerSlices?: number | readonly number[];
|
|
92
|
+
allocation?: number;
|
|
93
|
+
}
|
|
94
|
+
/** Only selects stored counts; never estimates sample sizes or power in the UI. */
|
|
95
|
+
export declare function collectingLine({ snapshot, phaseKind, status }: RoundLineInput, ctx?: ResultsContext): string | null;
|
|
96
|
+
export interface DataQualityItem {
|
|
97
|
+
id: string;
|
|
98
|
+
message: string;
|
|
99
|
+
detail?: string;
|
|
100
|
+
nextStep: string;
|
|
101
|
+
shares?: string[];
|
|
102
|
+
}
|
|
103
|
+
export declare function dataQuality(snapshot: DisplaySnapshot, ctx?: ResultsContext): DataQualityItem[];
|
|
104
|
+
export declare function verdictLabel(snapshot: Snapshot): string;
|
|
105
|
+
export {};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { armLabel, phaseKindLabel, verdictCodeLabel } from '../labels.js';
|
|
2
|
+
import { RESULTS_COPY, cappedCount, collectingCopy, conflictCopy, decidedTitle, exclusionCopy, ignoredCopy, metricUnavailable, moreDays, roundLabel, shareCopy, shippingTitle, srmP, uncappedTotal } from '../copy/results.js';
|
|
3
|
+
import { formatCI, formatCount, formatMetric, formatPercent, formatProbability } from './format.js';
|
|
4
|
+
export function defaultRound({ phases, decision, status }) {
|
|
5
|
+
if (status === 'decided' && decision) return decision.phase;
|
|
6
|
+
return phases.reduce((latest, phase)=>latest === null || phase.phase > latest ? phase.phase : latest, null);
|
|
7
|
+
}
|
|
8
|
+
export function roundOptions(phases) {
|
|
9
|
+
return phases.map((phase)=>({
|
|
10
|
+
value: phase.phase,
|
|
11
|
+
label: roundLabel(phase.phase, phaseKindLabel(phase.phaseKind))
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
export function verdictCard({ snapshot, decisionSnapshot, isDecidedTestRound, winnerLabel }) {
|
|
15
|
+
if (isDecidedTestRound) return {
|
|
16
|
+
title: decidedTitle(winnerLabel),
|
|
17
|
+
finding: decisionSnapshot?.verdict.finding ?? null,
|
|
18
|
+
detail: decisionSnapshot?.verdict.detail ?? null
|
|
19
|
+
};
|
|
20
|
+
const { headline, detail, guardrailLine } = snapshot.verdict;
|
|
21
|
+
return {
|
|
22
|
+
headline,
|
|
23
|
+
detail,
|
|
24
|
+
...guardrailLine === undefined ? {} : {
|
|
25
|
+
guardrailLine
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function rolloutLine(snapshot, phase, phases, decision) {
|
|
30
|
+
if (snapshot.phaseKind !== 'rollout') return null;
|
|
31
|
+
const newestRollout = phases.filter((phase)=>phase.phaseKind === 'rollout').reduce((latest, phase)=>latest === null || phase.phase > latest ? phase.phase : latest, null);
|
|
32
|
+
const winner = snapshot.winnerArm ?? (snapshot.phase === newestRollout ? decision?.winnerArm : undefined);
|
|
33
|
+
return shippingTitle(winner ? phase.arms.find((arm)=>arm.key === winner)?.label ?? armLabel(winner) : RESULTS_COPY.shippedGroup);
|
|
34
|
+
}
|
|
35
|
+
export function cappedCell({ metric, arm, caps }) {
|
|
36
|
+
const cap = caps?.[metric.metricId];
|
|
37
|
+
const model = {
|
|
38
|
+
statistic: formatMetric(arm?.mean, metric.kind)
|
|
39
|
+
};
|
|
40
|
+
if (metric.kind !== 'revenue') return model;
|
|
41
|
+
if (cap?.resolvedCap === null || !cap && metric.capNotice === 'no-history') model.notice = RESULTS_COPY.noCap;
|
|
42
|
+
if (arm?.capped) {
|
|
43
|
+
model.totalLine = uncappedTotal(formatMetric(arm.capped.uncappedTotal, metric.kind));
|
|
44
|
+
model.cappedLine = cappedCount(formatCount(arm.capped.cappedCount), formatMetric(cap?.resolvedCap, metric.kind));
|
|
45
|
+
}
|
|
46
|
+
return model;
|
|
47
|
+
}
|
|
48
|
+
export function armRows({ snapshot, phase, metricId }) {
|
|
49
|
+
const metric = snapshot.metrics.find((metric)=>metric.metricId === metricId);
|
|
50
|
+
return phase.arms.map((group)=>{
|
|
51
|
+
const arm = metric?.perArm.find((arm)=>arm.arm === group.key);
|
|
52
|
+
const cell = cappedCell({
|
|
53
|
+
metric: metric ?? phase.metrics.find((metric)=>metric.metricId === metricId) ?? {
|
|
54
|
+
metricId,
|
|
55
|
+
kind: 'count'
|
|
56
|
+
},
|
|
57
|
+
arm,
|
|
58
|
+
caps: snapshot.params.caps
|
|
59
|
+
});
|
|
60
|
+
const row = {
|
|
61
|
+
key: group.key,
|
|
62
|
+
label: group.label,
|
|
63
|
+
n: formatCount(arm?.n ?? snapshot.exposures.perArm[group.key]),
|
|
64
|
+
value: metric?.kind === 'binomial' ? formatCount(arm?.converters) : cell.statistic,
|
|
65
|
+
capped: cell
|
|
66
|
+
};
|
|
67
|
+
if (group.kind === 'holdout') return {
|
|
68
|
+
...row,
|
|
69
|
+
baseline: snapshot.phaseKind === 'rollout' ? RESULTS_COPY.holdoutBaseline : RESULTS_COPY.holdout
|
|
70
|
+
};
|
|
71
|
+
if (group.kind === 'control' && snapshot.phaseKind === 'test') return {
|
|
72
|
+
...row,
|
|
73
|
+
baseline: RESULTS_COPY.original
|
|
74
|
+
};
|
|
75
|
+
const comparison = metric?.comparisons.find((comparison)=>comparison.arm === group.key);
|
|
76
|
+
if (!comparison) return row;
|
|
77
|
+
const common = {
|
|
78
|
+
ci: formatCI(comparison.ci),
|
|
79
|
+
significance: RESULTS_COPY.significance[comparison.significant]
|
|
80
|
+
};
|
|
81
|
+
row.comparison = snapshot.method === 'bayesian' ? {
|
|
82
|
+
...common,
|
|
83
|
+
method: 'bayesian',
|
|
84
|
+
chanceToWin: formatPercent(comparison.chanceToWin),
|
|
85
|
+
risk: formatPercent(comparison.risk)
|
|
86
|
+
} : {
|
|
87
|
+
...common,
|
|
88
|
+
method: 'sequential',
|
|
89
|
+
lift: formatPercent(comparison.lift, true),
|
|
90
|
+
...snapshot.alphaAdjusted !== snapshot.alpha && comparison.ciAdjusted !== undefined ? {
|
|
91
|
+
adjustedCI: formatCI(comparison.ciAdjusted)
|
|
92
|
+
} : {},
|
|
93
|
+
pValue: formatProbability(comparison.pValue),
|
|
94
|
+
...snapshot.alphaAdjusted !== snapshot.alpha && comparison.pValueAdjusted !== undefined ? {
|
|
95
|
+
pValueAdjusted: formatProbability(comparison.pValueAdjusted)
|
|
96
|
+
} : {}
|
|
97
|
+
};
|
|
98
|
+
return row;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
export function guardrailChips(snapshot) {
|
|
102
|
+
return snapshot.guardrails.map((guardrail)=>({
|
|
103
|
+
name: snapshot.metrics.find((metric)=>metric.metricId === guardrail.metricId)?.name ?? '—',
|
|
104
|
+
status: RESULTS_COPY.guardrails[guardrail.status]
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
export function powerLine({ snapshot, phaseKind, status }) {
|
|
108
|
+
if (phaseKind !== 'test' || status !== 'running' || snapshot.verdict.code !== 'collecting') return null;
|
|
109
|
+
const { power } = snapshot;
|
|
110
|
+
if (power.feasible === false || power.daysRemaining !== null && power.daysRemaining > 90) return RESULTS_COPY.infeasible;
|
|
111
|
+
return power.daysRemaining !== null && power.daysRemaining >= 1 ? moreDays(formatCount(Math.ceil(power.daysRemaining))) : RESULTS_COPY.plannedEnd;
|
|
112
|
+
}
|
|
113
|
+
function comparedKeys(snapshot, phase) {
|
|
114
|
+
return phase ? phase.arms.filter((arm)=>arm.kind !== 'holdout' || snapshot.phaseKind === 'rollout').map((arm)=>arm.key) : Object.keys(snapshot.exposures.perArm).filter((key)=>key !== 'holdout' || snapshot.phaseKind === 'rollout');
|
|
115
|
+
}
|
|
116
|
+
function smallest(values) {
|
|
117
|
+
if (!values.length || values.some((value)=>value === undefined || !Number.isFinite(value))) return undefined;
|
|
118
|
+
return values.reduce((min, value)=>min === undefined || value !== undefined && value < min ? value : min, undefined);
|
|
119
|
+
}
|
|
120
|
+
/** Only selects stored counts; never estimates sample sizes or power in the UI. */ export function collectingLine({ snapshot, phaseKind, status }, ctx = {}) {
|
|
121
|
+
if (phaseKind === 'test' && status === 'decided') return null;
|
|
122
|
+
if (snapshot.verdict.code !== (phaseKind === 'rollout' ? 'rollout-collecting' : 'collecting')) return null;
|
|
123
|
+
const keys = comparedKeys(snapshot, ctx.phase);
|
|
124
|
+
const primary = snapshot.metrics.find((metric)=>metric.role === 'primary');
|
|
125
|
+
return collectingCopy(formatCount(smallest(keys.map((key)=>snapshot.exposures.perArm[key]))), formatCount(snapshot.minExposuresPerArm ?? ctx.minExposuresPerArm), formatCount(smallest(keys.map((key)=>primary?.perArm.find((arm)=>arm.arm === key)?.converters))), formatCount(primary ? snapshot.params.minSampleSizes[primary.metricId] : undefined));
|
|
126
|
+
}
|
|
127
|
+
export function dataQuality(snapshot, ctx = {}) {
|
|
128
|
+
const items = [];
|
|
129
|
+
const srmTotal = Object.keys(snapshot.srm.expected).reduce((total, key)=>total + (snapshot.exposures.perArm[key] ?? 0), 0);
|
|
130
|
+
if (snapshot.srm.flagged) items.push({
|
|
131
|
+
id: 'srm',
|
|
132
|
+
message: srmP(formatProbability(snapshot.srm.p)),
|
|
133
|
+
nextStep: RESULTS_COPY.srm,
|
|
134
|
+
shares: Object.entries(snapshot.srm.expected).map(([key, expected])=>shareCopy(ctx.phase?.arms.find((arm)=>arm.key === key)?.label ?? armLabel(key), formatPercent(expected), formatPercent(srmTotal > 0 ? (snapshot.exposures.perArm[key] ?? 0) / srmTotal : undefined)))
|
|
135
|
+
});
|
|
136
|
+
const exposures = snapshot.exposures;
|
|
137
|
+
if (exposures.excludedMultiArm > 0 || exposures.multiArmShare > 0) items.push({
|
|
138
|
+
id: 'multi-group',
|
|
139
|
+
message: RESULTS_COPY.multiGroup,
|
|
140
|
+
detail: exclusionCopy(formatCount(exposures.excludedMultiArm), formatPercent(exposures.multiArmShare)),
|
|
141
|
+
nextStep: RESULTS_COPY.multiGroupNext
|
|
142
|
+
});
|
|
143
|
+
if (exposures.armMismatch > 0) items.push({
|
|
144
|
+
id: 'mismatch',
|
|
145
|
+
message: RESULTS_COPY.mismatch,
|
|
146
|
+
detail: ignoredCopy(formatCount(exposures.armMismatch)),
|
|
147
|
+
nextStep: RESULTS_COPY.mismatchNext
|
|
148
|
+
});
|
|
149
|
+
if (exposures.identityConflictShare > 0) items.push({
|
|
150
|
+
id: 'identity',
|
|
151
|
+
message: RESULTS_COPY.identity,
|
|
152
|
+
detail: conflictCopy(formatPercent(exposures.identityConflictShare)),
|
|
153
|
+
nextStep: RESULTS_COPY.identityNext
|
|
154
|
+
});
|
|
155
|
+
if (snapshot.verdict.code === 'collecting' || snapshot.verdict.code === 'rollout-collecting') items.push({
|
|
156
|
+
id: 'too-few',
|
|
157
|
+
message: RESULTS_COPY.tooFew,
|
|
158
|
+
nextStep: RESULTS_COPY.tooFewNext
|
|
159
|
+
});
|
|
160
|
+
const slices = typeof ctx.layerSlices === 'number' ? ctx.layerSlices : ctx.layerSlices?.length;
|
|
161
|
+
if (ctx.inLayer && slices !== undefined && ctx.allocation !== undefined && slices < ctx.allocation) items.push({
|
|
162
|
+
id: 'layer',
|
|
163
|
+
message: RESULTS_COPY.layerFull,
|
|
164
|
+
nextStep: RESULTS_COPY.layerNext
|
|
165
|
+
});
|
|
166
|
+
for (const metric of snapshot.metrics)if (metric.unavailable !== undefined) items.push({
|
|
167
|
+
id: `metric-${metric.metricId}`,
|
|
168
|
+
message: metricUnavailable(metric.name, metric.unavailable),
|
|
169
|
+
nextStep: RESULTS_COPY.unavailableNext
|
|
170
|
+
});
|
|
171
|
+
return items;
|
|
172
|
+
}
|
|
173
|
+
export function verdictLabel(snapshot) {
|
|
174
|
+
return verdictCodeLabel(snapshot.verdict.code);
|
|
175
|
+
}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { Button, useConfig, useDocumentInfo, useForm, useFormFields, useFormModified } from '@payloadcms/ui';
|
|
5
|
+
import { useApi } from '../useApi.js';
|
|
6
|
+
import { reloadPage } from '../reload.js';
|
|
7
|
+
import { readArms } from '../arms/arms.model.js';
|
|
8
|
+
import { PreviewLinks } from '../PreviewLinks.js';
|
|
9
|
+
import { REVIEW_COPY as C } from '../copy/review.js';
|
|
10
|
+
import { API_MESSAGES, LOCKED_MESSAGES } from '../copy/common.js';
|
|
11
|
+
import { availableActions } from '../actions/actions.model.js';
|
|
12
|
+
import { ConfirmDialog } from '../actions/ConfirmDialog.js';
|
|
13
|
+
import { reviewView } from './review.model.js';
|
|
14
|
+
export function ReviewPanel(_props) {
|
|
15
|
+
const { id, data } = useDocumentInfo();
|
|
16
|
+
const savedAt = typeof data?.updatedAt === 'string' ? data.updatedAt : undefined;
|
|
17
|
+
const { config, getEntityConfig } = useConfig();
|
|
18
|
+
const api = useApi();
|
|
19
|
+
const { dispatchFields, setModified } = useForm();
|
|
20
|
+
const modified = useFormModified();
|
|
21
|
+
const status = useFormFields(([fields])=>fields.status?.value ?? 'draft');
|
|
22
|
+
const kind = useFormFields(([fields])=>fields.kind?.value ?? 'block');
|
|
23
|
+
const armsJson = useFormFields(([fields])=>JSON.stringify(readArms(fields)));
|
|
24
|
+
const arms = JSON.parse(armsJson);
|
|
25
|
+
const metricFields = getEntityConfig({
|
|
26
|
+
collectionSlug: 'xp-metrics'
|
|
27
|
+
})?.fields;
|
|
28
|
+
const sourcesJson = JSON.stringify(metricFields?.find((field)=>field.name === 'source')?.admin?.custom?.sources ?? []);
|
|
29
|
+
const [preflight, setPreflight] = useState(null);
|
|
30
|
+
const [refresh, setRefresh] = useState(0);
|
|
31
|
+
const [loading, setLoading] = useState(true);
|
|
32
|
+
const [busy, setBusy] = useState(false);
|
|
33
|
+
const [confirmStart, setConfirmStart] = useState(false);
|
|
34
|
+
const inFlight = useRef(false);
|
|
35
|
+
const [error, setError] = useState(null);
|
|
36
|
+
const [metricKind, setMetricKind] = useState();
|
|
37
|
+
const [duration, setDuration] = useState('');
|
|
38
|
+
const [tuning, setTuning] = useState('');
|
|
39
|
+
useEffect(()=>{
|
|
40
|
+
if (id == null) return;
|
|
41
|
+
let active = true;
|
|
42
|
+
setLoading(true);
|
|
43
|
+
setError(null);
|
|
44
|
+
void api.preflight(id).then((result)=>{
|
|
45
|
+
if (!active) return;
|
|
46
|
+
if (result.ok && result.data) {
|
|
47
|
+
setPreflight(result.data);
|
|
48
|
+
setDuration(result.data.estimate ? String(result.data.estimate.plannedDurationDays) : '');
|
|
49
|
+
setTuning(result.data.estimate ? String(result.data.estimate.sequentialTuningParameter) : '');
|
|
50
|
+
} else {
|
|
51
|
+
setPreflight(null);
|
|
52
|
+
setError(result.ok ? API_MESSAGES.unreadable : result.message);
|
|
53
|
+
}
|
|
54
|
+
setLoading(false);
|
|
55
|
+
});
|
|
56
|
+
return ()=>{
|
|
57
|
+
active = false;
|
|
58
|
+
};
|
|
59
|
+
}, [
|
|
60
|
+
id,
|
|
61
|
+
api,
|
|
62
|
+
refresh,
|
|
63
|
+
savedAt
|
|
64
|
+
]);
|
|
65
|
+
// The preflight wire shape contains the value, but the saved metric's source supplies its kind.
|
|
66
|
+
const metricId = preflight?.baseline?.metricId;
|
|
67
|
+
useEffect(()=>{
|
|
68
|
+
setMetricKind(undefined);
|
|
69
|
+
if (metricId == null) return;
|
|
70
|
+
const controller = new AbortController();
|
|
71
|
+
void (async ()=>{
|
|
72
|
+
try {
|
|
73
|
+
const response = await fetch(`${config.routes.api.replace(/\/$/, '')}/xp-metrics/${encodeURIComponent(metricId)}?depth=0`, {
|
|
74
|
+
credentials: 'include',
|
|
75
|
+
signal: controller.signal
|
|
76
|
+
});
|
|
77
|
+
if (!response.ok) return;
|
|
78
|
+
const metric = await response.json();
|
|
79
|
+
const sources = JSON.parse(sourcesJson);
|
|
80
|
+
if (!controller.signal.aborted) setMetricKind(sources.find((source)=>source.id === metric.source)?.kind);
|
|
81
|
+
} catch {}
|
|
82
|
+
})();
|
|
83
|
+
return ()=>controller.abort();
|
|
84
|
+
}, [
|
|
85
|
+
metricId,
|
|
86
|
+
config.routes.api,
|
|
87
|
+
sourcesJson
|
|
88
|
+
]);
|
|
89
|
+
if (id == null) return /*#__PURE__*/ _jsx("p", {
|
|
90
|
+
children: C.save
|
|
91
|
+
});
|
|
92
|
+
const view = preflight ? reviewView(preflight, {
|
|
93
|
+
status,
|
|
94
|
+
primaryMetricKind: metricKind
|
|
95
|
+
}) : null;
|
|
96
|
+
const editable = status === 'draft' || status === 'stopped';
|
|
97
|
+
const startAction = availableActions({
|
|
98
|
+
status,
|
|
99
|
+
kind,
|
|
100
|
+
arms,
|
|
101
|
+
canManage: true
|
|
102
|
+
}).find((action)=>action.id === 'start');
|
|
103
|
+
const pending = busy || confirmStart;
|
|
104
|
+
const lockedReason = status === 'running' ? LOCKED_MESSAGES.running : status === 'decided' ? LOCKED_MESSAGES.decided : LOCKED_MESSAGES.archived;
|
|
105
|
+
const validValues = duration.trim() !== '' && Number.isInteger(Number(duration)) && Number(duration) > 0 && tuning.trim() !== '' && Number.isFinite(Number(tuning)) && Number(tuning) >= 0;
|
|
106
|
+
function apply() {
|
|
107
|
+
if (!editable || pending || loading || !view?.applyValues || !validValues) return;
|
|
108
|
+
dispatchFields({
|
|
109
|
+
type: 'UPDATE',
|
|
110
|
+
path: 'analysis.plannedDurationDays',
|
|
111
|
+
value: Number(duration)
|
|
112
|
+
});
|
|
113
|
+
dispatchFields({
|
|
114
|
+
type: 'UPDATE',
|
|
115
|
+
path: 'analysis.sequentialTuningParameter',
|
|
116
|
+
value: Number(tuning)
|
|
117
|
+
});
|
|
118
|
+
setModified(true);
|
|
119
|
+
setRefresh((value)=>value + 1);
|
|
120
|
+
}
|
|
121
|
+
async function start() {
|
|
122
|
+
if (id == null || inFlight.current || pending || loading || modified || !view?.canStart) return;
|
|
123
|
+
if (status === 'stopped') {
|
|
124
|
+
setConfirmStart(true);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
inFlight.current = true;
|
|
128
|
+
setBusy(true);
|
|
129
|
+
setError(null);
|
|
130
|
+
const result = await api.start(id);
|
|
131
|
+
if (result.ok) {
|
|
132
|
+
reloadPage();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
setError(result.message);
|
|
136
|
+
inFlight.current = false;
|
|
137
|
+
setBusy(false);
|
|
138
|
+
}
|
|
139
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
140
|
+
className: "xp-review",
|
|
141
|
+
children: [
|
|
142
|
+
loading ? /*#__PURE__*/ _jsx("p", {
|
|
143
|
+
role: "status",
|
|
144
|
+
children: C.loading
|
|
145
|
+
}) : null,
|
|
146
|
+
view && preflight ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
147
|
+
children: [
|
|
148
|
+
/*#__PURE__*/ _jsx("ul", {
|
|
149
|
+
children: view.checks.map((check, index)=>/*#__PURE__*/ _jsxs("li", {
|
|
150
|
+
children: [
|
|
151
|
+
/*#__PURE__*/ _jsxs("span", {
|
|
152
|
+
children: [
|
|
153
|
+
check.ok ? '✓' : '✗',
|
|
154
|
+
" ",
|
|
155
|
+
check.ok ? check.done : check.hint
|
|
156
|
+
]
|
|
157
|
+
}),
|
|
158
|
+
check.detail ? /*#__PURE__*/ _jsx("p", {
|
|
159
|
+
children: check.detail
|
|
160
|
+
}) : null
|
|
161
|
+
]
|
|
162
|
+
}, index))
|
|
163
|
+
}),
|
|
164
|
+
/*#__PURE__*/ _jsx("ul", {
|
|
165
|
+
children: view.placements.map((placement)=>/*#__PURE__*/ _jsxs("li", {
|
|
166
|
+
children: [
|
|
167
|
+
placement.ok ? '✓' : '✗',
|
|
168
|
+
" ",
|
|
169
|
+
placement.title,
|
|
170
|
+
placement.detail ? /*#__PURE__*/ _jsx("p", {
|
|
171
|
+
children: placement.detail
|
|
172
|
+
}) : null
|
|
173
|
+
]
|
|
174
|
+
}, `${placement.collection}/${placement.id}`))
|
|
175
|
+
}),
|
|
176
|
+
/*#__PURE__*/ _jsx("fieldset", {
|
|
177
|
+
disabled: pending || loading,
|
|
178
|
+
style: {
|
|
179
|
+
border: 0,
|
|
180
|
+
padding: 0
|
|
181
|
+
},
|
|
182
|
+
children: /*#__PURE__*/ _jsx(PreviewLinks, {
|
|
183
|
+
experimentId: id,
|
|
184
|
+
placements: preflight.placements,
|
|
185
|
+
arms: arms
|
|
186
|
+
})
|
|
187
|
+
}),
|
|
188
|
+
/*#__PURE__*/ _jsx("p", {
|
|
189
|
+
children: view.baseline
|
|
190
|
+
}),
|
|
191
|
+
/*#__PURE__*/ _jsx("p", {
|
|
192
|
+
children: view.traffic
|
|
193
|
+
}),
|
|
194
|
+
/*#__PURE__*/ _jsx("p", {
|
|
195
|
+
className: view.estimateWarning ? 'xp-review__warning' : undefined,
|
|
196
|
+
style: view.estimateWarning ? {
|
|
197
|
+
color: 'var(--theme-warning-600)'
|
|
198
|
+
} : undefined,
|
|
199
|
+
children: view.estimate
|
|
200
|
+
}),
|
|
201
|
+
view.applyValues ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
202
|
+
children: [
|
|
203
|
+
/*#__PURE__*/ _jsxs("label", {
|
|
204
|
+
children: [
|
|
205
|
+
C.duration,
|
|
206
|
+
/*#__PURE__*/ _jsx("input", {
|
|
207
|
+
type: "number",
|
|
208
|
+
min: 1,
|
|
209
|
+
step: 1,
|
|
210
|
+
value: duration,
|
|
211
|
+
disabled: !editable || pending || loading,
|
|
212
|
+
onChange: (event)=>setDuration(event.target.value)
|
|
213
|
+
})
|
|
214
|
+
]
|
|
215
|
+
}),
|
|
216
|
+
/*#__PURE__*/ _jsxs("label", {
|
|
217
|
+
children: [
|
|
218
|
+
C.tuning,
|
|
219
|
+
/*#__PURE__*/ _jsx("input", {
|
|
220
|
+
type: "number",
|
|
221
|
+
min: 0,
|
|
222
|
+
step: "any",
|
|
223
|
+
value: tuning,
|
|
224
|
+
disabled: !editable || pending || loading,
|
|
225
|
+
onChange: (event)=>setTuning(event.target.value)
|
|
226
|
+
})
|
|
227
|
+
]
|
|
228
|
+
}),
|
|
229
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
230
|
+
disabled: !editable || pending || loading || !validValues,
|
|
231
|
+
onClick: apply,
|
|
232
|
+
children: C.apply
|
|
233
|
+
})
|
|
234
|
+
]
|
|
235
|
+
}) : null,
|
|
236
|
+
!editable ? /*#__PURE__*/ _jsx("p", {
|
|
237
|
+
children: lockedReason
|
|
238
|
+
}) : null,
|
|
239
|
+
modified ? /*#__PURE__*/ _jsx("p", {
|
|
240
|
+
children: C.saveFirst
|
|
241
|
+
}) : null,
|
|
242
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
243
|
+
disabled: !view.canStart || modified || pending || loading,
|
|
244
|
+
onClick: ()=>{
|
|
245
|
+
void start();
|
|
246
|
+
},
|
|
247
|
+
children: startAction?.label ?? C.start
|
|
248
|
+
})
|
|
249
|
+
]
|
|
250
|
+
}) : null,
|
|
251
|
+
error ? /*#__PURE__*/ _jsx("p", {
|
|
252
|
+
role: "alert",
|
|
253
|
+
children: error
|
|
254
|
+
}) : null,
|
|
255
|
+
error && !preflight ? /*#__PURE__*/ _jsx(Button, {
|
|
256
|
+
disabled: pending || loading,
|
|
257
|
+
onClick: ()=>setRefresh((value)=>value + 1),
|
|
258
|
+
children: C.retry
|
|
259
|
+
}) : null,
|
|
260
|
+
confirmStart && startAction ? /*#__PURE__*/ _jsx(ConfirmDialog, {
|
|
261
|
+
id: id,
|
|
262
|
+
action: startAction,
|
|
263
|
+
winnerLabel: "",
|
|
264
|
+
onClose: ()=>setConfirmStart(false)
|
|
265
|
+
}, `${id}/start`) : null
|
|
266
|
+
]
|
|
267
|
+
});
|
|
268
|
+
}
|