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';
44
55import { AIMessageRole } from '@gitbook/api' ;
66import * as React from 'react' ;
7+ import { useTrackEvent } from '../Insights' ;
78import { streamAIChatFollowUpResponses , streamAIChatResponse } from './server-actions' ;
89import { useAIMessageContextRef } from './useAIMessageContext' ;
910
@@ -86,6 +87,7 @@ export function useAIChatState(): AIChatState {
8687export function useAIChatController ( ) : AIChatController {
8788 const messageContextRef = useAIMessageContextRef ( ) ;
8889 const setState = zustand . useStore ( globalState , ( state ) => state . setState ) ;
90+ const trackEvent = useTrackEvent ( ) ;
8991
9092 return React . useMemo ( ( ) => {
9193 /**
@@ -113,6 +115,7 @@ export function useAIChatController(): AIChatController {
113115 responseId : null ,
114116 } ) ) ,
115117 postMessage : async ( input : { message : string } ) => {
118+ trackEvent ( { type : 'ask_question' , query : input . message } ) ;
116119 setState ( ( state ) => {
117120 return {
118121 ...state ,
@@ -168,5 +171,5 @@ export function useAIChatController(): AIChatController {
168171 } ) ) ;
169172 } ,
170173 } ;
171- } , [ messageContextRef , setState ] ) ;
174+ } , [ messageContextRef , setState , trackEvent ] ) ;
172175}
You can’t perform that action at this time.
0 commit comments