From ec65fd07ebf86c9875baa8e27de44d62974daae2 Mon Sep 17 00:00:00 2001 From: fbeaudoincoveo Date: Thu, 24 Aug 2023 15:22:30 -0400 Subject: [PATCH] Undo bad changes --- .../generated-answer-actions.ts | 10 ++--- .../generated-answer-analytics-actions.ts | 37 +++++++++---------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/packages/headless/src/features/generated-answer/generated-answer-actions.ts b/packages/headless/src/features/generated-answer/generated-answer-actions.ts index 37f3c5b6757..3fd238762b9 100644 --- a/packages/headless/src/features/generated-answer/generated-answer-actions.ts +++ b/packages/headless/src/features/generated-answer/generated-answer-actions.ts @@ -9,7 +9,7 @@ import {createAction, createAsyncThunk} from '@reduxjs/toolkit'; import {AsyncThunkGeneratedAnswerOptions} from '../../api/generated-answer/generated-answer-client'; import { GeneratedAnswerCitationsPayload, - /* GeneratedAnswerEndOfStreamPayload, */ + GeneratedAnswerEndOfStreamPayload, GeneratedAnswerMessagePayload, GeneratedAnswerPayloadType, GeneratedAnswerStreamEventData, @@ -21,8 +21,7 @@ import { SearchSection, } from '../../state/state-sections'; import {validatePayload} from '../../utils/validate-payload'; -// TODO: uncomment; this is making the build fail because this import doesn't exist -// import {logGeneratedAnswerStreamEnd} from './generated-answer-analytics-actions'; +import {logGeneratedAnswerStreamEnd} from './generated-answer-analytics-actions'; import {buildStreamingRequest} from './generated-answer-request'; type StateNeededByGeneratedAnswerStream = ConfigurationSection & @@ -125,8 +124,7 @@ export const streamAnswer = createAsyncThunk< ) ); break; - // TODO: uncomment; this is making the build fail because logGeneratedAnswerStreamEnd doesn't exist - /*case 'genqa.endOfStreamType': + case 'genqa.endOfStreamType': dispatch(setIsStreaming(false)); dispatch( logGeneratedAnswerStreamEnd( @@ -134,7 +132,7 @@ export const streamAnswer = createAsyncThunk< .answerGenerated ) ); - break; */ + break; default: if (state.debug) { extra.logger.warn(`Unknown payloadType: "${payloadType}"`); diff --git a/packages/headless/src/features/generated-answer/generated-answer-analytics-actions.ts b/packages/headless/src/features/generated-answer/generated-answer-analytics-actions.ts index 9191ceb8064..60fe89c0fe0 100644 --- a/packages/headless/src/features/generated-answer/generated-answer-analytics-actions.ts +++ b/packages/headless/src/features/generated-answer/generated-answer-analytics-actions.ts @@ -69,22 +69,21 @@ export const logDislikeGeneratedAnswer = (): CustomAction => } ); -// TODO: un-uncomment; this is currently failing the build because client.makeRetryGeneratedAnswer doesn't exist. -// export const logGeneratedAnswerStreamEnd = ( -// answerGenerated: boolean -// ): CustomAction => -// makeAnalyticsAction( -// 'analytics/generatedAnswer/streamEnd', -// AnalyticsType.Custom, -// (client, state) => { -// const generativeQuestionAnsweringId = -// generativeQuestionAnsweringIdSelector(state); -// if (!generativeQuestionAnsweringId) { -// return null; -// } -// return client.makeRetryGeneratedAnswer({ -// generativeQuestionAnsweringId, -// answerGenerated, -// }); -// } -// ); +export const logGeneratedAnswerStreamEnd = ( + answerGenerated: boolean +): CustomAction => + makeAnalyticsAction( + 'analytics/generatedAnswer/streamEnd', + AnalyticsType.Custom, + (client, state) => { + const generativeQuestionAnsweringId = + generativeQuestionAnsweringIdSelector(state); + if (!generativeQuestionAnsweringId) { + return null; + } + return client.makeGeneratedAnswerStreamEnd({ + generativeQuestionAnsweringId, + answerGenerated, + }); + } + );