flags merge pending: the flags slot (wave-p2-railyard PY2.1) is not on main, so experiments/_slot/flags-slot.ts carries a copy of its FlagEnv and Flag types and the setFlag contract, answers no slot until the merge (the one-block switch is written in the file), and is tested with an in-memory fixture of that contract: one setFlag call per start or stop, the service then reads the flag back as live. - _lib/a3-client.ts: every A3 endpoint through A1's paFetch, and the pure form mappings (tested). - Screens (one primary action each, no emoji, copy denylist clean): recordings (by person, event id or funnel drop-off; the player embedded from the signed 10-minute link; settings), click maps (overlay from a signed link, scroll depth bars), surveys (list, new, results, start and stop), experiments (list, new, results with the sample-ratio warning, start and stop), exports (destinations, signing secret shown once from a short-lived path cookie, runs, pause, resume, retry, test, delete; saved insight CSV download). - Recordings and click maps wait for RAILYARD_REPLAY_LIVE, experiments for RAILYARD_FLAGS_LIVE (the copy denylist's own switches); until then those screens say they are arriving, name nothing else, and their actions refuse. Segments stay the console's word for cohorts. - Uses A1's Shell and http helpers and A2's insights client read-only; no console dependency, manifest or lib change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
2.6 KiB
TypeScript
71 lines
2.6 KiB
TypeScript
import { a3Context, appQuery } from "../replay/_parts/context.ts";
|
|
import { A3Shell, fmt, NO_APP, NOT_CONNECTED, Notice, Problem } from "../replay/_parts/A3Shell.tsx";
|
|
import { problemText, type Survey } from "../_lib/a3-client.ts";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
const STATUS: Record<Survey["status"], string> = { draft: "Draft", running: "Showing", stopped: "Stopped" };
|
|
|
|
// Surveys of one app. One action: create a survey.
|
|
export default async function SurveysPage({ searchParams }: { searchParams: { app?: string } }) {
|
|
const ctx = await a3Context(searchParams.app);
|
|
const q = appQuery(ctx.app);
|
|
let surveys: Survey[] = [];
|
|
let max = 0;
|
|
let problem: string | null = null;
|
|
if (ctx.api) {
|
|
try {
|
|
const r = await ctx.api.surveys();
|
|
surveys = r.surveys;
|
|
max = r.max_running;
|
|
} catch (e) {
|
|
problem = problemText(e);
|
|
}
|
|
}
|
|
const target = (s: Survey) => (s.url ? `pages matching ${s.url}` : s.flag_key ? `people with the ${s.flag_key} flag on` : s.cohort_id ? "a segment" : "everyone");
|
|
return (
|
|
<A3Shell title="Surveys" names={ctx.names} app={ctx.app?.name ?? null} current="/product-analytics/surveys">
|
|
{!ctx.app ? <Notice text={NO_APP} /> : !ctx.api ? <Notice text={NOT_CONNECTED} /> : null}
|
|
{ctx.api ? (
|
|
<section className="card">
|
|
<p>
|
|
<a className="primary" href={`/product-analytics/surveys/new?${q}`}>
|
|
Create a survey
|
|
</a>
|
|
</p>
|
|
<p className="muted" data-copy-source="product-analytics src/surveys/store.ts MAX_RUNNING">
|
|
Surveys show in the web and mobile apps that use this app's analytics setup; answers arrive as events. Up to {max} surveys show at once.
|
|
</p>
|
|
<Problem text={problem} />
|
|
{surveys.length ? (
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Survey</th>
|
|
<th>Status</th>
|
|
<th>Shown to</th>
|
|
<th>Created</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody data-copy-source="product-analytics /surveys (live)">
|
|
{surveys.map((s) => (
|
|
<tr key={s.id}>
|
|
<td>
|
|
<a href={`/product-analytics/surveys/${s.id}?${q}`}>{s.name}</a>
|
|
</td>
|
|
<td>{STATUS[s.status]}</td>
|
|
<td>{target(s)}</td>
|
|
<td>{fmt(s.created_at)}</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
) : (
|
|
<p className="muted">No surveys yet.</p>
|
|
)}
|
|
</section>
|
|
) : null}
|
|
</A3Shell>
|
|
);
|
|
}
|