Skip to content

Commit 9b7bfe6

Browse files
#RI-2462-add non editor telemetry events (#759)
1 parent 743763a commit 9b7bfe6

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

redisinsight/ui/src/components/query/Query/Query.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import cx from 'classnames'
66
import { EuiButtonIcon, EuiText, EuiToolTip } from '@elastic/eui'
77
import * as monacoEditor from 'monaco-editor/esm/vs/editor/editor.api'
88
import MonacoEditor, { monaco } from 'react-monaco-editor'
9+
import { useParams } from 'react-router-dom'
910

1011
import {
1112
Theme,
@@ -34,6 +35,7 @@ import { appRedisCommandsSelector } from 'uiSrc/slices/app/redis-commands'
3435
import { IEditorMount, ISnippetController } from 'uiSrc/pages/workbench/interfaces'
3536
import { CommandExecutionUI } from 'uiSrc/slices/interfaces'
3637
import { darkTheme, lightTheme } from 'uiSrc/constants/monaco/cypher'
38+
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
3739

3840
import { workbenchResultsSelector } from 'uiSrc/slices/workbench/wb-results'
3941
import DedicatedEditor from 'uiSrc/components/query/DedicatedEditor/DedicatedEditor'
@@ -77,6 +79,8 @@ const Query = (props: Props) => {
7779
const { theme } = useContext(ThemeContext)
7880
const monacoObjects = useRef<Nullable<IEditorMount>>(null)
7981

82+
const { instanceId = '' } = useParams<{ instanceId: string }>()
83+
8084
let disposeCompletionItemProvider = () => {}
8185
let disposeSignatureHelpProvider = () => {}
8286

@@ -125,7 +129,7 @@ const Query = (props: Props) => {
125129
const triggerUpdateCursorPosition = (editor: monacoEditor.editor.IStandaloneCodeEditor) => {
126130
const position = editor.getPosition()
127131
isDedicatedEditorOpenRef.current = false
128-
editor.trigger('mouse', '_moveTo', { position: { lineNumber: 1, column: 1 }})
132+
editor.trigger('mouse', '_moveTo', { position: { lineNumber: 1, column: 1 } })
129133
editor.trigger('mouse', '_moveTo', { position })
130134
editor.focus()
131135
}
@@ -137,6 +141,13 @@ const Query = (props: Props) => {
137141
setIsDedicatedEditorOpen(true)
138142
editor.updateOptions({ readOnly: true })
139143
hideSyntaxWidget(editor)
144+
sendEventTelemetry({
145+
event: TelemetryEvent.WORKBENCH_NON_REDIS_EDITOR_OPENED,
146+
eventData: {
147+
databaseId: instanceId,
148+
lang: syntaxCommand.current.lang,
149+
}
150+
})
140151
}
141152

142153
const onChange = (value: string = '') => {
@@ -305,6 +316,14 @@ const Query = (props: Props) => {
305316

306317
editor.updateOptions({ readOnly: false })
307318
triggerUpdateCursorPosition(editor)
319+
320+
sendEventTelemetry({
321+
event: TelemetryEvent.WORKBENCH_NON_REDIS_EDITOR_CANCELLED,
322+
eventData: {
323+
databaseId: instanceId,
324+
lang: syntaxCommand.current.lang,
325+
}
326+
})
308327
}
309328

310329
const updateArgFromDedicatedEditor = (value: string = '') => {
@@ -333,6 +352,13 @@ const Query = (props: Props) => {
333352
])
334353
setIsDedicatedEditorOpen(false)
335354
triggerUpdateCursorPosition(editor)
355+
sendEventTelemetry({
356+
event: TelemetryEvent.WORKBENCH_NON_REDIS_EDITOR_SAVED,
357+
eventData: {
358+
databaseId: instanceId,
359+
lang: syntaxCommand.current.lang,
360+
}
361+
})
336362
}
337363

338364
const editorDidMount = (

redisinsight/ui/src/telemetry/events.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ export enum TelemetryEvent {
8585
WORKBENCH_RESULTS_COLLAPSED = 'WORKBENCH_RESULTS_COLLAPSED',
8686
WORKBENCH_RESULTS_EXPANDED = 'WORKBENCH_RESULTS_EXPANDED',
8787
WORKBENCH_RESULT_VIEW_CHANGED = 'WORKBENCH_RESULT_VIEW_CHANGED',
88+
WORKBENCH_NON_REDIS_EDITOR_OPENED = 'WORKBENCH_NON_REDIS_EDITOR_OPENED',
89+
WORKBENCH_NON_REDIS_EDITOR_CANCELLED = 'WORKBENCH_NON_REDIS_EDITOR_CANCELLED',
90+
WORKBENCH_NON_REDIS_EDITOR_SAVED = 'WORKBENCH_NON_REDIS_EDITOR_SAVED',
8891

8992
PROFILER_OPENED = 'PROFILER_OPENED',
9093
PROFILER_STARTED = 'PROFILER_STARTED',

0 commit comments

Comments
 (0)