diff --git a/public/hooks/use_feed_back.tsx b/public/hooks/use_feed_back.tsx index c06ad8b4..30ef375b 100644 --- a/public/hooks/use_feed_back.tsx +++ b/public/hooks/use_feed_back.tsx @@ -10,12 +10,18 @@ import { useChatContext } from '../contexts/chat_context'; import { useCore } from '../contexts/core_context'; import { useChatState } from './use_chat_state'; +interface AccountResponse { + data: { user_name: string; user_requested_tenant: string; roles: string[] }; +} + interface SendFeedbackBody { metadata: { type: 'event_analytics' | 'chat' | 'ppl_submit'; sessionId?: string; traceId?: string; error?: boolean; + user: string; + tenant: string; }; input: string; output: string; @@ -44,12 +50,15 @@ export const useFeedback = () => { return; } + const { username, tenant } = chatContext.currentAccount; const body: SendFeedbackBody = { metadata: { type: 'chat', // currently type is only chat in feedback sessionId: chatContext.sessionId, traceId: outputMessage.traceId, error: false, + user: username, + tenant, }, input: inputMessage.content, output: outputMessage.content, @@ -59,7 +68,7 @@ export const useFeedback = () => { }; try { - const response = await core.services.http.post(ASSISTANT_API.FEEDBACK, { + await core.services.http.post(ASSISTANT_API.FEEDBACK, { body: JSON.stringify(body), }); setFeedbackResult(correct); diff --git a/public/plugin.tsx b/public/plugin.tsx index f3f2512e..da4821bf 100644 --- a/public/plugin.tsx +++ b/public/plugin.tsx @@ -46,9 +46,9 @@ export class AssistantPlugin const actionExecutors: Record = {}; const assistantActions: AssistantActions = {} as AssistantActions; const getAccount = async () => { - return await core.http.get<{ data: { roles: string[]; user_name: string } }>( - '/api/v1/configuration/account' - ); + return await core.http.get<{ + data: { roles: string[]; user_name: string; user_requested_tenant: string | null }; + }>('/api/v1/configuration/account'); }; const assistantEnabled = (() => { let enabled: boolean; @@ -73,6 +73,7 @@ export class AssistantPlugin }); const account = await getAccount(); const username = account.data.user_name; + const tenant = account.data.user_requested_tenant ?? ''; coreStart.chrome.navControls.registerRight({ order: 10000, @@ -86,7 +87,7 @@ export class AssistantPlugin contentRenderers={contentRenderers} actionExecutors={actionExecutors} assistantActions={assistantActions} - currentAccount={{ username }} + currentAccount={{ username, tenant }} /> ), diff --git a/public/types.ts b/public/types.ts index 1797799d..d8f152a3 100644 --- a/public/types.ts +++ b/public/types.ts @@ -40,6 +40,7 @@ export interface AssistantStart {} export interface UserAccount { username: string; + tenant: string; } export interface ChatConfig {