File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
packages/gitbook/src/components/AI Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import * as zustand from 'zustand';
4
4
5
5
import { AIMessageRole } from '@gitbook/api' ;
6
6
import * as React from 'react' ;
7
+ import { useTrackEvent } from '../Insights' ;
7
8
import { streamAIChatFollowUpResponses , streamAIChatResponse } from './server-actions' ;
8
9
import { useAIMessageContextRef } from './useAIMessageContext' ;
9
10
@@ -86,6 +87,7 @@ export function useAIChatState(): AIChatState {
86
87
export function useAIChatController ( ) : AIChatController {
87
88
const messageContextRef = useAIMessageContextRef ( ) ;
88
89
const setState = zustand . useStore ( globalState , ( state ) => state . setState ) ;
90
+ const trackEvent = useTrackEvent ( ) ;
89
91
90
92
return React . useMemo ( ( ) => {
91
93
/**
@@ -113,6 +115,7 @@ export function useAIChatController(): AIChatController {
113
115
responseId : null ,
114
116
} ) ) ,
115
117
postMessage : async ( input : { message : string } ) => {
118
+ trackEvent ( { type : 'ask_question' , query : input . message } ) ;
116
119
setState ( ( state ) => {
117
120
return {
118
121
...state ,
@@ -168,5 +171,5 @@ export function useAIChatController(): AIChatController {
168
171
} ) ) ;
169
172
} ,
170
173
} ;
171
- } , [ messageContextRef , setState ] ) ;
174
+ } , [ messageContextRef , setState , trackEvent ] ) ;
172
175
}
You can’t perform that action at this time.
0 commit comments