@envive-ai/react-hooks 0.3.45 → 0.3.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application/models/api/widgetText.d.cts +2 -1
- package/dist/application/models/api/widgetText.d.ts +2 -1
- package/dist/application/models/index.cjs +1 -1
- package/dist/application/models/index.js +1 -1
- package/dist/application/models/validators/validateGraphQLFrontendConfig.cjs +1 -1
- package/dist/application/models/validators/validateGraphQLFrontendConfig.js +1 -1
- package/dist/application/utils/elementObserver.d.cts +2 -2
- package/dist/application/utils/elementObserver.d.ts +2 -2
- package/dist/application/utils/widgetTextFromApiWidgetTextResponse.cjs +3 -2
- package/dist/application/utils/widgetTextFromApiWidgetTextResponse.js +3 -2
- package/dist/atoms/app/index.d.cts +7 -7
- package/dist/atoms/app/index.d.ts +7 -7
- package/dist/atoms/app/variant.cjs +2 -2
- package/dist/atoms/app/variant.d.cts +1 -1
- package/dist/atoms/app/variant.d.ts +1 -1
- package/dist/atoms/app/variant.js +2 -2
- package/dist/atoms/chat/chatState.d.cts +18 -18
- package/dist/atoms/chat/chatState.d.ts +18 -18
- package/dist/atoms/chat/form.d.cts +2 -2
- package/dist/atoms/chat/form.d.ts +2 -2
- package/dist/atoms/chat/index.cjs +1 -1
- package/dist/atoms/chat/index.d.cts +2 -2
- package/dist/atoms/chat/index.d.ts +3 -3
- package/dist/atoms/chat/index.js +1 -1
- package/dist/atoms/chat/lastMessage.d.cts +2 -2
- package/dist/atoms/chat/lastMessage.d.ts +2 -2
- package/dist/atoms/chat/messageQueue.d.cts +6 -6
- package/dist/atoms/chat/messageQueue.d.ts +6 -6
- package/dist/atoms/chat/performanceMetrics.d.cts +6 -6
- package/dist/atoms/chat/performanceMetrics.d.ts +6 -6
- package/dist/atoms/chat/renderedWidgetRefs.d.cts +2 -2
- package/dist/atoms/chat/renderedWidgetRefs.d.ts +2 -2
- package/dist/atoms/chat/replies.d.cts +2 -2
- package/dist/atoms/chat/replies.d.ts +2 -2
- package/dist/atoms/chat/suggestions.d.cts +2 -2
- package/dist/atoms/chat/suggestions.d.ts +2 -2
- package/dist/atoms/envive/enviveConfig.d.cts +12 -12
- package/dist/atoms/envive/enviveConfig.d.ts +13 -13
- package/dist/atoms/globalSearch/globalSearch.d.cts +5 -5
- package/dist/atoms/globalSearch/globalSearch.d.ts +5 -5
- package/dist/atoms/org/customerService.d.cts +6 -6
- package/dist/atoms/org/customerService.d.ts +6 -6
- package/dist/atoms/org/graphqlConfig.d.cts +4 -4
- package/dist/atoms/org/graphqlConfig.d.ts +4 -4
- package/dist/atoms/org/index.cjs +1 -1
- package/dist/atoms/org/index.js +1 -1
- package/dist/atoms/org/newOrgConfigAtom.d.cts +2 -2
- package/dist/atoms/org/newOrgConfigAtom.d.ts +2 -2
- package/dist/atoms/org/orgAnalyticsConfig.d.cts +4 -4
- package/dist/atoms/org/orgAnalyticsConfig.d.ts +4 -4
- package/dist/atoms/search/chatSearch.cjs +1 -1
- package/dist/atoms/search/chatSearch.d.cts +17 -17
- package/dist/atoms/search/chatSearch.d.ts +17 -17
- package/dist/atoms/search/chatSearch.js +1 -1
- package/dist/atoms/search/searchAPI.cjs +1 -1
- package/dist/atoms/search/searchAPI.d.cts +13 -13
- package/dist/atoms/search/searchAPI.d.ts +13 -13
- package/dist/atoms/search/searchAPI.js +1 -1
- package/dist/atoms/widget/chatPreviewLoading.d.cts +2 -2
- package/dist/atoms/widget/chatPreviewLoading.d.ts +2 -2
- package/dist/contexts/enviveContext/types.d.cts +1 -1
- package/dist/contexts/enviveContext/types.d.ts +1 -1
- package/dist/contexts/pageContext/pageContext.cjs +2 -2
- package/dist/contexts/pageContext/pageContext.js +2 -2
- package/dist/contexts/salesAgentContext/chatAPI.cjs +2 -2
- package/dist/contexts/salesAgentContext/chatAPI.js +2 -2
- package/dist/contexts/salesAgentContext/salesAgentContext.cjs +4 -1
- package/dist/contexts/salesAgentContext/salesAgentContext.d.cts +2 -1
- package/dist/contexts/salesAgentContext/salesAgentContext.d.ts +2 -1
- package/dist/contexts/salesAgentContext/salesAgentContext.js +5 -2
- package/dist/contexts/salesAgentContext/salesAgentService.cjs +12 -4
- package/dist/contexts/salesAgentContext/salesAgentService.js +12 -4
- package/dist/contexts/searchContext/searchContext.cjs +1 -1
- package/dist/contexts/searchContext/searchContext.js +1 -1
- package/dist/contexts/systemSettingsContext/systemSettingsContext.d.cts +2 -2
- package/dist/contexts/systemSettingsContext/systemSettingsContext.d.ts +2 -2
- package/dist/contexts/types.d.cts +1 -1
- package/dist/contexts/types.d.ts +1 -1
- package/dist/contexts/typesV3.d.cts +1 -1
- package/dist/contexts/typesV3.d.ts +1 -1
- package/dist/contexts/widgetConfigContext/widgetConfigContext.cjs +1 -1
- package/dist/contexts/widgetConfigContext/widgetConfigContext.js +1 -1
- package/dist/hooks/ChatToggle/useChatToggle.cjs +1 -1
- package/dist/hooks/ChatToggle/useChatToggle.js +1 -1
- package/dist/hooks/GrabAndScroll/useGrabAndScroll.d.cts +2 -2
- package/dist/hooks/PageViewedEvent/usePageViewedEvent.cjs +2 -2
- package/dist/hooks/PageViewedEvent/usePageViewedEvent.js +2 -2
- package/dist/hooks/Search/useSearch.cjs +3 -3
- package/dist/hooks/Search/useSearch.js +3 -3
- package/dist/hooks/WidgetInteraction/types.cjs +2 -2
- package/dist/hooks/WidgetInteraction/types.d.cts +2 -2
- package/dist/hooks/WidgetInteraction/types.d.ts +2 -2
- package/dist/hooks/WidgetInteraction/types.js +2 -2
- package/dist/hooks/WidgetInteraction/utils.cjs +2 -2
- package/dist/hooks/WidgetInteraction/utils.js +2 -2
- package/dist/hooks/utils.d.cts +1 -1
- package/dist/services/amplitudeService/amplitudeService.cjs +3 -2
- package/dist/services/amplitudeService/amplitudeService.js +3 -2
- package/dist/services/enviveConfigService/enviveConfigService.cjs +34 -1
- package/dist/services/enviveConfigService/enviveConfigService.d.cts +4 -1
- package/dist/services/enviveConfigService/enviveConfigService.d.ts +4 -1
- package/dist/services/enviveConfigService/enviveConfigService.js +34 -1
- package/dist/services/enviveConfigService/fetchGraphQLConfig.cjs +1 -1
- package/dist/services/enviveConfigService/fetchGraphQLConfig.js +1 -1
- package/dist/services/hardcopyService/hardcopyService.cjs +4 -3
- package/dist/services/hardcopyService/hardcopyService.js +4 -3
- package/package.json +2 -2
- package/src/application/models/api/widgetText.ts +3 -0
- package/src/application/utils/widgetTextFromApiWidgetTextResponse.ts +1 -0
- package/src/atoms/app/variant.ts +1 -1
- package/src/contexts/pageContext/pageContext.tsx +1 -1
- package/src/contexts/salesAgentContext/salesAgentContext.tsx +7 -0
- package/src/contexts/salesAgentContext/salesAgentService.ts +12 -3
- package/src/hooks/PageViewedEvent/__tests__/usePageViewedEvent.test.ts +4 -4
- package/src/hooks/PageViewedEvent/usePageViewedEvent.ts +1 -1
- package/src/hooks/WidgetInteraction/types.ts +1 -1
- package/src/hooks/WidgetInteraction/utils.ts +1 -1
- package/src/services/amplitudeService/amplitudeService.ts +1 -0
- package/src/services/enviveConfigService/__tests__/enviveConfigService.test.ts +208 -0
- package/src/services/enviveConfigService/enviveConfigService.ts +60 -0
- package/src/services/hardcopyService/__tests__/hardcopyService.test.ts +47 -1
- package/src/services/hardcopyService/hardcopyService.ts +5 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WidgetTypeV3 } from 'src/contexts/typesV3';
|
|
2
2
|
import type { WidgetText } from 'src/application/models/api/widgetText';
|
|
3
3
|
import type { AppDetails } from 'src/atoms/app';
|
|
4
|
-
import { EnviveMetricsEventName } from 'src/services/amplitudeService';
|
|
4
|
+
import { EnviveMetricsEventName, TrackEventParams } from 'src/services/amplitudeService';
|
|
5
5
|
import { getAtomStore } from 'src/atoms/atomStore/atomStore';
|
|
6
6
|
import { resolvedBaseConfigVersionAtom } from 'src/atoms/envive/resolvedBaseConfigVersion';
|
|
7
7
|
import { HardcopyService, MOCK_HARDCOPY_RESPONSE, MockHardcopyService } from '../hardcopyService';
|
|
@@ -269,6 +269,52 @@ describe('HardcopyService', () => {
|
|
|
269
269
|
);
|
|
270
270
|
});
|
|
271
271
|
|
|
272
|
+
it('forwards ai_suggestions_attribution_by_slot on WidgetTextResponse when present', async () => {
|
|
273
|
+
const trackEvent = vi.fn();
|
|
274
|
+
const attribution = {
|
|
275
|
+
prompt_button_texts: {
|
|
276
|
+
served_method_id: 'variant_b',
|
|
277
|
+
served_method_type: 'bandit_pbm',
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
mockGetHardcopy.mockResolvedValueOnce(
|
|
281
|
+
makeWidgetTextResponse({ aiSuggestionsAttributionBySlot: attribution }),
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
await makeService(trackEvent).getHardcopy({
|
|
285
|
+
widgetType: WidgetTypeV3.ChatPreviewV3,
|
|
286
|
+
userEvent: {} as any,
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
expect(trackEvent).toHaveBeenCalledWith(
|
|
290
|
+
expect.objectContaining({
|
|
291
|
+
eventName: EnviveMetricsEventName.WidgetTextResponse,
|
|
292
|
+
eventProps: expect.objectContaining({
|
|
293
|
+
ai_suggestions_attribution_by_slot: attribution,
|
|
294
|
+
}),
|
|
295
|
+
}),
|
|
296
|
+
);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it('omits ai_suggestions_attribution_by_slot when the response carries none', async () => {
|
|
300
|
+
const trackEvent = vi.fn();
|
|
301
|
+
mockGetHardcopy.mockResolvedValueOnce(makeWidgetTextResponse());
|
|
302
|
+
|
|
303
|
+
await makeService(trackEvent).getHardcopy({
|
|
304
|
+
widgetType: WidgetTypeV3.ChatPreviewV3,
|
|
305
|
+
userEvent: {} as any,
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
const responseEvent = trackEvent.mock.calls
|
|
309
|
+
.map(([params]: [TrackEventParams]) => params)
|
|
310
|
+
.find(
|
|
311
|
+
(params: TrackEventParams) =>
|
|
312
|
+
params.eventName === EnviveMetricsEventName.WidgetTextResponse,
|
|
313
|
+
);
|
|
314
|
+
expect(responseEvent).toBeDefined();
|
|
315
|
+
expect(responseEvent!.eventProps).not.toHaveProperty('ai_suggestions_attribution_by_slot');
|
|
316
|
+
});
|
|
317
|
+
|
|
272
318
|
it('does not crash when trackEvent is not provided', async () => {
|
|
273
319
|
const service = new HardcopyService({
|
|
274
320
|
getAppDetails: () => mockAppDetails,
|
|
@@ -237,6 +237,11 @@ export class HardcopyService implements IHardcopyService {
|
|
|
237
237
|
response_id: response.responseId,
|
|
238
238
|
widget_text: response.values,
|
|
239
239
|
request_id: widgetTextRequest.requestId,
|
|
240
|
+
// Which method served each overridden slot — training/attribution
|
|
241
|
+
// reads this from the analytics event; passed through verbatim.
|
|
242
|
+
...(response.aiSuggestionsAttributionBySlot
|
|
243
|
+
? { ai_suggestions_attribution_by_slot: response.aiSuggestionsAttributionBySlot }
|
|
244
|
+
: {}),
|
|
240
245
|
},
|
|
241
246
|
});
|
|
242
247
|
return convertedResponse;
|