@envive-ai/react-hooks 0.3.11 → 0.3.13

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 (210) hide show
  1. package/dist/application/commerce-api.cjs +21 -41
  2. package/dist/application/commerce-api.d.cts +2 -4
  3. package/dist/application/commerce-api.d.ts +2 -4
  4. package/dist/application/commerce-api.js +21 -41
  5. package/dist/application/models/api/widgetTextRequest.d.cts +2 -1
  6. package/dist/application/models/api/widgetTextRequest.d.ts +2 -1
  7. package/dist/application/models/chatElementDisplayLocationV3.cjs +3 -1
  8. package/dist/application/models/chatElementDisplayLocationV3.d.cts +3 -1
  9. package/dist/application/models/chatElementDisplayLocationV3.d.ts +3 -1
  10. package/dist/application/models/chatElementDisplayLocationV3.js +3 -1
  11. package/dist/application/models/guards/api/index.cjs +6 -6
  12. package/dist/application/models/guards/api/index.js +6 -6
  13. package/dist/application/models/index.cjs +18 -18
  14. package/dist/application/models/index.js +18 -18
  15. package/dist/application/models/validators/validateResponse.cjs +3 -3
  16. package/dist/application/models/validators/validateResponse.js +3 -3
  17. package/dist/application/models/variantInfo/variantInfo.cjs +1 -1
  18. package/dist/application/models/variantInfo/variantInfo.d.cts +1 -1
  19. package/dist/application/models/variantInfo/variantInfo.d.ts +1 -1
  20. package/dist/application/models/variantInfo/variantInfo.js +1 -1
  21. package/dist/application/utils/analyticsUtils.cjs +5 -5
  22. package/dist/application/utils/analyticsUtils.d.cts +2 -2
  23. package/dist/application/utils/analyticsUtils.d.ts +2 -2
  24. package/dist/application/utils/analyticsUtils.js +3 -3
  25. package/dist/application/utils/nodeSelector.cjs +12 -14
  26. package/dist/application/utils/nodeSelector.js +12 -14
  27. package/dist/application/utils/widgetTextRequestToApiRequest.cjs +2 -1
  28. package/dist/application/utils/widgetTextRequestToApiRequest.js +2 -1
  29. package/dist/atoms/app/index.d.cts +7 -7
  30. package/dist/atoms/app/index.d.ts +7 -7
  31. package/dist/atoms/chat/chatState.cjs +5 -5
  32. package/dist/atoms/chat/chatState.d.cts +19 -19
  33. package/dist/atoms/chat/chatState.d.ts +19 -19
  34. package/dist/atoms/chat/chatState.js +3 -3
  35. package/dist/atoms/chat/form.d.cts +2 -2
  36. package/dist/atoms/chat/form.d.ts +2 -2
  37. package/dist/atoms/chat/index.d.ts +2 -2
  38. package/dist/atoms/chat/lastMessage.d.cts +2 -2
  39. package/dist/atoms/chat/lastMessage.d.ts +2 -2
  40. package/dist/atoms/chat/messageQueue.d.cts +6 -6
  41. package/dist/atoms/chat/messageQueue.d.ts +6 -6
  42. package/dist/atoms/chat/performanceMetrics.d.cts +6 -6
  43. package/dist/atoms/chat/performanceMetrics.d.ts +6 -6
  44. package/dist/atoms/chat/renderedWidgetRefs.d.cts +2 -2
  45. package/dist/atoms/chat/renderedWidgetRefs.d.ts +2 -2
  46. package/dist/atoms/chat/replies.cjs +4 -4
  47. package/dist/atoms/chat/replies.d.cts +3 -3
  48. package/dist/atoms/chat/replies.d.ts +3 -3
  49. package/dist/atoms/chat/replies.js +3 -3
  50. package/dist/atoms/chat/suggestions.d.cts +2 -2
  51. package/dist/atoms/chat/suggestions.d.ts +2 -2
  52. package/dist/atoms/envive/enviveConfig.d.cts +13 -13
  53. package/dist/atoms/envive/enviveConfig.d.ts +13 -13
  54. package/dist/atoms/globalSearch/globalSearch.d.cts +5 -5
  55. package/dist/atoms/globalSearch/globalSearch.d.ts +5 -5
  56. package/dist/atoms/org/customerService.d.cts +6 -6
  57. package/dist/atoms/org/customerService.d.ts +6 -6
  58. package/dist/atoms/org/graphqlConfig.d.cts +4 -4
  59. package/dist/atoms/org/graphqlConfig.d.ts +4 -4
  60. package/dist/atoms/org/index.cjs +1 -1
  61. package/dist/atoms/org/index.js +1 -1
  62. package/dist/atoms/org/newOrgConfigAtom.d.cts +2 -2
  63. package/dist/atoms/org/newOrgConfigAtom.d.ts +2 -2
  64. package/dist/atoms/org/orgAnalyticsConfig.d.cts +5 -5
  65. package/dist/atoms/org/orgAnalyticsConfig.d.ts +5 -5
  66. package/dist/atoms/search/chatSearch.d.cts +17 -17
  67. package/dist/atoms/search/searchAPI.d.cts +13 -13
  68. package/dist/atoms/search/searchAPI.d.ts +13 -13
  69. package/dist/atoms/search/utils.d.cts +1 -1
  70. package/dist/atoms/search/utils.d.ts +1 -1
  71. package/dist/atoms/widget/chatPreviewLoading.d.cts +2 -2
  72. package/dist/atoms/widget/chatPreviewLoading.d.ts +2 -2
  73. package/dist/contexts/amplitudeContext/amplitudeContext.cjs +5 -5
  74. package/dist/contexts/amplitudeContext/amplitudeContext.d.cts +3 -2
  75. package/dist/contexts/amplitudeContext/amplitudeContext.d.ts +3 -2
  76. package/dist/contexts/amplitudeContext/amplitudeContext.js +5 -5
  77. package/dist/contexts/amplitudeContext/index.cjs +3 -3
  78. package/dist/contexts/amplitudeContext/index.d.cts +1 -1
  79. package/dist/contexts/amplitudeContext/index.d.ts +1 -1
  80. package/dist/contexts/amplitudeContext/index.js +1 -1
  81. package/dist/contexts/cdnContext/cdnContext.cjs +1 -1
  82. package/dist/contexts/cdnContext/cdnContext.js +1 -1
  83. package/dist/contexts/enviveConfigContext/enviveConfigContext.cjs +1 -1
  84. package/dist/contexts/enviveConfigContext/enviveConfigContext.js +1 -1
  85. package/dist/contexts/enviveContext/enviveContext.cjs +17 -14
  86. package/dist/contexts/enviveContext/enviveContext.d.cts +4 -1
  87. package/dist/contexts/enviveContext/enviveContext.d.ts +4 -1
  88. package/dist/contexts/enviveContext/enviveContext.js +17 -14
  89. package/dist/contexts/graphqlContext/graphqlContext.cjs +2 -2
  90. package/dist/contexts/graphqlContext/graphqlContext.js +2 -2
  91. package/dist/contexts/graphqlContext/mockV3Config.cjs +3 -2
  92. package/dist/contexts/graphqlContext/mockV3Config.js +3 -2
  93. package/dist/contexts/hardcopyContext/hardcopyContext.cjs +18 -8
  94. package/dist/contexts/hardcopyContext/hardcopyContext.d.cts +6 -4
  95. package/dist/contexts/hardcopyContext/hardcopyContext.d.ts +6 -4
  96. package/dist/contexts/hardcopyContext/hardcopyContext.js +16 -6
  97. package/dist/contexts/newOrgConfigContext/newOrgConfigContext.cjs +1 -1
  98. package/dist/contexts/newOrgConfigContext/newOrgConfigContext.js +1 -1
  99. package/dist/contexts/pageContext/pageContext.cjs +11 -7
  100. package/dist/contexts/pageContext/pageContext.js +11 -7
  101. package/dist/contexts/pageContext/types.d.cts +1 -1
  102. package/dist/contexts/salesAgentContext/chatAPI.cjs +11 -11
  103. package/dist/contexts/salesAgentContext/chatAPI.js +4 -4
  104. package/dist/contexts/salesAgentContext/salesAgentContext.cjs +1 -1
  105. package/dist/contexts/salesAgentContext/salesAgentContext.js +1 -1
  106. package/dist/contexts/salesAgentContext/salesAgentService.cjs +9 -8
  107. package/dist/contexts/salesAgentContext/salesAgentService.js +7 -6
  108. package/dist/contexts/searchContext/searchContext.cjs +2 -2
  109. package/dist/contexts/searchContext/searchContext.js +2 -2
  110. package/dist/contexts/systemSettingsContext/systemSettingsContext.cjs +1 -1
  111. package/dist/contexts/systemSettingsContext/systemSettingsContext.d.cts +2 -2
  112. package/dist/contexts/systemSettingsContext/systemSettingsContext.d.ts +2 -2
  113. package/dist/contexts/systemSettingsContext/systemSettingsContext.js +1 -1
  114. package/dist/contexts/types.cjs +1 -1
  115. package/dist/contexts/types.d.cts +4 -2
  116. package/dist/contexts/types.d.ts +4 -2
  117. package/dist/contexts/types.js +1 -1
  118. package/dist/contexts/typesV3.cjs +1 -1
  119. package/dist/contexts/typesV3.d.cts +27 -2
  120. package/dist/contexts/typesV3.d.ts +27 -2
  121. package/dist/contexts/typesV3.js +1 -1
  122. package/dist/contexts/userIdentityContext/userIdentityContext.cjs +2 -34
  123. package/dist/contexts/userIdentityContext/userIdentityContext.d.cts +1 -2
  124. package/dist/contexts/userIdentityContext/userIdentityContext.d.ts +1 -2
  125. package/dist/contexts/userIdentityContext/userIdentityContext.js +2 -33
  126. package/dist/hooks/AmplitudeOperations/useAmplitudeOperations.cjs +1 -1
  127. package/dist/hooks/AmplitudeOperations/useAmplitudeOperations.d.cts +2 -2
  128. package/dist/hooks/AmplitudeOperations/useAmplitudeOperations.d.ts +2 -2
  129. package/dist/hooks/AmplitudeOperations/useAmplitudeOperations.js +1 -1
  130. package/dist/hooks/ChatToggle/useChatToggle.cjs +6 -5
  131. package/dist/hooks/ChatToggle/useChatToggle.js +4 -3
  132. package/dist/hooks/GrabAndScroll/useGrabAndScroll.d.cts +2 -2
  133. package/dist/hooks/GrabAndScroll/useGrabAndScroll.d.ts +2 -2
  134. package/dist/hooks/Search/useSearch.cjs +9 -8
  135. package/dist/hooks/Search/useSearch.js +4 -3
  136. package/dist/hooks/Search/useSearchInput.cjs +7 -7
  137. package/dist/hooks/Search/useSearchInput.js +4 -4
  138. package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.cjs +6 -5
  139. package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.d.cts +2 -2
  140. package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.d.ts +2 -2
  141. package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.js +3 -2
  142. package/dist/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.cjs +4 -3
  143. package/dist/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.js +3 -2
  144. package/dist/hooks/utils.d.ts +1 -1
  145. package/dist/services/amplitudeService/amplitudeService.cjs +17 -57
  146. package/dist/services/amplitudeService/amplitudeService.d.cts +4 -47
  147. package/dist/services/amplitudeService/amplitudeService.d.ts +4 -47
  148. package/dist/services/amplitudeService/amplitudeService.js +14 -52
  149. package/dist/services/amplitudeService/eventNames.cjs +59 -0
  150. package/dist/services/amplitudeService/eventNames.d.cts +54 -0
  151. package/dist/services/amplitudeService/eventNames.d.ts +54 -0
  152. package/dist/services/amplitudeService/eventNames.js +57 -0
  153. package/dist/services/amplitudeService/index.cjs +3 -2
  154. package/dist/services/amplitudeService/index.d.cts +2 -1
  155. package/dist/services/amplitudeService/index.d.ts +2 -1
  156. package/dist/services/amplitudeService/index.js +2 -1
  157. package/dist/services/ga4ProjectionService/ga4EventSchema.cjs +108 -0
  158. package/dist/services/ga4ProjectionService/ga4EventSchema.js +108 -0
  159. package/dist/services/ga4ProjectionService/ga4ProjectionService.cjs +71 -0
  160. package/dist/services/ga4ProjectionService/ga4ProjectionService.js +71 -0
  161. package/dist/types/customerService.cjs +2 -1
  162. package/dist/types/customerService.d.cts +2 -1
  163. package/dist/types/customerService.d.ts +2 -1
  164. package/dist/types/customerService.js +2 -1
  165. package/dist/types/enviveConfig.d.cts +4 -1
  166. package/dist/types/enviveConfig.d.ts +4 -1
  167. package/package.json +2 -7
  168. package/src/application/commerce-api.ts +25 -49
  169. package/src/application/models/api/widgetTextRequest.ts +1 -0
  170. package/src/application/models/chatElementDisplayLocationV3.ts +2 -0
  171. package/src/application/models/variantInfo/variantInfo.ts +1 -1
  172. package/src/application/utils/analyticsUtils.ts +1 -1
  173. package/src/application/utils/nodeSelector.ts +15 -14
  174. package/src/application/utils/widgetTextRequestToApiRequest.ts +1 -0
  175. package/src/atoms/chat/chatState.ts +1 -1
  176. package/src/atoms/chat/replies.ts +1 -1
  177. package/src/contexts/amplitudeContext/amplitudeContext.tsx +0 -1
  178. package/src/contexts/enviveContext/enviveContext.tsx +5 -2
  179. package/src/contexts/graphqlContext/mockV3Config.ts +3 -0
  180. package/src/contexts/hardcopyContext/hardcopyContext.tsx +20 -2
  181. package/src/contexts/pageContext/pageContext.tsx +9 -5
  182. package/src/contexts/salesAgentContext/chatAPI.ts +0 -1
  183. package/src/contexts/salesAgentContext/salesAgentService.ts +5 -2
  184. package/src/contexts/types.ts +3 -1
  185. package/src/contexts/typesV3.ts +28 -0
  186. package/src/contexts/userIdentityContext/__tests__/userIdentityContext.test.tsx +1 -66
  187. package/src/contexts/userIdentityContext/userIdentityContext.tsx +0 -47
  188. package/src/hooks/AmplitudeOperations/useAmplitudeOperations.ts +2 -4
  189. package/src/hooks/ChatToggle/useChatToggle.ts +2 -4
  190. package/src/hooks/Search/useSearch.tsx +2 -4
  191. package/src/hooks/Search/useSearchInput.ts +1 -1
  192. package/src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.ts +2 -4
  193. package/src/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.ts +2 -4
  194. package/src/services/amplitudeService/amplitudeService.ts +14 -50
  195. package/src/services/amplitudeService/eventNames.ts +52 -0
  196. package/src/services/ga4ProjectionService/__tests__/ga4ProjectionService.test.ts +334 -0
  197. package/src/services/ga4ProjectionService/ga4EventSchema.ts +143 -0
  198. package/src/services/ga4ProjectionService/ga4ProjectionService.ts +137 -0
  199. package/src/types/customerService.ts +1 -0
  200. package/src/types/enviveConfig.ts +3 -0
  201. package/dist/hooks/IdentifyUser/index.cjs +0 -3
  202. package/dist/hooks/IdentifyUser/index.d.cts +0 -2
  203. package/dist/hooks/IdentifyUser/index.d.ts +0 -2
  204. package/dist/hooks/IdentifyUser/index.js +0 -3
  205. package/dist/hooks/IdentifyUser/useIdentifyUser.cjs +0 -35
  206. package/dist/hooks/IdentifyUser/useIdentifyUser.d.cts +0 -10
  207. package/dist/hooks/IdentifyUser/useIdentifyUser.d.ts +0 -10
  208. package/dist/hooks/IdentifyUser/useIdentifyUser.js +0 -34
  209. package/src/hooks/IdentifyUser/index.ts +0 -1
  210. package/src/hooks/IdentifyUser/useIdentifyUser.ts +0 -29
