@delmaredigital/payload-experiments 0.4.0 → 0.5.0
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 +10 -4
- package/dist/admin/blocks/model.js +2 -0
- package/dist/admin/copy/blocks.d.ts +1 -0
- package/dist/admin/copy/blocks.js +1 -0
- package/dist/admin/copy/status.d.ts +3 -0
- package/dist/admin/copy/status.js +3 -0
- package/dist/admin/placementStatus.model.js +3 -0
- package/dist/admin/status.model.d.ts +3 -2
- package/dist/admin/status.model.js +9 -3
- package/dist/admin/surface/ResultsRoute.js +2 -1
- package/dist/admin/surface/TestsHome.d.ts +2 -1
- package/dist/admin/surface/TestsHome.js +31 -11
- package/dist/admin/surface/TestsSurface.js +4 -0
- package/dist/admin/surface/home.model.d.ts +11 -6
- package/dist/admin/surface/home.model.js +19 -8
- package/dist/admin/surface/newTest/PageWizard.js +13 -3
- package/dist/admin/surface/results/ResultsHeader.js +43 -9
- package/dist/admin/surface/test/TestPage.js +11 -1
- package/dist/admin/useLayerUsage.d.ts +1 -1
- package/dist/admin/views/buildSurfaceProps.js +3 -0
- package/dist/cohorts/build.d.ts +35 -0
- package/dist/cohorts/build.js +134 -0
- package/dist/cohorts/key.d.ts +12 -0
- package/dist/cohorts/key.js +15 -0
- package/dist/cohorts/maintenance.d.ts +10 -0
- package/dist/cohorts/maintenance.js +70 -0
- package/dist/cohorts/readiness.d.ts +30 -0
- package/dist/cohorts/readiness.js +54 -0
- package/dist/cohorts/readinessData.d.ts +29 -0
- package/dist/cohorts/readinessData.js +123 -0
- package/dist/cohorts/rule.d.ts +33 -0
- package/dist/cohorts/rule.js +50 -0
- package/dist/collections/cohortMembers.d.ts +4 -0
- package/dist/collections/cohortMembers.js +95 -0
- package/dist/collections/experiments/config.js +157 -7
- package/dist/collections/experiments/editability.js +10 -6
- package/dist/collections/experiments/lockHook.js +39 -20
- package/dist/collections/index.js +4 -1
- package/dist/collections/phases.js +4 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/db/adapter.d.ts +1 -1
- package/dist/db/adapter.js +14 -4
- package/dist/db/appends.js +1 -1
- package/dist/db/cohortMembership.d.ts +11 -0
- package/dist/db/cohortMembership.js +31 -0
- package/dist/db/cohortPool.d.ts +9 -0
- package/dist/db/cohortPool.js +53 -0
- package/dist/db/cohortTransactions.d.ts +3 -0
- package/dist/db/cohortTransactions.js +52 -0
- package/dist/db/cohorts.d.ts +72 -0
- package/dist/db/cohorts.js +280 -0
- package/dist/db/erase.d.ts +2 -0
- package/dist/db/erase.js +21 -2
- package/dist/db/events.d.ts +2 -0
- package/dist/db/events.js +8 -0
- package/dist/db/executor.d.ts +2 -0
- package/dist/db/executor.js +8 -0
- package/dist/db/locks.d.ts +7 -0
- package/dist/db/locks.js +13 -1
- package/dist/db/names.d.ts +95 -1
- package/dist/db/names.js +95 -1
- package/dist/db/occupancy.d.ts +21 -0
- package/dist/db/occupancy.js +46 -0
- package/dist/db/pageOccupancy.d.ts +4 -4
- package/dist/db/pageOccupancy.js +13 -10
- package/dist/db/pgExecutor.d.ts +4 -0
- package/dist/db/pgExecutor.js +1 -1
- package/dist/db/placements.js +1 -1
- package/dist/db/results.d.ts +5 -2
- package/dist/db/results.js +32 -5
- package/dist/db/slices.d.ts +9 -2
- package/dist/db/slices.js +15 -8
- package/dist/db/snapshots.d.ts +16 -1
- package/dist/db/snapshots.js +27 -2
- package/dist/db/sql.d.ts +2 -2
- package/dist/db/sql.js +1 -2
- package/dist/endpoints/cohortSources.d.ts +16 -0
- package/dist/endpoints/cohortSources.js +335 -0
- package/dist/endpoints/contentLocale.d.ts +1 -1
- package/dist/endpoints/events.js +82 -18
- package/dist/endpoints/index.js +45 -1
- package/dist/endpoints/pausedBy.d.ts +14 -0
- package/dist/endpoints/pausedBy.js +94 -0
- package/dist/endpoints/preflight.js +4 -1
- package/dist/endpoints/previewToken.js +2 -0
- package/dist/endpoints/results.d.ts +2 -2
- package/dist/endpoints/results.js +111 -3
- package/dist/endpoints/routeId.d.ts +2 -1
- package/dist/endpoints/routeId.js +6 -2
- package/dist/endpoints/summary.js +24 -1
- package/dist/endpoints/transitions.d.ts +7 -0
- package/dist/endpoints/transitions.js +50 -1
- package/dist/events/rows.d.ts +1 -1
- package/dist/events/rows.js +5 -3
- package/dist/exports/index.d.ts +2 -0
- package/dist/exports/index.js +1 -0
- package/dist/exports/runtimeProxy.d.ts +1 -0
- package/dist/exports/runtimeProxy.js +1 -0
- package/dist/hooks/blockRemovalRule.js +7 -4
- package/dist/hooks/pageGuard.js +1 -1
- package/dist/labels/status.d.ts +15 -0
- package/dist/labels/status.js +12 -0
- package/dist/manifest/compile.d.ts +15 -4
- package/dist/manifest/compile.js +91 -3
- package/dist/onInit.js +4 -1
- package/dist/options.d.ts +1 -0
- package/dist/options.js +10 -0
- package/dist/proxy/consentFallback.d.ts +1 -1
- package/dist/proxy/consentFallback.js +4 -4
- package/dist/proxy/control.d.ts +1 -1
- package/dist/proxy/control.js +2 -2
- package/dist/proxy/pageRewrite.d.ts +1 -1
- package/dist/proxy/pageRewrite.js +3 -2
- package/dist/proxy/resolve.js +76 -17
- package/dist/puck/ExperimentPicker.js +2 -1
- package/dist/puck/copy.d.ts +6 -5
- package/dist/puck/copy.js +3 -7
- package/dist/puck/editor/ExperimentSlotEditor.js +16 -5
- package/dist/puck/editor/QuickTestActions.js +7 -1
- package/dist/puck/editor/armWrites.js +6 -1
- package/dist/puck/editor/copy.d.ts +3 -0
- package/dist/puck/editor/copy.js +3 -0
- package/dist/puck/editor/editor.css +2 -1
- package/dist/puck/editor/editor.model.d.ts +2 -1
- package/dist/puck/editor/editor.model.js +2 -0
- package/dist/puck/editor/placementsCache.d.ts +1 -1
- package/dist/puck/editor/placementsCache.js +6 -3
- package/dist/results/analyse.d.ts +3 -1
- package/dist/results/analyse.js +20 -3
- package/dist/results/health.d.ts +11 -0
- package/dist/results/health.js +38 -0
- package/dist/results/power.d.ts +1 -1
- package/dist/results/power.js +1 -1
- package/dist/results/snapshot.d.ts +8 -2
- package/dist/results/snapshot.js +23 -1
- package/dist/results/unitValues.d.ts +48 -0
- package/dist/results/unitValues.js +166 -0
- package/dist/runtime/assign.d.ts +7 -3
- package/dist/runtime/assign.js +12 -4
- package/dist/runtime/cohortCookie.d.ts +15 -0
- package/dist/runtime/cohortCookie.js +72 -0
- package/dist/runtime/cohortLookup.d.ts +9 -0
- package/dist/runtime/cohortLookup.js +25 -0
- package/dist/runtime/eligibility.d.ts +11 -5
- package/dist/runtime/eligibility.js +33 -7
- package/dist/runtime/header.d.ts +1 -0
- package/dist/runtime/header.js +1 -1
- package/dist/runtime/proxyRuntime.js +5 -1
- package/dist/runtime/targeting.d.ts +3 -2
- package/dist/runtime/targeting.js +2 -1
- package/dist/sanitizeReadinessDetail.d.ts +2 -2
- package/dist/sanitizeReadinessDetail.js +41 -4
- package/dist/schedule/activeTime.d.ts +28 -0
- package/dist/schedule/activeTime.js +322 -0
- package/dist/schedule/ranges.d.ts +13 -0
- package/dist/schedule/ranges.js +11 -0
- package/dist/schedule/roundTime.d.ts +10 -0
- package/dist/schedule/roundTime.js +45 -0
- package/dist/schedule/types.d.ts +29 -0
- package/dist/schedule/types.js +1 -0
- package/dist/server/cohortLookup.d.ts +3 -0
- package/dist/server/cohortLookup.js +7 -0
- package/dist/server/eraseUser.d.ts +1 -0
- package/dist/server/getAssignments.js +63 -40
- package/dist/server/previewDraft.d.ts +1 -1
- package/dist/server/previewDraft.js +3 -2
- package/dist/server/recordExposures.js +4 -2
- package/dist/server/runResults.js +97 -150
- package/dist/testSurface/actions/LifecycleAction.d.ts +2 -1
- package/dist/testSurface/actions/LifecycleAction.js +15 -5
- package/dist/testSurface/actions/actions.model.d.ts +13 -2
- package/dist/testSurface/actions/actions.model.js +38 -5
- package/dist/testSurface/api.d.ts +13 -1
- package/dist/testSurface/api.js +19 -0
- package/dist/testSurface/copy/actions.d.ts +13 -0
- package/dist/testSurface/copy/actions.js +13 -0
- package/dist/testSurface/copy/cohorts.d.ts +68 -0
- package/dist/testSurface/copy/cohorts.js +81 -0
- package/dist/testSurface/copy/common.d.ts +2 -3
- package/dist/testSurface/copy/common.js +4 -4
- package/dist/testSurface/copy/inputs.d.ts +3 -0
- package/dist/testSurface/copy/inputs.js +3 -0
- package/dist/testSurface/copy/readiness.d.ts +20 -6
- package/dist/testSurface/copy/readiness.js +42 -9
- package/dist/testSurface/copy/results.d.ts +1 -0
- package/dist/testSurface/copy/results.js +1 -0
- package/dist/testSurface/copy/schedule.d.ts +58 -0
- package/dist/testSurface/copy/schedule.js +150 -0
- package/dist/testSurface/copy/surface.d.ts +2 -0
- package/dist/testSurface/copy/surface.js +2 -0
- package/dist/testSurface/copy/testPage.d.ts +12 -2
- package/dist/testSurface/copy/testPage.js +17 -2
- package/dist/testSurface/format/roundProgress.d.ts +13 -1
- package/dist/testSurface/format/roundProgress.js +34 -5
- package/dist/testSurface/format/scheduleStatus.d.ts +34 -0
- package/dist/testSurface/format/scheduleStatus.js +93 -0
- package/dist/testSurface/format/useScheduleClock.d.ts +3 -0
- package/dist/testSurface/format/useScheduleClock.js +20 -0
- package/dist/testSurface/labels.d.ts +4 -9
- package/dist/testSurface/labels.js +2 -7
- package/dist/testSurface/lockedNotice.model.d.ts +2 -2
- package/dist/testSurface/lockedNotice.model.js +16 -3
- package/dist/testSurface/readPreflight.d.ts +3 -0
- package/dist/testSurface/readPreflight.js +14 -0
- package/dist/testSurface/readinessRead.d.ts +2 -2
- package/dist/testSurface/results/DataQualityPanel.js +7 -7
- package/dist/testSurface/results/results.model.d.ts +1 -1
- package/dist/testSurface/results/results.model.js +34 -6
- package/dist/testSurface/review/cohortEstimate.d.ts +11 -0
- package/dist/testSurface/review/cohortEstimate.js +32 -0
- package/dist/testSurface/surface/contracts.d.ts +2 -1
- package/dist/testSurface/surface/contracts.js +1 -0
- package/dist/testSurface/surface/editorPlacement.d.ts +1 -0
- package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +3 -2
- package/dist/testSurface/surface/readiness/ActionDialogs.js +121 -32
- package/dist/testSurface/surface/readiness/Banner.js +29 -11
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +20 -2
- package/dist/testSurface/surface/readiness/readiness.model.js +35 -5
- package/dist/testSurface/surface/readiness/useTransition.js +17 -5
- package/dist/testSurface/surface/results/ResultsBody.js +46 -10
- package/dist/testSurface/surface/results/useResults.d.ts +16 -1
- package/dist/testSurface/surface/results/useResults.js +17 -6
- package/dist/testSurface/surface/test/CohortRuleEditor.d.ts +16 -0
- package/dist/testSurface/surface/test/CohortRuleEditor.js +492 -0
- package/dist/testSurface/surface/test/LengthSection.js +26 -6
- package/dist/testSurface/surface/test/ScheduleDateInput.d.ts +4 -0
- package/dist/testSurface/surface/test/ScheduleDateInput.js +15 -0
- package/dist/testSurface/surface/test/ScheduleSection.d.ts +2 -0
- package/dist/testSurface/surface/test/ScheduleSection.js +322 -0
- package/dist/testSurface/surface/test/Section.js +1 -1
- package/dist/testSurface/surface/test/TargetingSection.js +306 -182
- package/dist/testSurface/surface/test/TestSurface.js +9 -0
- package/dist/testSurface/surface/test/fields.d.ts +2 -1
- package/dist/testSurface/surface/test/fields.js +3 -3
- package/dist/testSurface/surface/test/jumpToSection.d.ts +1 -1
- package/dist/testSurface/surface/test/jumpToSection.js +4 -4
- package/dist/testSurface/surface/test/testPage.css +26 -0
- package/dist/testSurface/surface/testDocument.model.d.ts +12 -1
- package/dist/testSurface/surface/testDocument.model.js +2 -1
- package/dist/testSurface/surface/useTestDocument.js +11 -4
- package/dist/testSurface/targeting/targeting.model.d.ts +2 -1
- package/dist/testSurface/targeting/targeting.model.js +1 -1
- package/dist/testSurface/useApi.d.ts +12 -0
- package/dist/transitions/addMetric.js +5 -2
- package/dist/transitions/allocate.js +6 -1
- package/dist/transitions/assertNoOverlap.d.ts +9 -0
- package/dist/transitions/assertNoOverlap.js +24 -0
- package/dist/transitions/buildCohorts.d.ts +10 -0
- package/dist/transitions/buildCohorts.js +68 -0
- package/dist/transitions/cancelSchedule.d.ts +4 -0
- package/dist/transitions/cancelSchedule.js +42 -0
- package/dist/transitions/checkStart.d.ts +17 -3
- package/dist/transitions/checkStart.js +20 -7
- package/dist/transitions/decide.js +35 -11
- package/dist/transitions/kernel.d.ts +3 -1
- package/dist/transitions/kernel.js +5 -2
- package/dist/transitions/pause.d.ts +4 -0
- package/dist/transitions/pause.js +35 -0
- package/dist/transitions/phaseRecord.d.ts +19 -2
- package/dist/transitions/phaseRecord.js +50 -11
- package/dist/transitions/placementInteractions.js +1 -1
- package/dist/transitions/preflightData.d.ts +11 -3
- package/dist/transitions/preflightData.js +134 -81
- package/dist/transitions/reschedule.d.ts +4 -0
- package/dist/transitions/reschedule.js +58 -0
- package/dist/transitions/resume.d.ts +4 -0
- package/dist/transitions/resume.js +32 -0
- package/dist/transitions/scheduledRound.d.ts +18 -0
- package/dist/transitions/scheduledRound.js +42 -0
- package/dist/transitions/start.d.ts +4 -0
- package/dist/transitions/start.js +136 -55
- package/dist/transitions/startReads.d.ts +14 -0
- package/dist/transitions/startReads.js +27 -0
- package/dist/transitions/stop.d.ts +10 -0
- package/dist/transitions/stop.js +35 -22
- package/dist/types/admin.d.ts +1 -1
- package/dist/types/contracts.d.ts +7 -1
- package/dist/types/endpoints.d.ts +72 -3
- package/dist/types/manifest.d.ts +9 -0
- package/dist/types/runtime.d.ts +5 -0
- package/dist/types/snapshot.d.ts +10 -0
- package/dist/types/status.d.ts +1 -0
- package/dist/types/status.js +1 -0
- package/dist/types/surface.d.ts +1 -0
- package/dist/ui/Feedback.d.ts +9 -6
- package/dist/ui/Feedback.js +10 -9
- package/dist/ui/SelectControl.js +1 -1
- package/dist/ui/ui.css +2 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
# @delmaredigital/payload-experiments
|
|
2
2
|
|
|
3
|
+
> ⚠️ Upgrading to 0.5? Run `payload migrate:create` and apply the migration. [Upgrade instructions](https://plugins.delmaredigital.com/docs/experiments/upgrading)
|
|
4
|
+
|
|
3
5
|
A/B testing for Payload CMS and Next.js, from the content you already manage. Test a block on a page, a whole page against another page, or a setting your developer makes testable. Pick a goal, including click goals you name and attach to buttons and links, then compare the Original with your new versions. Results appear in the admin: they count only people who actually saw the content, warn when traffic looks wrong, and check guardrail goals (goals you don't want to hurt). You pick a winner and can make it permanent. Your data stays in your own Postgres database. There is no vendor.
|
|
4
6
|
|
|
7
|
+
**Documentation:** [plugins.delmaredigital.com/docs/experiments](https://plugins.delmaredigital.com/docs/experiments) · [Quick start](https://plugins.delmaredigital.com/docs/experiments/quick-start) · [Installation](https://plugins.delmaredigital.com/docs/experiments/installation)
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
5
11
|
## Install
|
|
6
12
|
|
|
7
13
|
```bash
|
|
@@ -255,7 +261,7 @@ A session refresh or an account's verified-email flag is not proof here.
|
|
|
255
261
|
|
|
256
262
|
### Erasing a user
|
|
257
263
|
|
|
258
|
-
When you erase a user, call `eraseUser(payload, { userId })` from `/rsc` so their test data goes too; see
|
|
264
|
+
When you erase a user, call `eraseUser(payload, { userId })` from `/rsc` so their test data goes too; see [`eraseUser`](https://plugins.delmaredigital.com/docs/experiments/reference/server#eraseuser).
|
|
259
265
|
|
|
260
266
|
### Puck (optional)
|
|
261
267
|
|
|
@@ -404,11 +410,11 @@ Callbacks receive `{ req }` and return a boolean or a promise of one.
|
|
|
404
410
|
| `readResults` | Read results | `manage` |
|
|
405
411
|
| `readIdentities` | Read identity links | `admin` |
|
|
406
412
|
|
|
407
|
-
## Full reference
|
|
413
|
+
## Full reference
|
|
408
414
|
|
|
409
|
-
|
|
415
|
+
Every option, export and endpoint is documented at [plugins.delmaredigital.com/docs/experiments](https://plugins.delmaredigital.com/docs/experiments), starting with [plugin options](https://plugins.delmaredigital.com/docs/experiments/reference/plugin-options).
|
|
410
416
|
|
|
411
417
|
## License
|
|
412
418
|
|
|
413
419
|
[MIT](https://github.com/delmaredigital/payload-experiments/blob/main/LICENSE).
|
|
414
|
-
See the [statistics engine
|
|
420
|
+
See the [statistics engine documentation](https://plugins.delmaredigital.com/docs/experiments/stats-package) for the methods behind the results.
|
|
@@ -14,6 +14,8 @@ export function statusSentence(status) {
|
|
|
14
14
|
switch(status.status){
|
|
15
15
|
case 'draft':
|
|
16
16
|
return blockDraftStatus(status.name, controlLabel);
|
|
17
|
+
case 'paused':
|
|
18
|
+
return BLOCK_COPY.paused(controlLabel);
|
|
17
19
|
case 'running':
|
|
18
20
|
return BLOCK_COPY.running;
|
|
19
21
|
case 'stopped':
|
|
@@ -21,6 +21,7 @@ export declare const BLOCK_COPY: {
|
|
|
21
21
|
discarded: (label?: string) => string;
|
|
22
22
|
neverDecided: (label?: string) => string;
|
|
23
23
|
running: string;
|
|
24
|
+
paused: (label?: string) => string;
|
|
24
25
|
stopped: (label?: string) => string;
|
|
25
26
|
archivedReplaceWhy: string;
|
|
26
27
|
archivedReplaceSteps: string[];
|
|
@@ -23,6 +23,7 @@ export const BLOCK_COPY = {
|
|
|
23
23
|
discarded: (label)=>`Winner discarded: this block shows ${controlVersionName(label)}. Use Unwrap to replace it with the content of ${controlVersionName(label)}.`,
|
|
24
24
|
neverDecided: (label)=>`Archived without a winner: this block shows ${controlVersionName(label)}. Use Unwrap to replace it with the content of ${controlVersionName(label)}.`,
|
|
25
25
|
running: "Running: visitors see different versions. Edit a version's tab to change it; the change is noted on the results.",
|
|
26
|
+
paused: (label)=>`Paused. Visitors see ${controlVersionName(label)}. Editing content now can affect the comparison when the test resumes.`,
|
|
26
27
|
stopped: (label)=>`Stopped: visitors see ${controlVersionName(label)}.`,
|
|
27
28
|
archivedReplaceWhy: 'To keep the winner on this page without the test, replace the Test block.',
|
|
28
29
|
archivedReplaceSteps: [
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export declare const STATUS_TOOLTIPS: {
|
|
2
2
|
readonly draft: "Draft";
|
|
3
3
|
readonly running: "Running";
|
|
4
|
+
readonly scheduled: "Scheduled";
|
|
5
|
+
readonly paused: "Paused — everyone sees the Original";
|
|
4
6
|
readonly stopped: (label?: string) => string;
|
|
5
7
|
readonly decided: "Decided — everyone sees the winner";
|
|
6
8
|
readonly decidedWithHoldout: "Decided — everyone sees the winner, except the holdout";
|
|
7
9
|
readonly archived: "Archived";
|
|
8
10
|
};
|
|
11
|
+
export declare const pausedPageStatus: (version: string, test: string) => string;
|
|
@@ -2,8 +2,11 @@ import { controlVersionName } from '../../labels/arms.js';
|
|
|
2
2
|
export const STATUS_TOOLTIPS = {
|
|
3
3
|
draft: 'Draft',
|
|
4
4
|
running: 'Running',
|
|
5
|
+
scheduled: 'Scheduled',
|
|
6
|
+
paused: 'Paused — everyone sees the Original',
|
|
5
7
|
stopped: (label)=>`Stopped — everyone sees ${controlVersionName(label)}`,
|
|
6
8
|
decided: 'Decided — everyone sees the winner',
|
|
7
9
|
decidedWithHoldout: 'Decided — everyone sees the winner, except the holdout',
|
|
8
10
|
archived: 'Archived'
|
|
9
11
|
};
|
|
12
|
+
export const pausedPageStatus = (version, test)=>`This page is ${version} in the paused test ${test}. Editing content now can affect the comparison when the test resumes.`;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { controlVersionName } from '../labels/arms.js';
|
|
2
|
+
import { pausedPageStatus } from './copy/status.js';
|
|
2
3
|
export function pageStatusCopy(test) {
|
|
3
4
|
if (test.pagesReleased) return null;
|
|
4
5
|
const winner = `${test.winnerLabel ?? 'the winner'}${test.winnerTitle ? ` (${test.winnerTitle})` : ''}`;
|
|
@@ -11,6 +12,8 @@ export function pageStatusCopy(test) {
|
|
|
11
12
|
const visitors = test.role === 'original' ? 'Visitors see this page.' : !test.originalPath ? `Visitors see ${control}.` : `Visitors to ${test.originalPath === '/' ? 'the homepage (/)' : test.originalPath} see ${control}.`;
|
|
12
13
|
return `This page is ${test.armLabel} in the stopped test ${test.name}. ${visitors}`;
|
|
13
14
|
}
|
|
15
|
+
case 'paused':
|
|
16
|
+
return pausedPageStatus(test.armLabel, test.name);
|
|
14
17
|
case 'running':
|
|
15
18
|
return `This page is the ${test.armLabel} of a running test: ${test.name}.`;
|
|
16
19
|
case 'decided':
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Status } from '../types/contracts.js';
|
|
2
2
|
export type PillTone = 'neutral' | 'success' | 'warning' | 'info' | 'muted';
|
|
3
|
-
export declare function statusPill({ status, arms, decision }: {
|
|
3
|
+
export declare function statusPill({ status: rawStatus, startedAt, arms, decision }: {
|
|
4
4
|
status: Status;
|
|
5
|
+
startedAt?: string | null;
|
|
5
6
|
arms?: readonly {
|
|
6
7
|
key: string;
|
|
7
8
|
label?: string;
|
|
@@ -10,7 +11,7 @@ export declare function statusPill({ status, arms, decision }: {
|
|
|
10
11
|
winnerArm?: string | null;
|
|
11
12
|
holdoutReleasedAt?: string | null;
|
|
12
13
|
} | null;
|
|
13
|
-
}): {
|
|
14
|
+
}, now?: number): {
|
|
14
15
|
label: string;
|
|
15
16
|
tone: PillTone;
|
|
16
17
|
tooltip: string;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import { statusLabel } from '../testSurface/labels.js';
|
|
1
|
+
import { displayStatus, statusLabel } from '../testSurface/labels.js';
|
|
2
2
|
import { STATUS_TOOLTIPS } from './copy/status.js';
|
|
3
3
|
const TONES = {
|
|
4
4
|
draft: 'neutral',
|
|
5
5
|
running: 'success',
|
|
6
6
|
stopped: 'warning',
|
|
7
7
|
decided: 'info',
|
|
8
|
-
archived: 'muted'
|
|
8
|
+
archived: 'muted',
|
|
9
|
+
scheduled: 'info',
|
|
10
|
+
paused: 'warning'
|
|
9
11
|
};
|
|
10
|
-
export function statusPill({ status, arms = [], decision }) {
|
|
12
|
+
export function statusPill({ status: rawStatus, startedAt, arms = [], decision }, now = Date.now()) {
|
|
13
|
+
const status = displayStatus({
|
|
14
|
+
status: rawStatus,
|
|
15
|
+
startedAt
|
|
16
|
+
}, now);
|
|
11
17
|
const holdout = status === 'decided' && arms?.some((group)=>group.key === 'holdout') && Boolean(decision?.winnerArm) && decision?.winnerArm !== 'control' && !decision?.holdoutReleasedAt;
|
|
12
18
|
const tooltip = status === 'stopped' ? STATUS_TOOLTIPS.stopped(arms?.find((group)=>group.key === 'control')?.label) : holdout ? STATUS_TOOLTIPS.decidedWithHoldout : STATUS_TOOLTIPS[status];
|
|
13
19
|
return {
|
|
@@ -37,7 +37,8 @@ function ManagedResults({ id, surface, onTitleChange }) {
|
|
|
37
37
|
test.doc.status,
|
|
38
38
|
test.doc.phase,
|
|
39
39
|
test.doc.allocation,
|
|
40
|
-
test.doc.metrics
|
|
40
|
+
test.doc.metrics,
|
|
41
|
+
test.doc.schedule
|
|
41
42
|
]) : 'loading';
|
|
42
43
|
if (test.loadState === 'ready' && test.doc) return /*#__PURE__*/ _jsx(ResultsBody, {
|
|
43
44
|
documentVersion: bodyKey,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { SurfaceShellProps } from './SurfaceShell.js';
|
|
2
2
|
import type { SurfaceProps } from '../../testSurface/surface/contracts.js';
|
|
3
|
-
export declare function TestsHome({ adminRoute, apiRoute, contentLocale, canManage, canReadResults, crumbs, flagPoints }: {
|
|
3
|
+
export declare function TestsHome({ adminRoute, apiRoute, contentLocale, canManage, canReadResults, crumbs, flagPoints, timeZone }: {
|
|
4
4
|
adminRoute: string;
|
|
5
5
|
apiRoute: string;
|
|
6
|
+
timeZone?: string;
|
|
6
7
|
contentLocale?: string;
|
|
7
8
|
canManage?: boolean;
|
|
8
9
|
canReadResults?: boolean;
|
|
@@ -24,6 +24,7 @@ import { useTestDocument } from '../../testSurface/surface/useTestDocument.js';
|
|
|
24
24
|
import { ConfirmDialog } from '../../ui/Dialog.js';
|
|
25
25
|
import { ACTIONS_COPY } from '../../testSurface/copy/actions.js';
|
|
26
26
|
import { API_MESSAGES } from '../../testSurface/copy/common.js';
|
|
27
|
+
import { useScheduleClock } from '../../testSurface/format/useScheduleClock.js';
|
|
27
28
|
import { READINESS_COPY } from '../../testSurface/copy/readiness.js';
|
|
28
29
|
const HOME_FIELDS = [
|
|
29
30
|
'name',
|
|
@@ -38,13 +39,16 @@ const HOME_FIELDS = [
|
|
|
38
39
|
'updatedAt',
|
|
39
40
|
'phase',
|
|
40
41
|
'allocation',
|
|
41
|
-
'startedAt'
|
|
42
|
+
'startedAt',
|
|
43
|
+
'schedule',
|
|
44
|
+
'pausedAt',
|
|
45
|
+
'pauseReason'
|
|
42
46
|
];
|
|
43
47
|
// Typecheck fails if HomeTest gains a field the list request does not select (Payload always returns id).
|
|
44
48
|
const homeFieldsComplete = true;
|
|
45
49
|
void homeFieldsComplete;
|
|
46
50
|
const HOME_SELECT = HOME_FIELDS.map((field)=>`select[${field}]=true`).join('&');
|
|
47
|
-
export function TestsHome({ adminRoute, apiRoute, contentLocale, canManage = false, canReadResults = true, crumbs, flagPoints }) {
|
|
51
|
+
export function TestsHome({ adminRoute, apiRoute, contentLocale, canManage = false, canReadResults = true, crumbs, flagPoints, timeZone }) {
|
|
48
52
|
useXpStepNav([
|
|
49
53
|
{
|
|
50
54
|
label: SURFACE_COPY.title
|
|
@@ -128,7 +132,10 @@ export function TestsHome({ adminRoute, apiRoute, contentLocale, canManage = fal
|
|
|
128
132
|
if (!response.ok) throw new Error('list');
|
|
129
133
|
const docs = response.docs.sort((a, b)=>(Date.parse(b.updatedAt ?? '') || 0) - (Date.parse(a.updatedAt ?? '') || 0));
|
|
130
134
|
if (!active) return;
|
|
131
|
-
const summary =
|
|
135
|
+
const [summary, pauses] = await Promise.all([
|
|
136
|
+
canReadResults ? api.summary(docs.map((doc)=>doc.id)) : undefined,
|
|
137
|
+
canManage && docs.some((doc)=>doc.status === 'paused') ? api.pausedBy(controller.signal) : undefined
|
|
138
|
+
]);
|
|
132
139
|
const summaries = summary?.ok ? summary.data ?? {} : {};
|
|
133
140
|
const ids = [
|
|
134
141
|
...new Set(docs.flatMap((doc)=>{
|
|
@@ -163,7 +170,8 @@ export function TestsHome({ adminRoute, apiRoute, contentLocale, canManage = fal
|
|
|
163
170
|
tests: docs.filter((doc)=>!deletedIds.current.has(String(doc.id))),
|
|
164
171
|
goalNames,
|
|
165
172
|
summaries,
|
|
166
|
-
summaryError: summary?.ok === false
|
|
173
|
+
summaryError: summary?.ok === false,
|
|
174
|
+
pauseAttributions: pauses?.ok ? pauses.data ?? {} : {}
|
|
167
175
|
});
|
|
168
176
|
} catch {
|
|
169
177
|
settle({
|
|
@@ -233,6 +241,7 @@ export function TestsHome({ adminRoute, apiRoute, contentLocale, canManage = fal
|
|
|
233
241
|
contentLocale,
|
|
234
242
|
canManage,
|
|
235
243
|
canReadResults,
|
|
244
|
+
timeZone,
|
|
236
245
|
isAdmin: false,
|
|
237
246
|
flagPoints: flagPoints ?? [],
|
|
238
247
|
attributeKeys: {},
|
|
@@ -308,9 +317,11 @@ export function TestsHome({ adminRoute, apiRoute, contentLocale, canManage = fal
|
|
|
308
317
|
action: newTest,
|
|
309
318
|
children: SURFACE_COPY.empty
|
|
310
319
|
}) : /*#__PURE__*/ _jsx(TestGroups, {
|
|
320
|
+
timeZone: timeZone,
|
|
311
321
|
tests: state.tests,
|
|
312
322
|
summaries: state.summaries,
|
|
313
323
|
goalNames: state.goalNames,
|
|
324
|
+
pauseAttributions: state.pauseAttributions,
|
|
314
325
|
adminRoute: adminRoute,
|
|
315
326
|
canManage: canManage,
|
|
316
327
|
canReadResults: canReadResults,
|
|
@@ -344,10 +355,10 @@ export function TestsHome({ adminRoute, apiRoute, contentLocale, canManage = fal
|
|
|
344
355
|
]
|
|
345
356
|
});
|
|
346
357
|
}
|
|
347
|
-
function TestGroups({ tests, summaries, goalNames, adminRoute, canManage, canReadResults, onSelect, flagPoints, search, clear }) {
|
|
358
|
+
function TestGroups({ tests, summaries, goalNames, pauseAttributions, adminRoute, canManage, canReadResults, onSelect, flagPoints, search, clear, timeZone }) {
|
|
348
359
|
const formatDate = useDateFormatter();
|
|
349
|
-
const now =
|
|
350
|
-
const groups = groupTests(tests, summaries, search);
|
|
360
|
+
const now = useScheduleClock(tests, timeZone);
|
|
361
|
+
const groups = groupTests(tests, summaries, search, now);
|
|
351
362
|
if (!groups.some((group)=>group.tests.length)) return /*#__PURE__*/ _jsxs("div", {
|
|
352
363
|
className: "xp-tests-no-matches",
|
|
353
364
|
children: [
|
|
@@ -374,11 +385,15 @@ function TestGroups({ tests, summaries, goalNames, adminRoute, canManage, canRea
|
|
|
374
385
|
now,
|
|
375
386
|
flagPoints,
|
|
376
387
|
goalNames,
|
|
377
|
-
canReadResults
|
|
388
|
+
canReadResults,
|
|
389
|
+
timeZone,
|
|
390
|
+
pauseAttribution: canManage ? pauseAttributions[test.id] : undefined
|
|
378
391
|
});
|
|
379
392
|
const ready = test.status === 'draft' && summary?.ready === true;
|
|
380
393
|
const actions = availableActions({
|
|
381
394
|
...test,
|
|
395
|
+
now,
|
|
396
|
+
timeZone,
|
|
382
397
|
canManage,
|
|
383
398
|
canReadResults
|
|
384
399
|
});
|
|
@@ -408,7 +423,7 @@ function TestGroups({ tests, summaries, goalNames, adminRoute, canManage, canRea
|
|
|
408
423
|
/*#__PURE__*/ _jsx("span", {
|
|
409
424
|
title: card.pill.tooltip,
|
|
410
425
|
children: /*#__PURE__*/ _jsx(StatusChip, {
|
|
411
|
-
status: ready ? 'ready' :
|
|
426
|
+
status: ready ? 'ready' : card.status
|
|
412
427
|
})
|
|
413
428
|
})
|
|
414
429
|
]
|
|
@@ -416,7 +431,7 @@ function TestGroups({ tests, summaries, goalNames, adminRoute, canManage, canRea
|
|
|
416
431
|
/*#__PURE__*/ _jsxs("div", {
|
|
417
432
|
className: "xp-tests-row-line",
|
|
418
433
|
children: [
|
|
419
|
-
|
|
434
|
+
card.status === 'running' && card.health ? /*#__PURE__*/ _jsx("span", {
|
|
420
435
|
className: `xp-tests-health xp-tests-health--${card.health}`,
|
|
421
436
|
children: SURFACE_COPY.health[card.health]
|
|
422
437
|
}) : null,
|
|
@@ -424,7 +439,11 @@ function TestGroups({ tests, summaries, goalNames, adminRoute, canManage, canRea
|
|
|
424
439
|
children: card.line
|
|
425
440
|
})
|
|
426
441
|
]
|
|
427
|
-
})
|
|
442
|
+
}),
|
|
443
|
+
card.scheduleLine ? /*#__PURE__*/ _jsx("div", {
|
|
444
|
+
className: "xp-tests-row-line",
|
|
445
|
+
children: card.scheduleLine
|
|
446
|
+
}) : null
|
|
428
447
|
]
|
|
429
448
|
}),
|
|
430
449
|
/*#__PURE__*/ _jsxs("div", {
|
|
@@ -511,6 +530,7 @@ function ListLifecycleDialog({ selection: { row, action }, surface, onClose }) {
|
|
|
511
530
|
const canOpen = !!doc && doc.status === row.status && (row.phase === undefined || doc.phase === row.phase) && availableActions({
|
|
512
531
|
...doc,
|
|
513
532
|
decision: doc.decision,
|
|
533
|
+
timeZone: surface.timeZone,
|
|
514
534
|
canManage: surface.canManage,
|
|
515
535
|
canReadResults: surface.canReadResults
|
|
516
536
|
}).some((item)=>item.id === action.id && !item.unavailable);
|
|
@@ -28,6 +28,9 @@ function SurfacePage(props) {
|
|
|
28
28
|
canReadResults: props.canReadResults,
|
|
29
29
|
isAdmin: props.isAdmin,
|
|
30
30
|
flagPoints: props.flagPoints,
|
|
31
|
+
...props.timeZone ? {
|
|
32
|
+
timeZone: props.timeZone
|
|
33
|
+
} : {},
|
|
31
34
|
attributeKeys: props.attributeKeys,
|
|
32
35
|
metricSources: props.metricSources,
|
|
33
36
|
admin: props.admin,
|
|
@@ -48,6 +51,7 @@ function SurfacePage(props) {
|
|
|
48
51
|
});
|
|
49
52
|
}
|
|
50
53
|
if (props.route === 'home') return /*#__PURE__*/ _jsx(TestsHome, {
|
|
54
|
+
timeZone: props.timeZone,
|
|
51
55
|
adminRoute: props.adminRoute,
|
|
52
56
|
apiRoute: props.apiRoute,
|
|
53
57
|
contentLocale: props.contentLocale,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Arm, DocId, ExperimentKind, Status, UnitType } from '../../types/contracts.js';
|
|
2
|
-
import type { SummaryResponse } from '../../types/endpoints.js';
|
|
2
|
+
import type { PauseAttribution, SummaryResponse } from '../../types/endpoints.js';
|
|
3
3
|
import type { DateFormatter } from '../../testSurface/format/date.js';
|
|
4
|
+
import type { TestDocument } from '../../testSurface/surface/testDocument.model.js';
|
|
4
5
|
import type { ReadinessContext } from '../../testSurface/surface/readiness/readiness.model.js';
|
|
5
6
|
import { type ActionDecision } from '../../testSurface/actions/actions.model.js';
|
|
6
|
-
export interface HomeTest {
|
|
7
|
+
export interface HomeTest extends Pick<TestDocument, 'schedule' | 'pausedAt' | 'pauseReason'> {
|
|
7
8
|
id: DocId;
|
|
8
9
|
name: string;
|
|
9
10
|
kind: ExperimentKind;
|
|
@@ -24,25 +25,29 @@ export interface HomeTest {
|
|
|
24
25
|
type Summary = SummaryResponse[DocId] | undefined;
|
|
25
26
|
export type Health = 'red' | 'amber' | 'green';
|
|
26
27
|
export declare function healthDot(test: HomeTest, summary: Summary): Health | undefined;
|
|
27
|
-
export declare function groupTests(tests: readonly HomeTest[], summaries: SummaryResponse, search?: string): {
|
|
28
|
+
export declare function groupTests(tests: readonly HomeTest[], summaries: SummaryResponse, search?: string, now?: number): {
|
|
28
29
|
key: string;
|
|
29
|
-
label: "Needs attention" | "Running" | "Stopped" | "Decided" | "Ready to start" | "Draft" | "Archived";
|
|
30
|
+
label: "Paused" | "Needs attention" | "Running" | "Stopped" | "Decided" | "Scheduled" | "Ready to start" | "Draft" | "Archived";
|
|
30
31
|
tests: HomeTest[];
|
|
31
32
|
}[];
|
|
32
|
-
export declare function homeCard(test: HomeTest, summary: Summary, adminRoute: string, { formatDate, now, flagPoints, goalNames, canReadResults, }: {
|
|
33
|
+
export declare function homeCard(test: HomeTest, summary: Summary, adminRoute: string, { formatDate, now, flagPoints, goalNames, canReadResults, timeZone, pauseAttribution, }: {
|
|
33
34
|
formatDate: DateFormatter;
|
|
34
35
|
now: number;
|
|
36
|
+
timeZone?: string;
|
|
35
37
|
flagPoints?: ReadinessContext['flagPoints'];
|
|
36
38
|
goalNames?: Readonly<Record<string, string>>;
|
|
37
39
|
canReadResults?: boolean;
|
|
40
|
+
pauseAttribution?: PauseAttribution;
|
|
38
41
|
}): {
|
|
39
42
|
kind: "Page block" | "Setting" | "Whole page";
|
|
40
43
|
pill: {
|
|
44
|
+
tooltip: string;
|
|
41
45
|
label: string;
|
|
42
46
|
tone: import("../status.model.js").PillTone;
|
|
43
|
-
tooltip: string;
|
|
44
47
|
};
|
|
48
|
+
status: "running" | "decided" | "draft" | "paused" | "stopped" | "archived" | "scheduled";
|
|
45
49
|
line: string;
|
|
50
|
+
scheduleLine: string | undefined;
|
|
46
51
|
health: Health | undefined;
|
|
47
52
|
href: string;
|
|
48
53
|
action: "Continue setup" | "View results" | "Open";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { formatAdminURL } from 'payload/shared';
|
|
2
2
|
import { roundProgress } from '../../testSurface/format/roundProgress.js';
|
|
3
|
-
import {
|
|
3
|
+
import { scheduleStatus } from '../../testSurface/format/scheduleStatus.js';
|
|
4
|
+
import { armLabel, displayStatus } from '../../testSurface/labels.js';
|
|
4
5
|
import { statusPill } from '../status.model.js';
|
|
5
6
|
import { decidedLine, runningLine, SURFACE_COPY } from '../../testSurface/copy/surface.js';
|
|
6
7
|
import { asymmetricGoalsCopy, nextCopy, READINESS_COPY } from '../../testSurface/copy/readiness.js';
|
|
@@ -9,10 +10,10 @@ import { sanitizeReadinessDetail } from '../../sanitizeReadinessDetail.js';
|
|
|
9
10
|
export function healthDot(test, summary) {
|
|
10
11
|
const code = summary?.verdict?.code;
|
|
11
12
|
if (summary?.health?.some((item)=>item.code === 'version-page-unavailable') || code === 'data-problem' || code === 'guardrail-failing') return 'red';
|
|
12
|
-
if (summary?.health?.
|
|
13
|
+
if (summary?.health?.some((item)=>item.code !== 'schedule-population') || code === 'unavailable' || code === 'collecting' && test.analysis?.plannedDurationDays != null && summary.days > test.analysis.plannedDurationDays) return 'amber';
|
|
13
14
|
return code ? 'green' : undefined;
|
|
14
15
|
}
|
|
15
|
-
export function groupTests(tests, summaries, search = '') {
|
|
16
|
+
export function groupTests(tests, summaries, search = '', now = Date.now()) {
|
|
16
17
|
const groups = new Map(Object.entries(SURFACE_COPY.groups).map(([key, label])=>[
|
|
17
18
|
key,
|
|
18
19
|
{
|
|
@@ -26,7 +27,8 @@ export function groupTests(tests, summaries, search = '') {
|
|
|
26
27
|
if (!test.name.toLocaleLowerCase('en-US').includes(query)) continue;
|
|
27
28
|
const summary = summaries[test.id];
|
|
28
29
|
const health = healthDot(test, summary);
|
|
29
|
-
const
|
|
30
|
+
const status = displayStatus(test, now);
|
|
31
|
+
const group = status === 'running' && (health === 'red' || health === 'amber') ? 'attention' : status === 'draft' && summary?.ready === true ? 'ready' : status;
|
|
30
32
|
(groups.get(group) ?? groups.get('draft')).tests.push(test);
|
|
31
33
|
}
|
|
32
34
|
return [
|
|
@@ -36,7 +38,7 @@ export function groupTests(tests, summaries, search = '') {
|
|
|
36
38
|
const number = (value)=>value != null && Number.isFinite(value) ? new Intl.NumberFormat('en-US', {
|
|
37
39
|
maximumFractionDigits: 0
|
|
38
40
|
}).format(value) : '—';
|
|
39
|
-
export function homeCard(test, summary, adminRoute, { formatDate, now, flagPoints, goalNames = {}, canReadResults = true }) {
|
|
41
|
+
export function homeCard(test, summary, adminRoute, { formatDate, now, flagPoints, goalNames = {}, canReadResults = true, timeZone, pauseAttribution }) {
|
|
40
42
|
const results = canReadResults && test.status !== 'draft';
|
|
41
43
|
const href = formatAdminURL({
|
|
42
44
|
adminRoute,
|
|
@@ -57,20 +59,29 @@ export function homeCard(test, summary, adminRoute, { formatDate, now, flagPoint
|
|
|
57
59
|
});
|
|
58
60
|
if (sentence) line = nextCopy(next.code === 'page-no-targets' ? READINESS_COPY.choosePages : sentence);
|
|
59
61
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
const timing = summary?.timing?.phase === test.phase ? summary?.timing : undefined;
|
|
63
|
+
const schedule = scheduleStatus(test, now, timing, timeZone, pauseAttribution);
|
|
64
|
+
if (schedule.status === 'running') {
|
|
65
|
+
const progress = roundProgress(test.startedAt, test.analysis?.plannedDurationDays, now, summary?.days ?? 0, timing);
|
|
62
66
|
line = runningLine(number(progress.day), number(progress.plannedDays), number(summary?.exposures));
|
|
63
67
|
}
|
|
68
|
+
if (schedule.status === 'scheduled' || schedule.status === 'paused') line = schedule.line;
|
|
64
69
|
if (test.status === 'decided') {
|
|
65
70
|
const winner = test.decision?.winnerArm;
|
|
66
71
|
const winnerLabel = test.arms?.find((arm)=>arm.key === winner)?.label?.trim();
|
|
67
72
|
line = decidedLine(formatDate(test.decidedAt), winner ? winnerLabel || armLabel(winner) : '—');
|
|
68
73
|
}
|
|
69
74
|
if (test.status === 'archived') line = statusPill(test).label;
|
|
75
|
+
const pill = statusPill(test, now);
|
|
70
76
|
return {
|
|
71
77
|
kind: SURFACE_COPY.kinds[test.kind],
|
|
72
|
-
pill:
|
|
78
|
+
pill: {
|
|
79
|
+
...pill,
|
|
80
|
+
tooltip: schedule.status === 'paused' ? line : pill.tooltip
|
|
81
|
+
},
|
|
82
|
+
status: schedule.status,
|
|
73
83
|
line,
|
|
84
|
+
scheduleLine: schedule.status === 'running' ? schedule.line : undefined,
|
|
74
85
|
health: healthDot(test, summary),
|
|
75
86
|
href,
|
|
76
87
|
action: results ? SURFACE_COPY.results : test.status !== 'draft' || summary?.ready === true ? SURFACE_COPY.open : SURFACE_COPY.continue
|
|
@@ -16,9 +16,11 @@ import { SURFACE_COPY } from '../../../testSurface/copy/surface.js';
|
|
|
16
16
|
import { pageStepCopy } from '../../../testSurface/copy/pages.js';
|
|
17
17
|
import { READINESS, nextStep, pageReadinessContext, readinessArm } from '../../../testSurface/surface/readiness/readiness.model.js';
|
|
18
18
|
import { FieldErrors } from '../../../testSurface/surface/test/fields.js';
|
|
19
|
+
import { ScheduleSection } from '../../../testSurface/surface/test/ScheduleSection.js';
|
|
20
|
+
import { useScheduleClock } from '../../../testSurface/format/useScheduleClock.js';
|
|
19
21
|
import { actionWaitMessage, SaveStatus } from '../../../testSurface/surface/readiness/SaveStatus.js';
|
|
20
22
|
import { availableActions } from '../../../testSurface/actions/actions.model.js';
|
|
21
|
-
import {
|
|
23
|
+
import { LifecycleDialog } from '../../../testSurface/actions/LifecycleAction.js';
|
|
22
24
|
import { Button } from '../../../ui/Button.js';
|
|
23
25
|
import { Banner } from '../../../ui/Feedback.js';
|
|
24
26
|
import { Select } from '../../../ui/Select.js';
|
|
@@ -33,6 +35,9 @@ import './newTest.css';
|
|
|
33
35
|
apiRoute: surface.apiRoute,
|
|
34
36
|
contentLocale: surface.contentLocale
|
|
35
37
|
});
|
|
38
|
+
const now = useScheduleClock(test.doc ? [
|
|
39
|
+
test.doc
|
|
40
|
+
] : [], surface.timeZone);
|
|
36
41
|
const testUrl = formatAdminURL({
|
|
37
42
|
adminRoute: surface.adminRoute,
|
|
38
43
|
path: `/experiments/${encodeURIComponent(String(id))}`
|
|
@@ -80,6 +85,8 @@ import './newTest.css';
|
|
|
80
85
|
const ready = readyToStart(test, surface.editorPlacementMessage);
|
|
81
86
|
const start = ready ? availableActions({
|
|
82
87
|
...doc,
|
|
88
|
+
now,
|
|
89
|
+
timeZone: surface.timeZone,
|
|
83
90
|
canManage: surface.canManage
|
|
84
91
|
}).find((action)=>action.id === 'start') : undefined;
|
|
85
92
|
const busy = test.hasUnsaved || test.saving === 'saving' || copying;
|
|
@@ -143,6 +150,10 @@ import './newTest.css';
|
|
|
143
150
|
}) : step === 'review' ? /*#__PURE__*/ _jsxs("div", {
|
|
144
151
|
className: "xp-page-wizard-review",
|
|
145
152
|
children: [
|
|
153
|
+
/*#__PURE__*/ _jsx(ScheduleSection, {
|
|
154
|
+
test: test,
|
|
155
|
+
surface: surface
|
|
156
|
+
}),
|
|
146
157
|
/*#__PURE__*/ _jsx("ul", {
|
|
147
158
|
children: test.preflight?.checks.map((check, index)=>{
|
|
148
159
|
if (!Object.hasOwn(READINESS, check.code)) return check.ok ? null : /*#__PURE__*/ _jsx("li", {
|
|
@@ -169,11 +180,10 @@ import './newTest.css';
|
|
|
169
180
|
ready ? /*#__PURE__*/ _jsx("p", {
|
|
170
181
|
children: READINESS_COPY.ready
|
|
171
182
|
}) : null,
|
|
172
|
-
confirmation ? /*#__PURE__*/ _jsx(
|
|
183
|
+
confirmation ? /*#__PURE__*/ _jsx(LifecycleDialog, {
|
|
173
184
|
test: test,
|
|
174
185
|
surface: surface,
|
|
175
186
|
action: confirmation,
|
|
176
|
-
winnerLabel: "",
|
|
177
187
|
onClose: ()=>setConfirmation(null),
|
|
178
188
|
onSuccess: leave
|
|
179
189
|
}) : null
|
|
@@ -14,8 +14,10 @@ import { createApi } from '../../../testSurface/api.js';
|
|
|
14
14
|
import { availableActions, actionGroupLabel } from '../../../testSurface/actions/actions.model.js';
|
|
15
15
|
import { LifecycleButton, LifecycleDialog } from '../../../testSurface/actions/LifecycleAction.js';
|
|
16
16
|
import { DeleteTestAction } from '../../../testSurface/surface/test/DeleteTest.js';
|
|
17
|
-
import { READINESS,
|
|
17
|
+
import { READINESS, testProgress, displayDate, blockingSteps, pageReadinessContext } from '../../../testSurface/surface/readiness/readiness.model.js';
|
|
18
18
|
import { READINESS_COPY as R, runningCopy, stoppedCopy, decidedCopy } from '../../../testSurface/copy/readiness.js';
|
|
19
|
+
import { useScheduleClock } from '../../../testSurface/format/useScheduleClock.js';
|
|
20
|
+
import { scheduleStatus } from '../../../testSurface/format/scheduleStatus.js';
|
|
19
21
|
import { useDateFormatter } from '../../../testSurface/format/useDateFormatter.js';
|
|
20
22
|
import { RESULTS_COPY as C } from '../../../testSurface/copy/results.js';
|
|
21
23
|
import { METRICS_COPY } from '../../../testSurface/copy/metrics.js';
|
|
@@ -25,17 +27,23 @@ export function ResultsHeader({ test, surface, resultsVersion, children, roundAc
|
|
|
25
27
|
const doc = test.doc;
|
|
26
28
|
const [selected, setSelected] = useState(null);
|
|
27
29
|
const [audience, setAudience] = useState();
|
|
28
|
-
const
|
|
30
|
+
const summary = audience?.phase === doc.phase ? audience?.summary : undefined;
|
|
31
|
+
const now = useScheduleClock([
|
|
32
|
+
doc
|
|
33
|
+
], surface.timeZone);
|
|
34
|
+
const timing = test.preflight?.timing ?? (summary?.timing?.phase === doc.phase ? summary?.timing : undefined);
|
|
35
|
+
const schedule = scheduleStatus(doc, now, timing, surface.timeZone, test.preflight?.pauseAttribution);
|
|
36
|
+
const progress = schedule.status === 'running' ? testProgress(doc, now, summary?.timing) : null;
|
|
29
37
|
useEffect(()=>{
|
|
30
38
|
let active = true;
|
|
31
|
-
if (surface.canReadResults &&
|
|
39
|
+
if (surface.canReadResults && (schedule.status === 'running' || schedule.status === 'paused')) {
|
|
32
40
|
void createApi(surface.apiRoute).summary([
|
|
33
41
|
doc.id
|
|
34
42
|
]).then((result)=>{
|
|
35
|
-
const
|
|
36
|
-
if (active &&
|
|
43
|
+
const next = result.ok ? result.data?.[doc.id] : undefined;
|
|
44
|
+
if (active && next && Number.isFinite(next.exposures)) setAudience({
|
|
37
45
|
phase: doc.phase,
|
|
38
|
-
|
|
46
|
+
summary: next
|
|
39
47
|
});
|
|
40
48
|
}).catch(()=>{});
|
|
41
49
|
}
|
|
@@ -44,7 +52,7 @@ export function ResultsHeader({ test, surface, resultsVersion, children, roundAc
|
|
|
44
52
|
};
|
|
45
53
|
}, [
|
|
46
54
|
doc.id,
|
|
47
|
-
|
|
55
|
+
schedule.status,
|
|
48
56
|
doc.phase,
|
|
49
57
|
surface.apiRoute,
|
|
50
58
|
surface.canReadResults,
|
|
@@ -55,6 +63,8 @@ export function ResultsHeader({ test, surface, resultsVersion, children, roundAc
|
|
|
55
63
|
const available = availableActions({
|
|
56
64
|
...doc,
|
|
57
65
|
decision,
|
|
66
|
+
now,
|
|
67
|
+
timeZone: surface.timeZone,
|
|
58
68
|
canManage: surface.canManage,
|
|
59
69
|
canReadResults: surface.canReadResults
|
|
60
70
|
});
|
|
@@ -62,7 +72,7 @@ export function ResultsHeader({ test, surface, resultsVersion, children, roundAc
|
|
|
62
72
|
const blockers = blockingSteps(test.preflight, pageReadinessContext(doc, test.preflight, surface));
|
|
63
73
|
const ready = readyToStart(test);
|
|
64
74
|
const startReason = test.preflightError ?? blockers[0]?.sentence ?? (!ready ? R.checking : undefined);
|
|
65
|
-
const sentence = test.statusReadPending ? R.checking :
|
|
75
|
+
const sentence = test.statusReadPending ? R.checking : progress ? runningCopy(displayDate(doc.startedAt, formatDate), summary?.exposures ?? null, progress.daysToGo, progress.weekendsToGo) : doc.status === 'stopped' ? stoppedCopy(displayDate(doc.stoppedAt, formatDate)) : doc.status === 'decided' ? decidedCopy(displayDate(doc.decidedAt, formatDate), winner) : doc.status === 'archived' ? R.archived : null;
|
|
66
76
|
const testURL = formatAdminURL({
|
|
67
77
|
adminRoute: surface.adminRoute,
|
|
68
78
|
path: `/experiments/${encodeURIComponent(String(doc.id))}`
|
|
@@ -107,7 +117,7 @@ export function ResultsHeader({ test, surface, resultsVersion, children, roundAc
|
|
|
107
117
|
children: TEST_PAGE.kinds[doc.kind]
|
|
108
118
|
}),
|
|
109
119
|
!test.statusReadPending ? /*#__PURE__*/ _jsx(StatusChip, {
|
|
110
|
-
status:
|
|
120
|
+
status: schedule.status
|
|
111
121
|
}) : null
|
|
112
122
|
]
|
|
113
123
|
}),
|
|
@@ -117,6 +127,10 @@ export function ResultsHeader({ test, surface, resultsVersion, children, roundAc
|
|
|
117
127
|
role: "status",
|
|
118
128
|
children: sentence
|
|
119
129
|
}) : null,
|
|
130
|
+
!test.statusReadPending && schedule.line ? /*#__PURE__*/ _jsx("p", {
|
|
131
|
+
role: "status",
|
|
132
|
+
children: schedule.line
|
|
133
|
+
}) : null,
|
|
120
134
|
released,
|
|
121
135
|
surface.canManage ? test.preflight?.checks.filter((check)=>check.code === 'make-content-unsupported' && check.warning).map((check, index)=>/*#__PURE__*/ _jsx(Banner, {
|
|
122
136
|
tone: "warning",
|
|
@@ -181,6 +195,19 @@ export function ResultsHeader({ test, surface, resultsVersion, children, roundAc
|
|
|
181
195
|
export function ReaderResultsShell({ surface, children, data }) {
|
|
182
196
|
// CORE-48 sends a missing name as an empty string.
|
|
183
197
|
const title = data?.experiment?.name?.trim() || C.test;
|
|
198
|
+
const phase = data?.phases.at(-1);
|
|
199
|
+
const doc = data?.experiment ? {
|
|
200
|
+
status: data.experiment.status,
|
|
201
|
+
startedAt: phase?.startedAt,
|
|
202
|
+
schedule: phase?.schedule,
|
|
203
|
+
analysis: {
|
|
204
|
+
plannedDurationDays: phase?.plannedDurationDays
|
|
205
|
+
}
|
|
206
|
+
} : undefined;
|
|
207
|
+
const now = useScheduleClock(doc ? [
|
|
208
|
+
doc
|
|
209
|
+
] : [], surface.timeZone);
|
|
210
|
+
const schedule = doc ? scheduleStatus(doc, now, phase, surface.timeZone) : undefined;
|
|
184
211
|
const crumbs = [
|
|
185
212
|
{
|
|
186
213
|
label: C.tests,
|
|
@@ -203,6 +230,13 @@ export function ReaderResultsShell({ surface, children, data }) {
|
|
|
203
230
|
label,
|
|
204
231
|
href: url
|
|
205
232
|
})),
|
|
233
|
+
status: schedule ? /*#__PURE__*/ _jsx(StatusChip, {
|
|
234
|
+
status: schedule.status
|
|
235
|
+
}) : undefined,
|
|
236
|
+
subtitle: schedule?.line ? /*#__PURE__*/ _jsx("p", {
|
|
237
|
+
role: "status",
|
|
238
|
+
children: schedule.line
|
|
239
|
+
}) : undefined,
|
|
206
240
|
children: children
|
|
207
241
|
});
|
|
208
242
|
}
|