mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 11:47:42 +01:00
Measure when users see a reply to their onboarding chat input (#23574)
This commit is contained in:
1 parent
2b65b97cae
commit
b0f682b66b
17 files changed
+367
-7
No files matched your search
@@ -324,6 +324,59 @@ test.describe("Chat launch after onboarding wizard", () => {
|
||||
await page.screenshot({ path: test.info().outputPath("onboarding-chat.png"), fullPage: true });
|
||||
});
|
||||
|
||||
test.describe("browser analytics", () => {
|
||||
test.use({ serviceWorkers: "block" });
|
||||
|
||||
for (const input of ["composer", "welcome answer"] as const) {
|
||||
test(`measures the first displayed reply to the onboarding ${input}`, async ({ page, baseURL }) => {
|
||||
test.setTimeout(180_000);
|
||||
await installLaunchIntercepts(page, baseURL, true);
|
||||
await page.route("**/api/auth/get-session", async route => {
|
||||
const response = await route.fetch();
|
||||
const session = await response.json();
|
||||
await route.fulfill({ response, json: { ...session, browserAnalytics: {
|
||||
token: "test", apiHost: "/analytics-fixture", uiHost: null, environment: "test",
|
||||
stackId: "test", replayEnabled: false,
|
||||
} } });
|
||||
});
|
||||
const captures: { actor: string; properties: Record<string, string> }[] = [];
|
||||
await page.exposeFunction("recordChatDisplay", (actor: string, properties: Record<string, string>) => {
|
||||
captures.push({ actor, properties });
|
||||
});
|
||||
await page.route("**/analytics-fixture/static/array.js", route => route.fulfill({
|
||||
contentType: "text/javascript",
|
||||
body: `window.posthog = { init() {}, register() {}, group() {}, reset() {}, identify(id) { this.actor = id; },
|
||||
capture(event, properties) { if (event === 'agent_chat_reply_displayed') window.recordChatDisplay(this.actor, properties); } };`,
|
||||
}));
|
||||
await runOnboardingWizard(page, `E2E-ChatDisplay-${Date.now()}`);
|
||||
await expect(page).toHaveURL(/\/chats\/[^/]+$/);
|
||||
const choices = page.getByTestId("task-chat-composer-takeover");
|
||||
const sent = page.waitForRequest(req => req.url().endsWith("/api/onboarding/telemetry")
|
||||
&& req.postDataJSON()?.event === "agent_chat_message_sent");
|
||||
if (input === "composer") {
|
||||
await choices.getByRole("button", { name: /^Dismiss / }).click();
|
||||
const editor = page.getByTestId("task-chat-composer-input").locator('[contenteditable="true"]');
|
||||
await editor.fill("build a website");
|
||||
await page.getByTestId("task-chat-composer-send").click();
|
||||
} else {
|
||||
await choices.getByRole("radio", { name: "Interview me about my goals" }).click();
|
||||
expect(captures).toHaveLength(0);
|
||||
await choices.getByRole("button", { name: /send|submit|continue/i }).click();
|
||||
}
|
||||
const reply = input === "composer" ? typedFixtureReply : choiceReplies.interview;
|
||||
const { chatId, messageId } = (await sent).postDataJSON();
|
||||
expect(chatId).toBeTruthy();
|
||||
expect(messageId).toBeTruthy();
|
||||
await expect(page.getByText(reply, { exact: true })).toBeVisible({ timeout: 30_000 });
|
||||
await expect.poll(() => captures).toEqual([{ actor: "local-board",
|
||||
properties: { surface: "onboarding_chat", reply_kind: "response_to_user", chat_id: chatId, message_id: messageId } }]);
|
||||
await page.reload();
|
||||
await expect(page.getByText(reply, { exact: true })).toBeVisible();
|
||||
expect(captures).toHaveLength(1);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
test("warms the welcome during review, then animates it before showing the real choice card", async ({ page, baseURL }) => {
|
||||
test.setTimeout(180_000);
|
||||
await installLaunchIntercepts(page, baseURL, true);
|
||||
|
||||
@@ -327,7 +327,7 @@
|
||||
"packages/shared/src/node-version.ts": "9a7766a8324122ce41738918bb0125398b9657e1",
|
||||
"packages/shared/src/oauth-endpoint-url.test.ts": "7f7ad634b3de7f25513e6c8b6426e1285d079e12",
|
||||
"packages/shared/src/oauth-endpoint-url.ts": "5ea73648dc5df103881e40e8ed920e38d901760a",
|
||||
"packages/shared/src/onboarding-telemetry.ts": "758da7421779d5ca20e83ac7222cc8c67714f278",
|
||||
"packages/shared/src/onboarding-telemetry.ts": "c959a1d091d81d2379d22d066490931fa74c586c",
|
||||
"packages/shared/src/openrouter-attribution.test.ts": "ddc980f9d06fac708d02dcef8a8962e9887d6854",
|
||||
"packages/shared/src/openrouter-attribution.ts": "b77e887721cbf6bd882004f07df2405b6e58e52c",
|
||||
"packages/shared/src/paperclip-peer.test.ts": "304c9db3bb82871834f4e8970d334cb21bb9de7a",
|
||||
|
||||
Reference in new issue
Block a user