@@ -0,0 +1,137 @@
1
+ import Logger from 'src/application/logging/logger';
2
+ import { EnviveMetricsEventName } from '../amplitudeService/eventNames';
3
+ import { GA4ProjectedEventConfig, GA4_EVENT_SCHEMA } from './ga4EventSchema';
4
+
5
+ const filterToSchema = (
6
+ eventProps: Record<string, unknown>,
7
+ allowedFields: readonly string[],
8
+ ): Record<string, unknown> => {
9
+ const result: Record<string, unknown> = {};
10
+ for (const field of allowedFields) {
11
+ if (field in eventProps) {
12
+ result[field] = eventProps[field];
13
+ }
14
+ }
15
+ return result;
16
+ };
17
+
18
+ // "context.page_type" → "context_page_type"
19
+ const flattenDotKeys = (obj: Record<string, unknown>): Record<string, unknown> => {
20
+ const result: Record<string, unknown> = {};
21
+ for (const [key, value] of Object.entries(obj)) {
22
+ result[key.replace(/\./g, '_')] = value;
23
+ }
24
+ return result;
25
+ };
26
+
27
+ // Omit context.page_id for non-pdp/plp page types. The current implementation for context.page_id is:
28
+ // PDP: product_id
29
+ // PLP: plp_id
30
+ // Search: search query
31
+ // Other: page url
32
+ // We want to omit all but pdp and plp page types to provide a clear, consistent interface for merchants.
33
+ const sanitizePageId = (filtered: Record<string, unknown>): Record<string, unknown> => {
34
+ const pageType = filtered['context.page_type'];
35
+ if (pageType === 'pdp' || pageType === 'plp') {
36
+ return filtered;
37
+ }
38
+ const rest = { ...filtered };
39
+ delete rest['context.page_id'];
40
+ return rest;
41
+ };
42
+
43
+ // Extract whitelisted sub-fields from trigger.widget_interaction_data
44
+ const projectWidgetInteractionData = (
45
+ eventProps: Record<string, unknown>,
46
+ config: GA4ProjectedEventConfig,
47
+ ): Record<string, unknown> => {
48
+ if (!config.widgetInteractionDataProjections) {
49
+ return {};
50
+ }
51
+
52
+ const interaction = eventProps['trigger.widget_interaction'];
53
+ if (typeof interaction !== 'string') {
54
+ return {};
55
+ }
56
+
57
+ const projectionMap = config.widgetInteractionDataProjections[interaction];
58
+ if (!projectionMap) {
59
+ return {};
60
+ }
61
+
62
+ const interactionData = eventProps['trigger.widget_interaction_data'];
63
+ if (
64
+ interactionData === null ||
65
+ interactionData === undefined ||
66
+ typeof interactionData !== 'object'
67
+ ) {
68
+ return {};
69
+ }
70
+
71
+ const data = interactionData as Record<string, unknown>;
72
+ const result: Record<string, unknown> = {};
73
+ for (const [gaKey, sourceField] of Object.entries(projectionMap)) {
74
+ if (sourceField in data) {
75
+ result[gaKey] = data[sourceField];
76
+ }
77
+ }
78
+ return result;
79
+ };
80
+
81
+ const truncateString = (value: unknown): unknown => {
82
+ if (typeof value === 'string' && value.length > 100) {
83
+ return `${value.substring(0, 97)}...`;
84
+ }
85
+ return value;
86
+ };
87
+
88
+ const truncateValues = (obj: Record<string, unknown>): Record<string, unknown> => {
89
+ const result: Record<string, unknown> = {};
90
+ for (const [key, value] of Object.entries(obj)) {
91
+ result[key] = truncateString(value);
92
+ }
93
+ return result;
94
+ };
95
+
96
+ const pushToDataLayer = (gaEvent: Record<string, unknown>): void => {
97
+ if (typeof window !== 'undefined' && window.dataLayer) {
98
+ window.dataLayer.push(gaEvent);
99
+ }
100
+ };
101
+
102
+ export const projectToGA4 = (
103
+ eventName: EnviveMetricsEventName,
104
+ eventProps?: Record<string, unknown>,
105
+ ): void => {
106
+ try {
107
+ const schemaEntry = GA4_EVENT_SCHEMA[eventName];
108
+
109
+ if (schemaEntry.gaEventName === null) {
110
+ return;
111
+ }
112
+
113
+ const config = schemaEntry;
114
+ const props = eventProps ?? {};
115
+
116
+ let filtered = filterToSchema(props, config.allowedFields);
117
+ filtered = sanitizePageId(filtered);
118
+
119
+ const interactionFields = projectWidgetInteractionData(props, config);
120
+
121
+ const flatParams = {
122
+ ...flattenDotKeys(filtered),
123
+ ...interactionFields,
124
+ };
125
+
126
+ const truncatedParams = truncateValues(flatParams);
127
+
128
+ pushToDataLayer({
129
+ event: config.gaEventName,
130
+ ...truncatedParams,
131
+ });
132
+ } catch (err) {
133
+ Logger.logError('[envive-ai] Error projecting event to GA4', err, {
134
+ eventName,
135
+ });
136
+ }
137
+ };
@@ -11,6 +11,7 @@ export enum CustomerServiceType {
11
11
  gladly = 'gladly',
12
12
  richpanel = 'richpanel',
13
13
  zendesk = 'zendesk',
14
+ eightByEight = '8x8',
14
15
  unsupported = 'unsupported',
15
16
  }
