Skip to content

Commit cb8597a

Browse files
committed
more events
1 parent 6a114b6 commit cb8597a

File tree

16 files changed

+110
-14
lines changed

16 files changed

+110
-14
lines changed

src/components/LiteEditor/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { FileCopy } from "@styled-icons/remix-line"
99
import { CheckboxCircle } from "@styled-icons/remix-fill"
1010
import { copyToClipboard } from "../../utils/copyToClipboard"
1111
import { SquareSplitHorizontalIcon } from "@phosphor-icons/react"
12+
import { trackEvent } from "../../modules/ConsoleEventTracker"
13+
import { ConsoleEvent } from "../../modules/ConsoleEventTracker/events"
1214

1315
const EditorWrapper = styled.div<{ $noBorder?: boolean }>`
1416
position: relative;
@@ -161,7 +163,12 @@ const LiteEditorToolbar = ({
161163
<ButtonsContainer>
162164
<OpenInEditorButton
163165
className="open-in-editor-btn"
164-
onClick={onOpenInEditor}
166+
onClick={() => {
167+
void trackEvent(ConsoleEvent.AI_OPEN_IN_EDITOR, {
168+
diffEditor,
169+
})
170+
onOpenInEditor()
171+
}}
165172
title="Open in editor"
166173
data-hook="ai-open-in-editor-button"
167174
>

src/components/SetupAIAssistant/ConfigurationModal.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,8 @@ export const ConfigurationModal = ({
762762
if (!selectedProvider || enabledModels.length === 0) return
763763

764764
void trackEvent(ConsoleEvent.AI_PROVIDER_CONFIGURE, {
765-
type: selectedProvider,
765+
name: selectedProvider,
766+
grantSchemaAccess,
766767
})
767768

768769
const selectedModel =
@@ -891,6 +892,13 @@ export const ConfigurationModal = ({
891892
},
892893
}
893894

895+
void trackEvent(ConsoleEvent.AI_PROVIDER_CONFIGURE, {
896+
name: "custom",
897+
grantSchemaAccess: definition.grantSchemaAccess ?? false,
898+
type: definition.type,
899+
contextWindow: definition.contextWindow,
900+
})
901+
894902
updateSettings(StoreKey.AI_ASSISTANT_SETTINGS, newSettings)
895903
toast.success("AI Assistant activated successfully")
896904
setCustomProviderModalOpen(false)

src/components/SetupAIAssistant/SettingsModal.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,9 @@ export const SettingsModal = ({ open, onOpenChange }: SettingsModalProps) => {
850850
const handleRemoveProvider = useCallback(
851851
(providerId: ProviderId) => {
852852
const isCustom = !BUILTIN_PROVIDERS[providerId]
853+
void trackEvent(ConsoleEvent.AI_SETTINGS_PROVIDER_REMOVE, {
854+
isCustom,
855+
})
853856

854857
if (isCustom) {
855858
setLocalCustomProviders((prev) => {

src/modules/ConsoleEventTracker/events.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export enum ConsoleEvent {
66
SEARCH_EXECUTE = "search.execute",
77
SEARCH_OPEN = "search.open",
88

9-
EDITOR_RUN_ALL = "editor.run_all",
9+
EDITOR_VIEW_TAB = "editor.view_tab",
10+
EDITOR_RUN_MULTIPLE = "editor.run_multiple",
1011
EDITOR_GLYPH_RUN = "editor.glyph_run",
1112
EDITOR_GLYPH_CONTEXT_OPEN = "editor.glyph_context_open",
1213
EDITOR_GLYPH_CONTEXT_QUERY_PLAN = "editor.glyph_context_query_plan",
@@ -17,6 +18,7 @@ export enum ConsoleEvent {
1718
GRID_REFRESH = "grid.refresh",
1819
GRID_LAYOUT_RESET = "grid.layout_reset",
1920
GRID_COLUMN_FREEZE = "grid.column_freeze",
21+
GRID_COLUMN_MOVE_TO_FRONT = "grid.column_move_to_front",
2022
GRID_CELL_COPY = "grid.cell_copy",
2123

2224
IMPORT_FILE_UPLOAD = "import.file_upload",
@@ -31,7 +33,10 @@ export enum ConsoleEvent {
3133
AI_CHAT_SEND = "ai.chat_send",
3234
AI_CHAT_ACCEPT = "ai.chat_accept",
3335
AI_EDITOR_SUGGESTION_ACCEPT = "ai.editor.suggestion_accept",
36+
AI_EDITOR_SUGGESTION_REJECT = "ai.editor.suggestion_reject",
37+
AI_EDITOR_SUGGESTION_APPLY = "ai.editor.suggestion_apply",
3438
AI_CHAT_REJECT = "ai.chat_reject",
39+
AI_OPEN_IN_EDITOR = "ai.open_in_editor",
3540
AI_CHAT_DELETE = "ai.chat_delete",
3641
AI_CHAT_RENAME = "ai.chat_rename",
3742
AI_HISTORY_OPEN = "ai.history_open",
@@ -40,32 +45,36 @@ export enum ConsoleEvent {
4045
AI_GLYPH_CLICK = "ai.glyph_click",
4146
AI_CONTEXT_BADGE_CLICK = "ai.context_badge_click",
4247
AI_PROVIDER_CONFIGURE = "ai.provider_configure",
48+
AI_SETTINGS_PROVIDER_REMOVE = "ai.settings_provider_remove",
4349
AI_PROMO_OPEN = "ai.promo_open",
4450
AI_CONFIGURATION_OPEN = "ai.configuration_open",
4551
AI_CONFIGURATION_VALIDATE = "ai.configuration_validate",
4652
AI_SETTINGS_OPEN = "ai.settings_open",
4753
AI_SETTINGS_MODEL_TOGGLE = "ai.settings_model_toggle",
48-
AI_SETTINGS_API_KEY_REMOVE = "ai.settings_api_key_remove",
4954
AI_SETTINGS_API_KEY_EDIT = "ai.settings_api_key_edit",
5055
AI_SETTINGS_SCHEMA_ACCESS_REMOVE = "ai.settings_schema_access_remove",
5156
AI_MODEL_CHANGE = "ai.model_change",
57+
AI_FLOW_COMPLETE = "ai.flow_complete",
5258

5359
PANEL_BOTTOM_SWITCH = "panel.bottom.switch",
5460

5561
SCHEMA_FILTER_SUSPENDED = "schema.filter_suspended",
5662
SCHEMA_CONTEXT_MENU_OPEN = "schema.context_menu_open",
5763
SCHEMA_CONTEXT_RESUME_WAL = "schema.context_resume_wal",
64+
SCHEMA_RESUME_WAL_SUBMIT = "schema.resume_wal_submit",
5865
SCHEMA_CONTEXT_COPY_DDL = "schema.context_copy_ddl",
5966
SCHEMA_CONTEXT_EXPLAIN = "schema.context_explain",
6067
SCHEMA_COPY_MULTIPLE = "schema.copy_multiple",
6168

69+
TABLE_DETAILS_TAB_SWITCH = "table_details.tab_switch",
6270
TABLE_DETAILS_OPEN = "table_details.open",
6371
TABLE_DETAILS_SCHEMA_EXPLAIN = "table_details.schema_explain",
6472
TABLE_DETAILS_ASK_AI = "table_details.ask_ai",
6573
TABLE_DETAILS_COPY_DDL = "table_details.copy_ddl",
6674

6775
SIDEBAR_NAVIGATE = "sidebar.navigate",
6876

77+
TAB_ADD = "tab.add",
6978
TAB_IMPORT = "tab.import",
7079
TAB_EXPORT = "tab.export",
7180
TAB_RENAME = "tab.rename",
@@ -78,7 +87,9 @@ export enum ConsoleEvent {
7887
QUERY_LOG_CLEAR = "query_log.clear",
7988

8089
METRIC_ADD = "metric.add",
90+
METRIC_REMOVE = "metric.remove",
8191
METRIC_TAB_OPEN = "metric.tab_open",
92+
METRIC_REFRESH_RATE_CHANGE = "metric.refresh_rate_change",
8293

8394
HELP_OPEN = "help.open",
8495
HELP_FEEDBACK_SUBMIT = "help.feedback_submit",

src/providers/EditorProvider/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import { eventBus } from "../../modules/EventBus"
3838
import { EventType } from "../../modules/EventBus/types"
3939

4040
import { useLiveQuery } from "dexie-react-hooks"
41+
import { trackEvent } from "../../modules/ConsoleEventTracker"
42+
import { ConsoleEvent } from "../../modules/ConsoleEventTracker/events"
4143

4244
export const MAX_TABS = 100
4345

@@ -303,6 +305,11 @@ export const EditorProvider: React.FC = ({ children }) => {
303305
return undefined
304306
}
305307

308+
void trackEvent(ConsoleEvent.TAB_ADD, {
309+
type: newBuffer?.metricsViewState ? BufferType.METRICS : BufferType.SQL,
310+
count: (buffers?.length ?? 0) + 1,
311+
})
312+
306313
const fallback = makeFallbackBuffer(
307314
newBuffer?.metricsViewState ? BufferType.METRICS : BufferType.SQL,
308315
)

src/scenes/Editor/AIChatWindow/ChatMessages.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ import {
5252
AIOperationStatus,
5353
useAIStatus,
5454
} from "../../../providers/AIStatusProvider"
55+
import { trackEvent } from "../../../modules/ConsoleEventTracker"
56+
import { ConsoleEvent } from "../../../modules/ConsoleEventTracker/events"
5557

5658
type QueryRunStatus = "neutral" | "loading" | "success" | "error"
5759

@@ -1201,6 +1203,9 @@ export const ChatMessages: React.FC<ChatMessagesProps> = ({
12011203
message.sql &&
12021204
!isOperationInProgress
12031205
) {
1206+
void trackEvent(
1207+
ConsoleEvent.AI_EDITOR_SUGGESTION_APPLY,
1208+
)
12041209
onApplyToEditor(message.id, message.sql)
12051210
}
12061211
}}

src/scenes/Editor/Metrics/add-metric-dialog.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ export const AddMetricDialog = ({ open, onOpenChange }: Props) => {
6767
: defaultColor
6868

6969
const handleSelectMetric = async (metricType: MetricType) => {
70-
void trackEvent(ConsoleEvent.METRIC_ADD, { metricType })
70+
void trackEvent(ConsoleEvent.METRIC_ADD, {
71+
metricType,
72+
count: metrics.length + 1,
73+
})
7174
if (buffer?.id) {
7275
const newBuffer = merge(buffer, {
7376
metricsViewState: {

src/scenes/Editor/Metrics/index.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import { formatISO } from "date-fns"
3232
import { DateTimePicker } from "./date-time-picker"
3333
import useElementVisibility from "../../../hooks/useElementVisibility"
3434
import { widgets } from "./widgets"
35+
import { trackEvent } from "../../../modules/ConsoleEventTracker"
36+
import { ConsoleEvent } from "../../../modules/ConsoleEventTracker/events"
3537

3638
const Root = styled.div`
3739
display: flex;
@@ -346,6 +348,12 @@ export const Metrics = () => {
346348
}))}
347349
onChange={(e) => {
348350
if (buffer?.id) {
351+
void trackEvent(
352+
ConsoleEvent.METRIC_REFRESH_RATE_CHANGE,
353+
{
354+
refreshRate: e.target.value as RefreshRate,
355+
},
356+
)
349357
void updateBuffer(buffer.id, {
350358
metricsViewState: {
351359
...buffer?.metricsViewState,

src/scenes/Editor/Metrics/metric.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ import {
4444
import { ColorPalette } from "./color-palette"
4545
import { eventBus } from "../../../modules/EventBus"
4646
import { EventType } from "../../../modules/EventBus/types"
47+
import { trackEvent } from "../../../modules/ConsoleEventTracker"
48+
import { ConsoleEvent } from "../../../modules/ConsoleEventTracker/events"
4749

4850
const MetricInfoRoot = styled(Box).attrs({
4951
align: "center",
@@ -283,7 +285,13 @@ export const Metric = ({
283285
/>
284286
<IconWithTooltip
285287
icon={
286-
<ActionButton skin="transparent" onClick={() => onRemove(metric)}>
288+
<ActionButton
289+
skin="transparent"
290+
onClick={() => {
291+
void trackEvent(ConsoleEvent.METRIC_REMOVE)
292+
onRemove(metric)
293+
}}
294+
>
287295
<Trash size="18px" />
288296
</ActionButton>
289297
}

src/scenes/Editor/Monaco/index.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,11 +1174,16 @@ const MonacoEditor = ({ hidden = false }: { hidden?: boolean }) => {
11741174
})
11751175
glyphWidgetsRef.current.clear()
11761176
const lineCount = editorRef.current?.getModel()?.getLineCount()
1177+
const hasContent =
1178+
(editorRef.current?.getModel()?.getValueLength() ?? 0) > 0
11771179
if (lineCount) {
11781180
setLineNumbersMinChars(
11791181
getDefaultLineNumbersMinChars(canUseAIRef.current) +
11801182
(lineCount.toString().length - 1),
11811183
)
1184+
if (hasContent) {
1185+
void trackEvent(ConsoleEvent.EDITOR_VIEW_TAB, { lines: lineCount })
1186+
}
11821187
}
11831188
setTimeout(() => {
11841189
if (monacoRef.current && editorRef.current) {
@@ -1446,9 +1451,10 @@ const MonacoEditor = ({ hidden = false }: { hidden?: boolean }) => {
14461451
return
14471452
}
14481453

1449-
if (runAll) {
1450-
void trackEvent(ConsoleEvent.EDITOR_RUN_ALL)
1451-
}
1454+
void trackEvent(ConsoleEvent.EDITOR_RUN_MULTIPLE, {
1455+
queryCount: queriesToRunRef.current?.length ?? 0,
1456+
runAll,
1457+
})
14521458

14531459
const triggerScript = () => {
14541460
if (runAll) {

0 commit comments

Comments
 (0)