@envive-ai/react-hooks 0.3.44 → 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.
Files changed (102) hide show
  1. package/dist/application/models/api/responseGenerics.d.cts +4 -2
  2. package/dist/application/models/api/responseGenerics.d.ts +4 -2
  3. package/dist/application/models/api/widgetText.d.cts +2 -1
  4. package/dist/application/models/api/widgetText.d.ts +2 -1
  5. package/dist/application/models/index.d.cts +2 -2
  6. package/dist/application/models/index.d.ts +2 -2
  7. package/dist/application/models/validators/validateResponse.cjs +3 -2
  8. package/dist/application/models/validators/validateResponse.js +3 -2
  9. package/dist/application/utils/widgetTextFromApiWidgetTextResponse.cjs +3 -2
  10. package/dist/application/utils/widgetTextFromApiWidgetTextResponse.js +3 -2
  11. package/dist/atoms/app/index.d.cts +7 -7
  12. package/dist/atoms/app/index.d.ts +7 -7
  13. package/dist/atoms/app/variant.cjs +2 -2
  14. package/dist/atoms/app/variant.d.cts +1 -1
  15. package/dist/atoms/app/variant.d.ts +1 -1
  16. package/dist/atoms/app/variant.js +2 -2
  17. package/dist/atoms/chat/chatState.d.ts +19 -19
  18. package/dist/atoms/chat/form.d.cts +2 -2
  19. package/dist/atoms/chat/form.d.ts +2 -2
  20. package/dist/atoms/chat/index.d.cts +3 -3
  21. package/dist/atoms/chat/index.d.ts +3 -3
  22. package/dist/atoms/chat/lastMessage.d.cts +2 -2
  23. package/dist/atoms/chat/lastMessage.d.ts +2 -2
  24. package/dist/atoms/chat/messageQueue.d.cts +6 -6
  25. package/dist/atoms/chat/messageQueue.d.ts +6 -6
  26. package/dist/atoms/chat/performanceMetrics.d.cts +6 -6
  27. package/dist/atoms/chat/performanceMetrics.d.ts +6 -6
  28. package/dist/atoms/chat/renderedWidgetRefs.d.cts +2 -2
  29. package/dist/atoms/chat/renderedWidgetRefs.d.ts +2 -2
  30. package/dist/atoms/chat/replies.d.cts +2 -2
  31. package/dist/atoms/chat/replies.d.ts +2 -2
  32. package/dist/atoms/chat/suggestions.d.cts +2 -2
  33. package/dist/atoms/chat/suggestions.d.ts +2 -2
  34. package/dist/atoms/envive/enviveConfig.d.cts +12 -12
  35. package/dist/atoms/envive/enviveConfig.d.ts +13 -13
  36. package/dist/atoms/globalSearch/globalSearch.d.cts +5 -5
  37. package/dist/atoms/globalSearch/globalSearch.d.ts +5 -5
  38. package/dist/atoms/org/customerService.d.cts +6 -6
  39. package/dist/atoms/org/customerService.d.ts +6 -6
  40. package/dist/atoms/org/graphqlConfig.d.cts +4 -4
  41. package/dist/atoms/org/graphqlConfig.d.ts +4 -4
  42. package/dist/atoms/org/newOrgConfigAtom.d.cts +2 -2
  43. package/dist/atoms/org/newOrgConfigAtom.d.ts +2 -2
  44. package/dist/atoms/org/orgAnalyticsConfig.d.cts +4 -4
  45. package/dist/atoms/org/orgAnalyticsConfig.d.ts +4 -4
  46. package/dist/atoms/search/chatSearch.d.cts +17 -17
  47. package/dist/atoms/search/chatSearch.d.ts +17 -17
  48. package/dist/atoms/search/searchAPI.d.cts +13 -13
  49. package/dist/atoms/search/searchAPI.d.ts +13 -13
  50. package/dist/atoms/search/types.d.ts +1 -1
  51. package/dist/atoms/widget/chatPreviewLoading.d.cts +2 -2
  52. package/dist/atoms/widget/chatPreviewLoading.d.ts +2 -2
  53. package/dist/contexts/pageContext/pageContext.cjs +2 -2
  54. package/dist/contexts/pageContext/pageContext.js +2 -2
  55. package/dist/contexts/salesAgentContext/salesAgentContext.cjs +4 -1
  56. package/dist/contexts/salesAgentContext/salesAgentContext.d.cts +2 -1
  57. package/dist/contexts/salesAgentContext/salesAgentContext.d.ts +2 -1
  58. package/dist/contexts/salesAgentContext/salesAgentContext.js +5 -2
  59. package/dist/contexts/salesAgentContext/salesAgentService.cjs +11 -3
  60. package/dist/contexts/salesAgentContext/salesAgentService.js +12 -4
  61. package/dist/contexts/types.d.cts +1 -1
  62. package/dist/contexts/types.d.ts +1 -1
  63. package/dist/contexts/typesV3.d.cts +1 -1
  64. package/dist/contexts/typesV3.d.ts +1 -1
  65. package/dist/hooks/PageViewedEvent/usePageViewedEvent.cjs +2 -2
  66. package/dist/hooks/PageViewedEvent/usePageViewedEvent.js +2 -2
  67. package/dist/hooks/ShopifyUrlOperations/useShopifyUrlOperations.d.cts +2 -2
  68. package/dist/hooks/ShopifyUrlOperations/useShopifyUrlOperations.d.ts +2 -2
  69. package/dist/hooks/WidgetInteraction/types.cjs +2 -2
  70. package/dist/hooks/WidgetInteraction/types.d.cts +2 -2
  71. package/dist/hooks/WidgetInteraction/types.d.ts +2 -2
  72. package/dist/hooks/WidgetInteraction/types.js +2 -2
  73. package/dist/hooks/WidgetInteraction/utils.cjs +2 -2
  74. package/dist/hooks/WidgetInteraction/utils.js +2 -2
  75. package/dist/hooks/utils.d.cts +1 -1
  76. package/dist/hooks/utils.d.ts +1 -1
  77. package/dist/services/amplitudeService/amplitudeService.cjs +2 -1
  78. package/dist/services/amplitudeService/amplitudeService.js +2 -1
  79. package/dist/services/enviveConfigService/enviveConfigService.cjs +34 -1
  80. package/dist/services/enviveConfigService/enviveConfigService.d.cts +4 -1
  81. package/dist/services/enviveConfigService/enviveConfigService.d.ts +4 -1
  82. package/dist/services/enviveConfigService/enviveConfigService.js +34 -1
  83. package/dist/services/hardcopyService/hardcopyService.cjs +3 -2
  84. package/dist/services/hardcopyService/hardcopyService.js +3 -2
  85. package/package.json +2 -2
  86. package/src/application/models/api/responseGenerics.ts +3 -0
  87. package/src/application/models/api/widgetText.ts +3 -0
  88. package/src/application/models/validators/validateResponse.ts +1 -0
  89. package/src/application/utils/widgetTextFromApiWidgetTextResponse.ts +1 -0
  90. package/src/atoms/app/variant.ts +1 -1
  91. package/src/contexts/pageContext/pageContext.tsx +1 -1
  92. package/src/contexts/salesAgentContext/salesAgentContext.tsx +7 -0
  93. package/src/contexts/salesAgentContext/salesAgentService.ts +12 -3
  94. package/src/hooks/PageViewedEvent/__tests__/usePageViewedEvent.test.ts +4 -4
  95. package/src/hooks/PageViewedEvent/usePageViewedEvent.ts +1 -1
  96. package/src/hooks/WidgetInteraction/types.ts +1 -1
  97. package/src/hooks/WidgetInteraction/utils.ts +1 -1
  98. package/src/services/amplitudeService/amplitudeService.ts +1 -0
  99. package/src/services/enviveConfigService/__tests__/enviveConfigService.test.ts +208 -0
  100. package/src/services/enviveConfigService/enviveConfigService.ts +60 -0
  101. package/src/services/hardcopyService/__tests__/hardcopyService.test.ts +47 -1
  102. 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;