16
17
  export enum CustomerServiceIntegrationMode {
@@ -1,4 +1,6 @@
1
1
  import { FrontendConfigOverrides, VariantInfo } from 'src/application/models';
2
+ import type { HardcopyResponse } from 'src/contexts/hardcopyContext/hardcopyContext';
3
+ import type { WidgetTypeV3 } from 'src/contexts/typesV3';
2
4
 
3
5
  export interface EnviveConfig {
4
6
  publicKey?: string;
@@ -15,6 +17,7 @@ export interface EnviveConfig {
15
17
  initialOpenSearchOverlay?: boolean;
16
18
  WidgetMountingOverride?: Record<string, any>[];
17
19
  configChanges?: FrontendConfigOverrides[];
20
+ hardcopyOverride?: Partial<Record<WidgetTypeV3, HardcopyResponse>>;
18
21
  }
19
22
 
20
23
  declare global {
@@ -1,3 +0,0 @@
1
- const require_useIdentifyUser = require('./useIdentifyUser.cjs');
2
-
3
- exports.useIdentifyUser = require_useIdentifyUser.useIdentifyUser;
@@ -1,2 +0,0 @@
1
- import { useIdentifyUser } from "./useIdentifyUser.cjs";
2
- export { useIdentifyUser };
@@ -1,2 +0,0 @@
1
- import { useIdentifyUser } from "./useIdentifyUser.js";
2
- export { useIdentifyUser };
@@ -1,3 +0,0 @@
1
- import { useIdentifyUser } from "./useIdentifyUser.js";
2
-
3
- export { useIdentifyUser };
@@ -1,35 +0,0 @@
1
- const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
- const require_userIdentityContext = require('../../contexts/userIdentityContext/userIdentityContext.cjs');
3
- let react = require("react");
4
-
5
- //#region src/hooks/IdentifyUser/useIdentifyUser.ts
6
- const useIdentifyUser = () => {
7
- const { identifyUser, isReady } = require_userIdentityContext.useUserIdentity();
8
- const [loading, setLoading] = (0, react.useState)(false);
9
- const [error, setError] = (0, react.useState)(null);
10
- return {
11
- loading,
12
- error,
13
- executeIdentifyUser: (0, react.useCallback)(async () => {
14
- if (!isReady) {
15
- setError(/* @__PURE__ */ new Error("UserIdentityContext not ready."));
16
- return;
17
- }
18
- setLoading(true);
19
- setError(null);
20
- try {
21
- await identifyUser();
22
- } catch (err) {
23
- setError(err instanceof Error ? err : /* @__PURE__ */ new Error("Unknown error during user identification."));
24
- throw err;
25
- } finally {
26
- setLoading(false);
27
- }
28
- }, [identifyUser, isReady]),
29
- isReady
30
- };
31
- };
32
-
33
- //#endregion
34
- exports.useIdentifyUser = useIdentifyUser;
35
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XJyIGluc3RhbmNlb2YgRXJyb3IgPyBlcnIgOiBuZXcgRXJyb3IoJ1Vua25vd24gZXJyb3IgZHVyaW5nIHVzZXIgaWRlbnRpZmljYXRpb24uJykpO1xuICAgICAgdGhyb3cgZXJyO1xuICAgIH0gZmluYWxseSB7XG4gICAgICBzZXRMb2FkaW5nKGZhbHNlKTtcbiAgICB9XG4gIH0sIFtpZGVudGlmeVVzZXIsIGlzUmVhZHldKTtcblxuICByZXR1cm4geyBsb2FkaW5nLCBlcnJvciwgZXhlY3V0ZUlkZW50aWZ5VXNlciwgaXNSZWFkeSB9O1xufTtcbiJdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFHQSxNQUFhLHdCQUF3QjtDQUNuQyxNQUFNLEVBQUUsY0FBYyxZQUFZQSw2Q0FBaUI7Q0FDbkQsTUFBTSxDQUFDLFNBQVMsa0NBQXVCLE1BQU07Q0FDN0MsTUFBTSxDQUFDLE9BQU8sZ0NBQW1DLEtBQUs7QUFxQnRELFFBQU87RUFBRTtFQUFTO0VBQU8sNENBbkJlLFlBQVk7QUFDbEQsT0FBSSxDQUFDLFNBQVM7QUFDWiw2QkFBUyxJQUFJLE1BQU0saUNBQWlDLENBQUM7QUFDckQ7O0FBR0YsY0FBVyxLQUFLO0FBQ2hCLFlBQVMsS0FBSztBQUVkLE9BQUk7QUFDRixVQUFNLGNBQWM7WUFDYixLQUFLO0FBQ1osYUFBUyxlQUFlLFFBQVEsc0JBQU0sSUFBSSxNQUFNLDRDQUE0QyxDQUFDO0FBQzdGLFVBQU07YUFDRTtBQUNSLGVBQVcsTUFBTTs7S0FFbEIsQ0FBQyxjQUFjLFFBQVEsQ0FBQztFQUVtQjtFQUFTIn0=
@@ -1,10 +0,0 @@
1
- //#region src/hooks/IdentifyUser/useIdentifyUser.d.ts
2
- declare const useIdentifyUser: () => {
3
- loading: boolean;
4
- error: Error | null;
5
- executeIdentifyUser: () => Promise<void>;
6
- isReady: boolean;
7
- };
8
- //#endregion
9
- export { useIdentifyUser };
10
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXNlSWRlbnRpZnlVc2VyLmQuY3RzIiwibmFtZXMiOltdLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9ob29rcy9JZGVudGlmeVVzZXIvdXNlSWRlbnRpZnlVc2VyLmQudHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGRlY2xhcmUgY29uc3QgdXNlSWRlbnRpZnlVc2VyOiAoKSA9PiB7XG4gICAgbG9hZGluZzogYm9vbGVhbjtcbiAgICBlcnJvcjogRXJyb3IgfCBudWxsO1xuICAgIGV4ZWN1dGVJZGVudGlmeVVzZXI6ICgpID0+IFByb21pc2U8dm9pZD47XG4gICAgaXNSZWFkeTogYm9vbGVhbjtcbn07XG4iXSwibWFwcGluZ3MiOiI7QUFBQSxJQUFXLGtCQUFrQjtDQUFDO09BQVc7T0FBRztDQUFBIn0=
@@ -1,10 +0,0 @@
1
- //#region src/hooks/IdentifyUser/useIdentifyUser.d.ts
2
- declare const useIdentifyUser: () => {
3
- loading: boolean;
4
- error: Error | null;
5
- executeIdentifyUser: () => Promise<void>;
6
- isReady: boolean;
7
- };
8
- //#endregion
9
- export { useIdentifyUser };
10
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXNlSWRlbnRpZnlVc2VyLmQudHMiLCJuYW1lcyI6W10sInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2hvb2tzL0lkZW50aWZ5VXNlci91c2VJZGVudGlmeVVzZXIuZC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZGVjbGFyZSBjb25zdCB1c2VJZGVudGlmeVVzZXI6ICgpID0+IHtcbiAgICBsb2FkaW5nOiBib29sZWFuO1xuICAgIGVycm9yOiBFcnJvciB8IG51bGw7XG4gICAgZXhlY3V0ZUlkZW50aWZ5VXNlcjogKCkgPT4gUHJvbWlzZTx2b2lkPjtcbiAgICBpc1JlYWR5OiBib29sZWFuO1xufTtcbiJdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVcsa0JBQWtCO0NBQUM7T0FBVztPQUFHO0NBQUEifQ==
@@ -1,34 +0,0 @@
1
- import { useUserIdentity } from "../../contexts/userIdentityContext/userIdentityContext.js";
2
- import { useCallback, useState } from "react";
3
-
4
- //#region src/hooks/IdentifyUser/useIdentifyUser.ts
5
- const useIdentifyUser = () => {
6
- const { identifyUser, isReady } = useUserIdentity();
7
- const [loading, setLoading] = useState(false);
8
- const [error, setError] = useState(null);
9
- return {
10
- loading,
11
- error,
12
- executeIdentifyUser: useCallback(async () => {
13
- if (!isReady) {
14
- setError(/* @__PURE__ */ new Error("UserIdentityContext not ready."));
15
- return;
16
- }
17
- setLoading(true);
18
- setError(null);
19
- try {
20
- await identifyUser();
21
- } catch (err) {
22
- setError(err instanceof Error ? err : /* @__PURE__ */ new Error("Unknown error during user identification."));
23
- throw err;
24
- } finally {
25
- setLoading(false);
26
- }
27
- }, [identifyUser, isReady]),
28
- isReady
29
- };
30
- };
31
-
32
- //#endregion
33
- export { useIdentifyUser };
34
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXNlSWRlbnRpZnlVc2VyLmpzIiwibmFtZXMiOltdLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9ob29rcy9JZGVudGlmeVVzZXIvdXNlSWRlbnRpZnlVc2VyLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IHVzZUNhbGxiYWNrLCB1c2VTdGF0ZSB9IGZyb20gJ3JlYWN0JztcbmltcG9ydCB7IHVzZVVzZXJJZGVudGl0eSB9IGZyb20gJ3NyYy9jb250ZXh0cy91c2VySWRlbnRpdHlDb250ZXh0L3VzZXJJZGVudGl0eUNvbnRleHQnO1xuXG5leHBvcnQgY29uc3QgdXNlSWRlbnRpZnlVc2VyID0gKCkg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BUyxNQUFNO0NBQzdDLE1BQU0sQ0FBQyxPQUFPLFlBQVksU0FBdUIsS0FBSztBQXFCdEQsUUFBTztFQUFFO0VBQVM7RUFBTyxxQkFuQkcsWUFBWSxZQUFZO0FBQ2xELE9BQUksQ0FBQyxTQUFTO0FBQ1osNkJBQVMsSUFBSSxNQUFNLGlDQUFpQyxDQUFDO0FBQ3JEOztBQUdGLGNBQVcsS0FBSztBQUNoQixZQUFTLEtBQUs7QUFFZCxPQUFJO0FBQ0YsVUFBTSxjQUFjO1lBQ2IsS0FBSztBQUNaLGFBQVMsZUFBZSxRQUFRLHNCQUFNLElBQUksTUFBTSw0Q0FBNEMsQ0FBQztBQUM3RixVQUFNO2FBQ0U7QUFDUixlQUFXLE1BQU07O0tBRWxCLENBQUMsY0FBYyxRQUFRLENBQUM7RUFFbUI7RUFBUyJ9
@@ -1 +0,0 @@
1
- export * from './useIdentifyUser';
@@ -1,29 +0,0 @@
1
- import { useCallback, useState } from 'react';
2
- import { useUserIdentity } from 'src/contexts/userIdentityContext/userIdentityContext';
3
-
4
- export const useIdentifyUser = () => {
5
- const { identifyUser, isReady } = useUserIdentity();
6
- const [loading, setLoading] = useState(false);
7
- const [error, setError] = useState<Error | null>(null);
8
-
9
- const executeIdentifyUser = useCallback(async () => {
10
- if (!isReady) {
11
- setError(new Error('UserIdentityContext not ready.'));
12
- return;
13
- }
14
-
15
- setLoading(true);
16
- setError(null);
17
-
18
- try {
19
- await identifyUser();
20
- } catch (err) {
21
- setError(err instanceof Error ? err : new Error('Unknown error during user identification.'));
22
- throw err;
23
- } finally {
24
- setLoading(false);
25
- }
26
- }, [identifyUser, isReady]);
27
-
28
- return { loading, error, executeIdentifyUser, isReady };
29
- };