From 6e3a6255c3120850d659cb2120bb24ebe5106e73 Mon Sep 17 00:00:00 2001 From: Nisarg Patel Date: Sat, 4 Apr 2026 17:10:32 -0700 Subject: [PATCH 1/3] fix: improve analytics observability for retention debugging - Use Effect error _tag instead of constructor.name for run:failed error_tag, fixing minified class names in production builds - Instrument missing cookies:sync_choice and cookies:toggled events - Only emit cookies:browser_selection when browsers are selected Made-with: Cursor --- .cursor/settings.json | 7 +++++++ .../screens/cookie-sync-confirm-screen.tsx | 12 +++++++++--- apps/cli/src/components/screens/main-menu-screen.tsx | 1 + apps/cli/src/data/execution-atom.ts | 7 ++++++- 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 .cursor/settings.json diff --git a/.cursor/settings.json b/.cursor/settings.json new file mode 100644 index 000000000..b459ee22e --- /dev/null +++ b/.cursor/settings.json @@ -0,0 +1,7 @@ +{ + "plugins": { + "posthog": { + "enabled": true + } + } +} diff --git a/apps/cli/src/components/screens/cookie-sync-confirm-screen.tsx b/apps/cli/src/components/screens/cookie-sync-confirm-screen.tsx index ed26ead75..6a77f29e0 100644 --- a/apps/cli/src/components/screens/cookie-sync-confirm-screen.tsx +++ b/apps/cli/src/components/screens/cookie-sync-confirm-screen.tsx @@ -61,10 +61,16 @@ export const CookieSyncConfirmScreen = ({ const confirm = () => { const keys = [...selectedKeys]; setCookieBrowserKeys(keys); - trackEvent("cookies:browser_selection", { - selected_count: keys.length, - browsers: keys.join(","), + trackEvent("cookies:sync_choice", { + choice: keys.length > 0 ? "use_cookies" : "skip_cookies", }); + if (keys.length > 0) { + trackEvent("cookies:browser_selection", { + selected_count: keys.length, + browsers: keys.join(","), + }); + trackEvent("cookies:toggled", { enabled: true }); + } if (changesFor && instruction) { setScreen( screenForTestingOrPortPicker({ diff --git a/apps/cli/src/components/screens/main-menu-screen.tsx b/apps/cli/src/components/screens/main-menu-screen.tsx index afe77137b..a748a0683 100644 --- a/apps/cli/src/components/screens/main-menu-screen.tsx +++ b/apps/cli/src/components/screens/main-menu-screen.tsx @@ -234,6 +234,7 @@ export const MainMenu = ({ gitState }: MainMenuProps) => { if (cookieBrowserKeys.length > 0) { clearCookieBrowserKeys(); trackEvent("cookies:cleared"); + trackEvent("cookies:toggled", { enabled: false }); } else { setScreen(Screen.CookieSyncConfirm({})); } diff --git a/apps/cli/src/data/execution-atom.ts b/apps/cli/src/data/execution-atom.ts index 13bd79384..fb86f3ca4 100644 --- a/apps/cli/src/data/execution-atom.ts +++ b/apps/cli/src/data/execution-atom.ts @@ -189,7 +189,12 @@ export const executeFn = cliAtomRuntime.fn()((input) => Effect.tapError((error) => Effect.gen(function* () { const analytics = yield* Analytics; - const errorTag = error instanceof Error ? error.constructor.name : "UnknownError"; + const errorTag = + "_tag" in error && typeof error._tag === "string" + ? error._tag + : error instanceof Error + ? error.constructor.name + : "UnknownError"; yield* analytics.capture("run:failed", { plan_id: "direct", error_tag: errorTag, From f75034589bc397a0d8f05b7bf564efad4146f384 Mon Sep 17 00:00:00 2001 From: Nisarg Patel Date: Sat, 4 Apr 2026 21:00:42 -0700 Subject: [PATCH 2/3] Apply suggestion from @cubic-dev-ai[bot] Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- apps/cli/src/data/execution-atom.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/cli/src/data/execution-atom.ts b/apps/cli/src/data/execution-atom.ts index fb86f3ca4..78da5b85d 100644 --- a/apps/cli/src/data/execution-atom.ts +++ b/apps/cli/src/data/execution-atom.ts @@ -190,7 +190,10 @@ export const executeFn = cliAtomRuntime.fn()((input) => Effect.gen(function* () { const analytics = yield* Analytics; const errorTag = - "_tag" in error && typeof error._tag === "string" + typeof error === "object" && + error !== null && + "_tag" in error && + typeof error._tag === "string" ? error._tag : error instanceof Error ? error.constructor.name From bdfaf7f078e51dbeba9d759fbd4b61045b433dab Mon Sep 17 00:00:00 2001 From: Nisarg Patel Date: Sat, 4 Apr 2026 21:18:31 -0700 Subject: [PATCH 3/3] fix: refine error handling in executeFn for improved type safety - Updated error handling logic to cast errors as any before checking instance type, ensuring compatibility with various error structures. - This change addresses potential type issues while maintaining existing functionality. --- apps/cli/src/data/execution-atom.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/cli/src/data/execution-atom.ts b/apps/cli/src/data/execution-atom.ts index 78da5b85d..0a8d323bf 100644 --- a/apps/cli/src/data/execution-atom.ts +++ b/apps/cli/src/data/execution-atom.ts @@ -195,8 +195,9 @@ export const executeFn = cliAtomRuntime.fn()((input) => "_tag" in error && typeof error._tag === "string" ? error._tag - : error instanceof Error - ? error.constructor.name + : // ignore for now + (error as any) instanceof Error + ? (error as any).constructor.name : "UnknownError"; yield* analytics.capture("run:failed", { plan_id: "direct",