@delmaredigital/payload-experiments 0.4.0-rc.7 → 0.4.0-rc.9
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 +12 -12
- package/dist/admin/blocks/model.js +2 -2
- package/dist/admin/copy/blocks.js +1 -1
- package/dist/admin/surface/ResultsRoute.js +17 -11
- package/dist/admin/surface/TestsHome.js +53 -20
- package/dist/admin/surface/newTest/PageWizard.js +8 -2
- package/dist/admin/surface/results/ResultsHeader.js +11 -6
- package/dist/admin/surface/test/TestPage.js +3 -3
- package/dist/blocks/formState.js +1 -1
- package/dist/collections/experiments/config.js +8 -3
- package/dist/collections/experiments/deleteGuard.js +2 -2
- package/dist/collections/experiments/lockHook.js +21 -2
- package/dist/collections/experiments/pickSlug.js +2 -0
- package/dist/collections/metricsGuards.js +2 -0
- package/dist/collections/serialize.js +5 -4
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/db/adapter.d.ts +9 -1
- package/dist/db/adapter.js +77 -1
- package/dist/db/delete.d.ts +1 -1
- package/dist/db/delete.js +2 -4
- package/dist/db/events.d.ts +9 -0
- package/dist/db/events.js +42 -8
- package/dist/db/executor.d.ts +7 -1
- package/dist/db/executor.js +7 -3
- package/dist/db/results.d.ts +5 -1
- package/dist/db/results.js +21 -5
- package/dist/db/snapshots.d.ts +1 -0
- package/dist/endpoints/deleteImpact.js +2 -1
- package/dist/endpoints/events.js +103 -39
- package/dist/endpoints/index.js +2 -8
- package/dist/endpoints/placementStatus.js +7 -4
- package/dist/endpoints/results.d.ts +1 -1
- package/dist/endpoints/results.js +6 -2
- package/dist/endpoints/routeId.d.ts +2 -2
- package/dist/endpoints/routeId.js +11 -5
- package/dist/endpoints/summary.js +46 -12
- package/dist/endpoints/transitions.js +37 -24
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +6 -0
- package/dist/events/request.d.ts +6 -2
- package/dist/events/request.js +35 -8
- package/dist/events/rows.d.ts +1 -1
- package/dist/events/rows.js +24 -8
- package/dist/events/writable.d.ts +9 -0
- package/dist/events/writable.js +13 -0
- package/dist/exports/index.d.ts +1 -1
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.js +1 -0
- package/dist/goals/fairness.js +2 -2
- package/dist/hooks/hostHook.js +6 -2
- package/dist/hooks/pageGuard.js +4 -0
- package/dist/lib/fetchAllDocs.d.ts +1 -1
- package/dist/manifest/compile.js +8 -5
- package/dist/onInit.js +14 -0
- package/dist/options.js +5 -0
- package/dist/proxy/pageNavigation.d.ts +4 -0
- package/dist/proxy/pageNavigation.js +28 -0
- package/dist/proxy/resolve.js +52 -25
- package/dist/puck/editor/ConfigureTestDrawer.js +5 -4
- package/dist/puck/editor/ExperimentSlotEditor.js +182 -58
- package/dist/puck/editor/QuickTestActions.d.ts +5 -2
- package/dist/puck/editor/QuickTestActions.js +16 -4
- package/dist/puck/editor/ResultsReadout.d.ts +2 -1
- package/dist/puck/editor/ResultsReadout.js +2 -1
- package/dist/puck/editor/VersionBuilder.d.ts +13 -2
- package/dist/puck/editor/VersionBuilder.js +133 -49
- package/dist/puck/editor/armWrites.js +1 -1
- package/dist/puck/editor/armsCache.js +1 -3
- package/dist/puck/editor/copy.d.ts +4 -1
- package/dist/puck/editor/copy.js +4 -1
- package/dist/puck/editor/editor.chrome.css +1 -0
- package/dist/puck/editor/editor.css +1 -0
- package/dist/puck/editor/editor.model.d.ts +1 -0
- package/dist/puck/editor/placementsCache.d.ts +5 -1
- package/dist/puck/editor/placementsCache.js +17 -9
- package/dist/puck/editor/usePageSaveReadiness.d.ts +9 -0
- package/dist/puck/editor/usePageSaveReadiness.js +34 -0
- package/dist/puck/editor/usePlacementNotice.d.ts +2 -2
- package/dist/puck/editor/usePlacementNotice.js +5 -4
- package/dist/results/aggregate.d.ts +6 -3
- package/dist/results/aggregate.js +9 -9
- package/dist/results/health.d.ts +8 -0
- package/dist/results/health.js +28 -0
- package/dist/results/identityCredit.d.ts +1 -0
- package/dist/results/identityCredit.js +4 -1
- package/dist/results/verdict.js +2 -1
- package/dist/runtime/cookie.d.ts +10 -2
- package/dist/runtime/cookie.js +38 -6
- package/dist/runtime/cookieOptions.d.ts +6 -0
- package/dist/runtime/cookieOptions.js +14 -0
- package/dist/runtime/proxyRuntime.d.ts +1 -0
- package/dist/runtime/proxyRuntime.js +18 -8
- package/dist/runtime/signing.d.ts +1 -0
- package/dist/runtime/signing.js +5 -0
- package/dist/sanitizeReadinessDetail.d.ts +2 -2
- package/dist/sanitizeReadinessDetail.js +20 -2
- package/dist/server/getAssignments.js +11 -10
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +11 -2
- package/dist/server/resolveExperimentBlocks.js +2 -4
- package/dist/server/resolveExperimentData.js +2 -5
- package/dist/server/runResults.js +52 -14
- package/dist/server/startExperiment.d.ts +20 -0
- package/dist/server/startExperiment.js +70 -0
- package/dist/server/trackConversion.js +10 -13
- package/dist/testSurface/actions/DecideDialog.d.ts +4 -1
- package/dist/testSurface/actions/DecideDialog.js +32 -14
- package/dist/testSurface/actions/MakeContentResult.d.ts +4 -3
- package/dist/testSurface/actions/MakeContentResult.js +9 -1
- package/dist/testSurface/api.d.ts +5 -5
- package/dist/testSurface/api.js +21 -9
- package/dist/testSurface/copy/actions.d.ts +1 -0
- package/dist/testSurface/copy/actions.js +1 -0
- package/dist/testSurface/copy/common.d.ts +3 -1
- package/dist/testSurface/copy/common.js +4 -2
- package/dist/testSurface/copy/languages.d.ts +1 -0
- package/dist/testSurface/copy/languages.js +1 -0
- package/dist/testSurface/copy/metrics.d.ts +1 -0
- package/dist/testSurface/copy/metrics.js +1 -0
- package/dist/testSurface/copy/readiness.d.ts +12 -1
- package/dist/testSurface/copy/readiness.js +18 -1
- package/dist/testSurface/copy/results.d.ts +5 -2
- package/dist/testSurface/copy/results.js +5 -2
- package/dist/testSurface/copy/testPage.d.ts +20 -2
- package/dist/testSurface/copy/testPage.js +34 -3
- package/dist/testSurface/readPreflight.d.ts +5 -0
- package/dist/testSurface/readPreflight.js +7 -0
- package/dist/testSurface/readinessRead.d.ts +3 -0
- package/dist/testSurface/readinessRead.js +4 -0
- package/dist/testSurface/results/VerdictHero.d.ts +2 -1
- package/dist/testSurface/results/VerdictHero.js +5 -1
- package/dist/testSurface/results/results.model.d.ts +1 -1
- package/dist/testSurface/results/results.model.js +6 -2
- package/dist/testSurface/surface/contracts.d.ts +8 -1
- package/dist/testSurface/surface/editorPlacement.d.ts +2 -2
- package/dist/testSurface/surface/editorPlacement.js +1 -1
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +2 -2
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +20 -6
- package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +4 -2
- package/dist/testSurface/surface/readiness/ActionDialogs.js +39 -34
- package/dist/testSurface/surface/readiness/Banner.js +23 -12
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +4 -3
- package/dist/testSurface/surface/readiness/SaveStatus.js +15 -15
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +6 -1
- package/dist/testSurface/surface/readiness/readiness.model.js +108 -11
- package/dist/testSurface/surface/readiness/useTransition.d.ts +4 -4
- package/dist/testSurface/surface/readiness/useTransition.js +12 -10
- package/dist/testSurface/surface/results/ReleasePages.d.ts +4 -2
- package/dist/testSurface/surface/results/ReleasePages.js +5 -4
- package/dist/testSurface/surface/results/ResultsBody.d.ts +4 -2
- package/dist/testSurface/surface/results/ResultsBody.js +86 -43
- package/dist/testSurface/surface/results/useResults.d.ts +7 -6
- package/dist/testSurface/surface/results/useResults.js +3 -2
- package/dist/testSurface/surface/setting/parts.js +58 -18
- package/dist/testSurface/surface/test/AdvancedSection.js +1 -0
- package/dist/testSurface/surface/test/DeleteTest.d.ts +6 -2
- package/dist/testSurface/surface/test/DeleteTest.js +145 -54
- package/dist/testSurface/surface/test/GoalSection.js +7 -3
- package/dist/testSurface/surface/test/LengthSection.js +3 -0
- package/dist/testSurface/surface/test/PageHoldout.js +4 -1
- package/dist/testSurface/surface/test/ReadinessBar.js +1 -1
- package/dist/testSurface/surface/test/TargetingSection.js +77 -12
- package/dist/testSurface/surface/test/TestSurface.js +81 -19
- package/dist/testSurface/surface/test/VersionsSection.js +56 -29
- package/dist/testSurface/surface/test/fields.d.ts +29 -4
- package/dist/testSurface/surface/test/fields.js +159 -39
- package/dist/testSurface/surface/test/pageParts.js +14 -5
- package/dist/testSurface/surface/test/testPage.model.d.ts +1 -0
- package/dist/testSurface/surface/test/testPage.model.js +6 -0
- package/dist/testSurface/surface/testDocument.model.d.ts +3 -0
- package/dist/testSurface/surface/testDocument.model.js +4 -1
- package/dist/testSurface/surface/useTestDocument.d.ts +22 -4
- package/dist/testSurface/surface/useTestDocument.js +407 -160
- package/dist/testSurface/useApi.d.ts +5 -5
- package/dist/testSurface/useOnTestReturn.d.ts +2 -0
- package/dist/testSurface/useOnTestReturn.js +27 -0
- package/dist/testSurface/useReadinessPolling.js +3 -1
- package/dist/transitions/addMetric.d.ts +1 -4
- package/dist/transitions/allocate.d.ts +2 -2
- package/dist/transitions/allocate.js +3 -1
- package/dist/transitions/archive.d.ts +1 -1
- package/dist/transitions/archive.js +3 -2
- package/dist/transitions/checkStart.d.ts +1 -0
- package/dist/transitions/checkStart.js +17 -6
- package/dist/transitions/decide.d.ts +1 -1
- package/dist/transitions/decide.js +5 -3
- package/dist/transitions/deleteExperiment.d.ts +2 -2
- package/dist/transitions/deleteExperiment.js +17 -7
- package/dist/transitions/kernel.d.ts +2 -0
- package/dist/transitions/kernel.js +9 -4
- package/dist/transitions/makeContent.d.ts +2 -1
- package/dist/transitions/makeContent.js +12 -8
- package/dist/transitions/nestedPlacementNames.d.ts +2 -2
- package/dist/transitions/nestedPlacementNames.js +4 -5
- package/dist/transitions/phaseRecord.d.ts +2 -0
- package/dist/transitions/phaseRecord.js +5 -0
- package/dist/transitions/placementInteractions.d.ts +3 -3
- package/dist/transitions/placementInteractions.js +8 -7
- package/dist/transitions/placements.d.ts +2 -0
- package/dist/transitions/placements.js +5 -5
- package/dist/transitions/preflightData.d.ts +3 -2
- package/dist/transitions/preflightData.js +67 -41
- package/dist/transitions/releaseHoldout.d.ts +2 -1
- package/dist/transitions/releaseHoldout.js +3 -1
- package/dist/transitions/releasePages.d.ts +2 -1
- package/dist/transitions/releasePages.js +3 -1
- package/dist/transitions/resolveCaps.d.ts +2 -4
- package/dist/transitions/start.d.ts +6 -8
- package/dist/transitions/start.js +67 -34
- package/dist/transitions/startReads.d.ts +7 -0
- package/dist/transitions/startReads.js +28 -0
- package/dist/transitions/stop.d.ts +2 -1
- package/dist/transitions/stop.js +3 -2
- package/dist/types/contracts.d.ts +6 -3
- package/dist/types/endpoints.d.ts +52 -9
- package/dist/types/runtime.d.ts +15 -9
- package/dist/types/snapshot.d.ts +2 -0
- package/dist/ui/ChipsInput.d.ts +8 -1
- package/dist/ui/ChipsInput.js +17 -4
- package/package.json +2 -2
package/dist/options.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { validateAccent } from './ui/accent.js';
|
|
2
2
|
import { DEFAULT_MAX_BODY_BYTES } from './constants.js';
|
|
3
|
+
import { publicEventOrigin } from './events/request.js';
|
|
3
4
|
const normalisedCollections = new WeakMap();
|
|
4
5
|
/** Resolve once per registration list; every consumer shares the same field defaults. */ export function puckCollections(options) {
|
|
5
6
|
const entries = options.puck?.collections;
|
|
@@ -19,6 +20,8 @@ const normalisedCollections = new WeakMap();
|
|
|
19
20
|
}
|
|
20
21
|
export function resolveOptions(input) {
|
|
21
22
|
if (typeof input?.access?.manage !== 'function') throw new Error('Experiments access.manage must be a function');
|
|
23
|
+
const origin = publicEventOrigin(input.events?.origin);
|
|
24
|
+
if (input.events?.origin !== undefined && !origin) throw new Error('Experiments events.origin must be a public HTTP(S) origin with no path, query or credentials');
|
|
22
25
|
const { manage, admin = manage, readResults = manage, readIdentities = admin } = input.access;
|
|
23
26
|
for (const [name, access] of Object.entries({
|
|
24
27
|
admin,
|
|
@@ -163,6 +166,8 @@ export function resolveOptions(input) {
|
|
|
163
166
|
])),
|
|
164
167
|
events: {
|
|
165
168
|
...input.events,
|
|
169
|
+
origin,
|
|
170
|
+
rateLimit: input.events?.rateLimit,
|
|
166
171
|
retentionDays,
|
|
167
172
|
maxBodyBytes,
|
|
168
173
|
dimensions: Array.isArray(dimensions) ? [
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NextRequest } from 'next/server';
|
|
2
|
+
/** A document or an App Router navigation can mint the cookie for its own render. */
|
|
3
|
+
export declare function isPageNavigation({ method, headers }: NextRequest): boolean;
|
|
4
|
+
export declare function looksLikeNormalizedAppRouterRequest({ method, headers }: NextRequest): boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** A document or an App Router navigation can mint the cookie for its own render. */ export function isPageNavigation({ method, headers }) {
|
|
2
|
+
if (method !== 'GET') return false;
|
|
3
|
+
if (headers.has('x-nextjs-data') || headers.has('next-router-prefetch') || headers.has('next-router-segment-prefetch') || headers.has('x-middleware-prefetch') || headers.has('next-hmr-refresh') || headers.get('next-test-fetch-priority') === 'low' || [
|
|
4
|
+
'purpose',
|
|
5
|
+
'sec-purpose',
|
|
6
|
+
'x-moz'
|
|
7
|
+
].some((name)=>/\b(?:prefetch|prerender)\b/i.test(headers.get(name) ?? ''))) return false;
|
|
8
|
+
const mode = headers.get('sec-fetch-mode');
|
|
9
|
+
const destination = headers.get('sec-fetch-dest');
|
|
10
|
+
if (headers.has('rsc')) {
|
|
11
|
+
// Next sends the router state on navigation and refresh. Explicit full prefetch can
|
|
12
|
+
// share this shape, so hosts must avoid full prefetch on routes covered by the proxy.
|
|
13
|
+
const site = headers.get('sec-fetch-site');
|
|
14
|
+
return headers.get('rsc') === '1' && Boolean(headers.get('next-router-state-tree')) && (mode === null || mode === 'cors' || mode === 'same-origin') && (destination === null || destination === 'empty') && (site === null || site === 'same-origin');
|
|
15
|
+
}
|
|
16
|
+
if (mode !== null && mode !== 'navigate') return false;
|
|
17
|
+
if (destination !== null) return destination === 'document';
|
|
18
|
+
// Older browsers still advertise HTML for a document navigation.
|
|
19
|
+
return (headers.get('accept') ?? '').split(',').some((value)=>{
|
|
20
|
+
const [type, ...params] = value.trim().toLowerCase().split(';');
|
|
21
|
+
return (type === 'text/html' || type === 'application/xhtml+xml') && !params.some((param)=>/^\s*q\s*=\s*0(?:\.0*)?\s*$/.test(param));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export function looksLikeNormalizedAppRouterRequest({ method, headers }) {
|
|
25
|
+
// Next-Url survives normalization when the App Router sends it for interception.
|
|
26
|
+
// Fetch Metadata and Accept alone also match ordinary same-origin fetches.
|
|
27
|
+
return method === 'GET' && !headers.has('rsc') && headers.get('next-url')?.startsWith('/') === true && headers.get('accept') === '*/*' && headers.get('sec-fetch-mode') === 'cors' && headers.get('sec-fetch-dest') === 'empty' && headers.get('sec-fetch-site') === 'same-origin';
|
|
28
|
+
}
|
package/dist/proxy/resolve.js
CHANGED
|
@@ -4,14 +4,17 @@ import { assign, fillFlagPoints } from '../runtime/assign.js';
|
|
|
4
4
|
import { sign } from '../runtime/signing.js';
|
|
5
5
|
import { requestAttributes } from '../runtime/normalisePath.js';
|
|
6
6
|
import { isBot } from '../runtime/bot.js';
|
|
7
|
-
import { cookieAttributes, encodeUnitCookie, mintUnitId,
|
|
7
|
+
import { cookieAttributes, encodeUnitCookie, mintUnitId, readSignedUnit, unitCookieMaxAgeMs } from '../runtime/cookie.js';
|
|
8
8
|
import { encodeAssignmentsHeader } from '../runtime/header.js';
|
|
9
9
|
import { verifyPreviewToken } from '../runtime/previewToken.js';
|
|
10
10
|
import { pageRewrite } from './pageRewrite.js';
|
|
11
11
|
import { skipPath } from './skip.js';
|
|
12
12
|
import { controlAssignments, emptyAssignments } from './control.js';
|
|
13
13
|
import { consentFallback } from './consentFallback.js';
|
|
14
|
+
import { isPageNavigation, looksLikeNormalizedAppRouterRequest } from './pageNavigation.js';
|
|
15
|
+
import { assertCookieOptions } from '../runtime/cookieOptions.js';
|
|
14
16
|
const caches = new WeakMap();
|
|
17
|
+
let warnedAboutUrlNormalization = false;
|
|
15
18
|
export async function resolveExperiments(request, proxyRuntime) {
|
|
16
19
|
const requestHeaders = new Headers(request.headers);
|
|
17
20
|
const result = {
|
|
@@ -23,38 +26,62 @@ export async function resolveExperiments(request, proxyRuntime) {
|
|
|
23
26
|
...requestHeaders.keys()
|
|
24
27
|
])if (name.startsWith('x-xp-')) requestHeaders.delete(name);
|
|
25
28
|
if (skipPath(request.nextUrl.pathname, proxyRuntime.apiRoute)) return result;
|
|
29
|
+
assertCookieOptions(proxyRuntime.cookie);
|
|
30
|
+
const name = proxyRuntime.cookie.name;
|
|
31
|
+
if (!warnedAboutUrlNormalization && !request.cookies.has(name) && looksLikeNormalizedAppRouterRequest(request)) {
|
|
32
|
+
warnedAboutUrlNormalization = true;
|
|
33
|
+
console.warn('[payload-experiments] Next.js may be stripping App Router headers. Set skipProxyUrlNormalize: true in your Next.js config. Without it, visitors who follow in-site links or continue after consent without a full page load wait until their next full page load to enroll in tests.');
|
|
34
|
+
}
|
|
35
|
+
const bot = isBot(request.headers.get('user-agent'));
|
|
26
36
|
let consent = false;
|
|
27
37
|
try {
|
|
28
38
|
consent = proxyRuntime.cookie.consent?.(request) !== false;
|
|
29
39
|
} catch {
|
|
30
40
|
console.error('[payload-experiments] consent failed; treating consent as false');
|
|
31
41
|
}
|
|
32
|
-
const
|
|
42
|
+
const nowMs = Date.now();
|
|
43
|
+
const signedUnit = consent ? readSignedUnit(request, proxyRuntime, nowMs) : null;
|
|
44
|
+
let visitorId = signedUnit?.unitId;
|
|
45
|
+
let cookieValue;
|
|
46
|
+
if (consent && !signedUnit && !bot && isPageNavigation(request)) {
|
|
47
|
+
try {
|
|
48
|
+
const limit = proxyRuntime.rateLimitUnit;
|
|
49
|
+
if (limit === false || await limit?.(request) === true) {
|
|
50
|
+
const id = mintUnitId();
|
|
51
|
+
cookieValue = encodeUnitCookie(id, proxyRuntime.secrets);
|
|
52
|
+
visitorId = id;
|
|
53
|
+
}
|
|
54
|
+
} catch {
|
|
55
|
+
console.error('[payload-experiments] visitor ID issuance failed');
|
|
56
|
+
}
|
|
57
|
+
} else if (signedUnit && (signedUnit.renewedAtMs === null || nowMs - signedUnit.renewedAtMs >= unitCookieMaxAgeMs(proxyRuntime) / 2)) {
|
|
58
|
+
cookieValue = encodeUnitCookie(signedUnit.unitId, proxyRuntime.secrets, signedUnit.issuedAtMs, nowMs);
|
|
59
|
+
}
|
|
60
|
+
// Consent applies to both unit types. Issuance only controls the visitor ID.
|
|
61
|
+
// Keep Next's Flight cache key out of the signed context and preserve the app's raw query.
|
|
62
|
+
const query = request.nextUrl.search.slice(1).split('&').filter((part)=>part !== '_rsc' && !part.startsWith('_rsc=')).join('&');
|
|
63
|
+
const requestPath = query ? `${request.nextUrl.pathname}?${query}` : request.nextUrl.pathname;
|
|
64
|
+
const requestContext = `${request.method}|${requestPath}|${consent ? 'c1' : 'c0'}`;
|
|
33
65
|
const signedContext = `${requestContext}|${sign(`xp:request:${requestContext}`, proxyRuntime.secrets)}`;
|
|
34
66
|
if (Buffer.byteLength(signedContext) <= 2048) requestHeaders.set(XP_REQUEST_HEADER, signedContext);
|
|
35
|
-
|
|
36
|
-
let visitorId = consent ? verifyUnitCookie(request.cookies.get(name)?.value, proxyRuntime.secrets) ?? undefined : undefined;
|
|
37
|
-
if (!consent) {
|
|
67
|
+
if (!visitorId || cookieValue) {
|
|
38
68
|
const cookies = (requestHeaders.get('cookie') ?? '').split(';').map((cookie)=>cookie.trim()).filter((cookie)=>cookie && cookie.split('=', 1)[0]?.trim() !== name);
|
|
69
|
+
if (cookieValue) {
|
|
70
|
+
result.requestCookies.push({
|
|
71
|
+
name,
|
|
72
|
+
value: cookieValue
|
|
73
|
+
});
|
|
74
|
+
result.setCookies.push({
|
|
75
|
+
name,
|
|
76
|
+
value: cookieValue,
|
|
77
|
+
...cookieAttributes(proxyRuntime, {
|
|
78
|
+
https: request.nextUrl.protocol === 'https:'
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
cookies.push(`${name}=${cookieValue}`);
|
|
82
|
+
}
|
|
39
83
|
if (cookies.length) requestHeaders.set('cookie', cookies.join('; '));
|
|
40
84
|
else requestHeaders.delete('cookie');
|
|
41
|
-
} else if (!visitorId) {
|
|
42
|
-
visitorId = mintUnitId();
|
|
43
|
-
const value = encodeUnitCookie(visitorId, proxyRuntime.secrets);
|
|
44
|
-
result.requestCookies.push({
|
|
45
|
-
name,
|
|
46
|
-
value
|
|
47
|
-
});
|
|
48
|
-
result.setCookies.push({
|
|
49
|
-
name,
|
|
50
|
-
value,
|
|
51
|
-
...cookieAttributes(proxyRuntime, {
|
|
52
|
-
https: request.nextUrl.protocol === 'https:'
|
|
53
|
-
})
|
|
54
|
-
});
|
|
55
|
-
const cookies = (request.headers.get('cookie') ?? '').split(';').map((cookie)=>cookie.trim()).filter((cookie)=>cookie && cookie.split('=', 1)[0] !== name);
|
|
56
|
-
cookies.push(`${name}=${value}`);
|
|
57
|
-
requestHeaders.set('cookie', cookies.join('; '));
|
|
58
85
|
}
|
|
59
86
|
let resolvedUnit = {
|
|
60
87
|
attributes: {}
|
|
@@ -92,7 +119,7 @@ export async function resolveExperiments(request, proxyRuntime) {
|
|
|
92
119
|
visitorId,
|
|
93
120
|
userId,
|
|
94
121
|
staff: attributes.staff === true,
|
|
95
|
-
bot
|
|
122
|
+
bot,
|
|
96
123
|
preview: Boolean(previewExperiment),
|
|
97
124
|
sessionUnknown: sessionUnknown ?? false,
|
|
98
125
|
method: request.method
|
|
@@ -103,7 +130,7 @@ export async function resolveExperiments(request, proxyRuntime) {
|
|
|
103
130
|
try {
|
|
104
131
|
assignments = consentFallback(currentManifest, attributes, context);
|
|
105
132
|
} catch {
|
|
106
|
-
console.error('[payload-experiments]
|
|
133
|
+
console.error('[payload-experiments] identity-free fallback failed; serving non-exposable control');
|
|
107
134
|
assignmentFailed = true;
|
|
108
135
|
try {
|
|
109
136
|
assignments = controlAssignments(currentManifest, context);
|
|
@@ -132,7 +159,7 @@ export async function resolveExperiments(request, proxyRuntime) {
|
|
|
132
159
|
}
|
|
133
160
|
}
|
|
134
161
|
if (previewExperiment && token) {
|
|
135
|
-
if (
|
|
162
|
+
if (visitorId && !assignmentFailed) {
|
|
136
163
|
assignments.deferred = assignments.deferred.filter((slug)=>slug !== previewExperiment.slug);
|
|
137
164
|
assignments.bySlug[previewExperiment.slug] = {
|
|
138
165
|
slug: previewExperiment.slug,
|
|
@@ -24,8 +24,7 @@ export function ConfigureTestDrawer({ id, routes, onClose }) {
|
|
|
24
24
|
surface: {
|
|
25
25
|
...result.surface,
|
|
26
26
|
adminRoute: routes.admin,
|
|
27
|
-
apiRoute: routes.api
|
|
28
|
-
contentLocale: routes.contentLocale
|
|
27
|
+
apiRoute: routes.api
|
|
29
28
|
}
|
|
30
29
|
} : result);
|
|
31
30
|
});
|
|
@@ -35,7 +34,6 @@ export function ConfigureTestDrawer({ id, routes, onClose }) {
|
|
|
35
34
|
}, [
|
|
36
35
|
routes.api,
|
|
37
36
|
routes.admin,
|
|
38
|
-
routes.contentLocale,
|
|
39
37
|
attempt
|
|
40
38
|
]);
|
|
41
39
|
// Unknown permissions use the test page's authoritative admin access check.
|
|
@@ -65,7 +63,10 @@ export function ConfigureTestDrawer({ id, routes, onClose }) {
|
|
|
65
63
|
},
|
|
66
64
|
children: state.surface ? /*#__PURE__*/ _jsx(TestSurface, {
|
|
67
65
|
id: id,
|
|
68
|
-
surface:
|
|
66
|
+
surface: {
|
|
67
|
+
...state.surface,
|
|
68
|
+
contentLocale: routes.contentLocale
|
|
69
|
+
},
|
|
69
70
|
embedded: true,
|
|
70
71
|
onTitleChange: setTitle,
|
|
71
72
|
onDocument: (doc)=>publishExperiment(id, doc),
|