From 825458d72d2dd6185073e5c7bbe57eff649a20dd Mon Sep 17 00:00:00 2001 From: Michael Matloka Date: Tue, 26 May 2026 16:42:59 +0200 Subject: [PATCH] feat(inbox): Capture "Signal source connected" analytics event Fires when a user enables a signal source for the Inbox, either by toggling a non-warehouse source on directly or by completing the DataSourceSetup wizard for a warehouse source. `is_first_connection` distinguishes a brand-new config from a re-enable; `via_setup_wizard` distinguishes the OAuth path from a plain toggle. Lets us measure inbox onboarding (e.g. first-time-for-user trend of new users connecting their first source). Generated-By: PostHog Code Task-Id: 55527856-9edd-4907-a389-98ac880f806d --- .../inbox/hooks/useSignalSourceManager.ts | 18 ++++++++++++++++++ apps/code/src/shared/types/analytics.ts | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/apps/code/src/renderer/features/inbox/hooks/useSignalSourceManager.ts b/apps/code/src/renderer/features/inbox/hooks/useSignalSourceManager.ts index 7d9f0a642..c1a107aec 100644 --- a/apps/code/src/renderer/features/inbox/hooks/useSignalSourceManager.ts +++ b/apps/code/src/renderer/features/inbox/hooks/useSignalSourceManager.ts @@ -9,8 +9,10 @@ import type { SignalReportPriority, SignalUserAutonomyConfig, } from "@shared/types"; +import { ANALYTICS_EVENTS } from "@shared/types/analytics"; import { getCloudUrlFromRegion } from "@shared/utils/urls"; import { useQueryClient } from "@tanstack/react-query"; +import { track } from "@utils/analytics"; import { useCallback, useMemo, useRef, useState } from "react"; import { toast } from "sonner"; import { useEvaluations } from "./useEvaluations"; @@ -330,6 +332,9 @@ export function useSignalSourceManager() { const label = SOURCE_LABELS[product]; + const hadExistingConfig = configs?.some( + (c) => c.source_product === product, + ); try { if (product === "error_tracking") { for (const sourceType of ERROR_TRACKING_SOURCE_TYPES) { @@ -371,6 +376,14 @@ export function useSignalSourceManager() { } } + if (enabled) { + track(ANALYTICS_EVENTS.SIGNAL_SOURCE_CONNECTED, { + source_product: product, + is_first_connection: !hadExistingConfig, + via_setup_wizard: false, + }); + } + await invalidateAfterToggle(); } catch (error: unknown) { const message = @@ -415,6 +428,11 @@ export function useSignalSourceManager() { enabled: true, }); } + track(ANALYTICS_EVENTS.SIGNAL_SOURCE_CONNECTED, { + source_product: completedSource, + is_first_connection: !existing, + via_setup_wizard: true, + }); } catch { toast.error( "Data source connected, but failed to enable signal source. Try toggling it on.", diff --git a/apps/code/src/shared/types/analytics.ts b/apps/code/src/shared/types/analytics.ts index 61f56c0cf..268e00d24 100644 --- a/apps/code/src/shared/types/analytics.ts +++ b/apps/code/src/shared/types/analytics.ts @@ -562,6 +562,22 @@ export interface InboxReportActionProperties { question_text?: string; } +export interface SignalSourceConnectedProperties { + source_product: + | "session_replay" + | "error_tracking" + | "github" + | "linear" + | "zendesk" + | "conversations" + | "pganalyze" + | "llm_analytics"; + /** True when this is a brand-new createSignalSourceConfig, false for re-enable of an existing config. */ + is_first_connection: boolean; + /** True when the connection went through the DataSourceSetup wizard (warehouse OAuth path). */ + via_setup_wizard: boolean; +} + // Subscription / billing events export interface SubscriptionStartedProperties { plan_key: string; @@ -681,6 +697,7 @@ export const ANALYTICS_EVENTS = { INBOX_REPORT_CLOSED: "Inbox report closed", INBOX_REPORT_ACTION: "Inbox report action", INBOX_REPORT_SCROLLED: "Inbox report scrolled", + SIGNAL_SOURCE_CONNECTED: "Signal source connected", // Prompt history events PROMPT_HISTORY_OPENED: "Prompt history opened", @@ -793,6 +810,7 @@ export type EventPropertyMap = { [ANALYTICS_EVENTS.INBOX_REPORT_CLOSED]: InboxReportClosedProperties; [ANALYTICS_EVENTS.INBOX_REPORT_ACTION]: InboxReportActionProperties; [ANALYTICS_EVENTS.INBOX_REPORT_SCROLLED]: InboxReportScrolledProperties; + [ANALYTICS_EVENTS.SIGNAL_SOURCE_CONNECTED]: SignalSourceConnectedProperties; // Prompt history events [ANALYTICS_EVENTS.PROMPT_HISTORY_OPENED]: PromptHistoryOpenedProperties;