Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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,
});
Comment thread
charlesvien marked this conversation as resolved.
} catch {
toast.error(
"Data source connected, but failed to enable signal source. Try toggling it on.",
Expand Down
18 changes: 18 additions & 0 deletions apps/code/src/shared/types/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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;
Expand Down
Loading