feat: instrument PostHog analytics for the onboarding funnel (#1547)

* feat: instrument PostHog analytics for the onboarding funnel

* test: de-flake onboarding layout probe and profile activation
This commit is contained in:
Hiep Le
2026-07-02 22:26:39 +07:00
committed by GitHub
parent c7c4166a2b
commit b6727865b7
5 changed files with 323 additions and 4 deletions
+5 -1
View File
@@ -560,8 +560,12 @@ export async function activateProfileViaUI(page: Page, profileName: string) {
return (await target.getByTestId("profile-active-badge").count()) > 0;
},
{
// Each poll iteration reloads /settings/llm and re-fetches settings,
// so a slow backend (activation PATCH + settings propagation) needs
// headroom beyond a couple of reloads. 30s keeps this robust under
// added proxy latency without masking a genuine activation failure.
message: `Profile "${profileName}" should have an "Active" badge`,
timeout: 15_000,
timeout: 30_000,
intervals: [1_000, 2_000, 3_000],
},
)
+16
View File
@@ -134,6 +134,22 @@ export async function getOnboardingStepLayout(
page: Page,
): Promise<OnboardingStepLayout> {
await waitForOnboardingStep(page, ONBOARDING_BACKEND_STEP);
// Wait for the backend health probe to settle before sampling the layout.
// While the probe is in flight the backend slide shows a transient
// "checking" banner at step 0. A healthy configured backend then auto-skips
// the backend slide (starting the flow on agent selection), while an
// unhealthy/unconfigured one keeps it. Sampling during the "checking" window
// races that skip: we would wrongly report a backend step that immediately
// disappears and then wait forever for a "connected" banner that never
// renders. Waiting for "checking" to clear makes the verdict deterministic
// regardless of how long the probe takes (e.g. when a spec slows
// `/api/settings` via a `route.fetch()` intercept).
await expect(
page.getByTestId("onboarding-backend-checking"),
"onboarding backend health probe should settle before sampling the layout",
).toHaveCount(0, { timeout: 15_000 });
const hasBackendStep = await page
.getByTestId("onboarding-step-check-backend")
.isVisible()