@@ -38,6 +38,7 @@ type AISearchResultEventParams = {
3838 eventGroupId : string
3939 couldNotAnswer ?: boolean
4040 status : number
41+ connectedEventId ?: string
4142}
4243
4344export function AskAIResults ( {
@@ -67,11 +68,14 @@ export function AskAIResults({
6768 message : string
6869 sources : AIReference [ ]
6970 aiCouldNotAnswer : boolean
71+ connectedEventId ?: string
7072 } > ( 'ai-query-cache' , 1000 , 7 )
7173
7274 const [ isCopied , setCopied ] = useClipboard ( message , { successDuration : 1400 } )
7375 const [ feedbackSelected , setFeedbackSelected ] = useState < null | 'up' | 'down' > ( null )
7476
77+ const [ conversationId , setConversationId ] = useState < string > ( '' )
78+
7579 const handleAICannotAnswer = ( ) => {
7680 setInitialLoading ( false )
7781 setResponseLoading ( false )
@@ -129,6 +133,7 @@ export function AskAIResults({
129133 eventGroupId : askAIEventGroupId . current ,
130134 couldNotAnswer : cachedData . aiCouldNotAnswer ,
131135 status : cachedData . aiCouldNotAnswer ? 400 : 200 ,
136+ connectedEventId : cachedData . connectedEventId ,
132137 } )
133138
134139 setTimeout ( ( ) => {
@@ -141,6 +146,7 @@ export function AskAIResults({
141146 async function fetchData ( ) {
142147 let messageBuffer = ''
143148 let sourcesBuffer : AIReference [ ] = [ ]
149+ let conversationIdBuffer = ''
144150
145151 try {
146152 const response = await executeAISearch ( router , version , query , debug )
@@ -212,6 +218,9 @@ export function AskAIResults({
212218 messageBuffer += parsedLine . text
213219 setMessage ( messageBuffer )
214220 }
221+ } else if ( parsedLine . chunkType === 'CONVERSATION_ID' ) {
222+ conversationIdBuffer = parsedLine . conversation_id
223+ setConversationId ( parsedLine . conversation_id )
215224 }
216225 if ( ! isCancelled ) {
217226 setAnnouncement ( 'Copilot Response Loading...' )
@@ -233,6 +242,7 @@ export function AskAIResults({
233242 message : messageBuffer ,
234243 sources : sourcesBuffer ,
235244 aiCouldNotAnswer : false ,
245+ connectedEventId : conversationIdBuffer ,
236246 } ,
237247 version ,
238248 router . locale || 'en' ,
@@ -245,6 +255,7 @@ export function AskAIResults({
245255 eventGroupId : askAIEventGroupId . current ,
246256 couldNotAnswer : false ,
247257 status : 200 ,
258+ connectedEventId : conversationIdBuffer ,
248259 } )
249260 }
250261 }
@@ -299,6 +310,7 @@ export function AskAIResults({
299310 survey_vote : true ,
300311 eventGroupKey : ASK_AI_EVENT_GROUP ,
301312 eventGroupId : askAIEventGroupId . current ,
313+ survey_connected_event_id : conversationId ,
302314 } )
303315 } }
304316 > </ IconButton >
@@ -320,6 +332,7 @@ export function AskAIResults({
320332 survey_vote : false ,
321333 eventGroupKey : ASK_AI_EVENT_GROUP ,
322334 eventGroupId : askAIEventGroupId . current ,
335+ survey_connected_event_id : conversationId ,
323336 } )
324337 } }
325338 > </ IconButton >
@@ -409,6 +422,7 @@ function sendAISearchResultEvent({
409422 eventGroupId,
410423 couldNotAnswer = false ,
411424 status,
425+ connectedEventId,
412426} : AISearchResultEventParams ) {
413427 let searchResultLinksJson = '[]'
414428 try {
@@ -418,12 +432,10 @@ function sendAISearchResultEvent({
418432 }
419433 sendEvent ( {
420434 type : EventType . aiSearchResult ,
421- // TODO: Remove PII so we can include the actual data
422- ai_search_result_query : 'REDACTED' ,
423- ai_search_result_response : 'REDACTED' ,
424435 ai_search_result_links_json : searchResultLinksJson ,
425436 ai_search_result_provided_answer : couldNotAnswer ? false : true ,
426437 ai_search_result_response_status : status ,
438+ ai_search_result_connected_event_id : connectedEventId ,
427439 eventGroupKey : ASK_AI_EVENT_GROUP ,
428440 eventGroupId : eventGroupId ,
429441 } )
0 commit comments