File tree Expand file tree Collapse file tree 3 files changed +48
-0
lines changed
components/CodeAssistantTelemetry
containers/Tenant/Query/QueryEditor Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+
3+ import { useSendOpenTabsMutation } from '../../store/reducers/codeAssist' ;
4+ import { selectQueriesHistory } from '../../store/reducers/query/query' ;
5+ import { useTypedSelector } from '../../utils/hooks' ;
6+
7+ export function CodeAssistantTelemetry ( ) {
8+ const [ sendOpenTabs ] = useSendOpenTabsMutation ( ) ;
9+ const historyQueries = useTypedSelector ( selectQueriesHistory ) ;
10+
11+ React . useEffect ( ( ) => {
12+ if ( ! historyQueries ?. length ) {
13+ return ;
14+ }
15+
16+ const tabs = historyQueries . map ( ( query ) => ( {
17+ FileName : `query_${ query . queryId } .yql` ,
18+ Text : query . queryText ,
19+ } ) ) ;
20+
21+ sendOpenTabs ( tabs ) ;
22+ } , [ historyQueries , sendOpenTabs ] ) ;
23+
24+ return null ;
25+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import throttle from 'lodash/throttle';
66import type Monaco from 'monaco-editor' ;
77import { v4 as uuidv4 } from 'uuid' ;
88
9+ import { CodeAssistantTelemetry } from '../../../../components/CodeAssistantTelemetry/CodeAssistantTelemetry' ;
910import { MonacoEditor } from '../../../../components/MonacoEditor/MonacoEditor' ;
1011import SplitPane from '../../../../components/SplitPane' ;
1112import { useTracingLevelOptionAvailable } from '../../../../store/reducers/capabilities/hooks' ;
@@ -341,6 +342,7 @@ export default function QueryEditor(props: QueryEditorProps) {
341342
342343 return (
343344 < div className = { b ( ) } >
345+ { window . api . codeAssistant && < CodeAssistantTelemetry /> }
344346 < SplitPane
345347 direction = "vertical"
346348 defaultSizePaneKey = { DEFAULT_SIZE_RESULT_PANE_KEY }
Original file line number Diff line number Diff line change 1+ import type { TelemetryOpenTabs } from '../../types/api/codeAssistant' ;
2+
3+ import { api } from './api' ;
4+
5+ export const codeAssistApi = api . injectEndpoints ( {
6+ endpoints : ( build ) => ( {
7+ sendOpenTabs : build . mutation ( {
8+ queryFn : async ( params : TelemetryOpenTabs ) => {
9+ try {
10+ const data = await window . api . codeAssistant ?. sendCodeAssistOpenTabs ( params ) ;
11+ return { data} ;
12+ } catch ( error ) {
13+ return { error} ;
14+ }
15+ } ,
16+ } ) ,
17+ } ) ,
18+ overrideExisting : 'throw' ,
19+ } ) ;
20+
21+ export const { useSendOpenTabsMutation} = codeAssistApi ;
You can’t perform that action at this time.
0 commit comments