@envive-ai/react-hooks 0.3.32 → 0.3.33
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/commerce-api.d.cts +1 -1
- package/dist/application/commerce-api.d.ts +1 -1
- package/dist/atoms/app/index.d.cts +9 -9
- package/dist/atoms/app/index.d.ts +9 -9
- package/dist/atoms/app/variant.d.cts +8 -8
- package/dist/atoms/app/variant.d.ts +8 -8
- package/dist/atoms/chat/chatState.d.cts +20 -20
- package/dist/atoms/chat/chatState.d.ts +20 -20
- 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 +3 -3
- package/dist/atoms/chat/index.d.ts +2 -2
- package/dist/atoms/chat/index.js +1 -1
- 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.ts +6 -6
- package/dist/atoms/chat/renderedWidgetRefs.d.cts +2 -2
- package/dist/atoms/chat/renderedWidgetRefs.d.ts +3 -3
- package/dist/atoms/chat/replies.d.ts +3 -3
- 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 +13 -13
- 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 +6 -6
- 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 +5 -5
- package/dist/atoms/org/graphqlConfig.d.ts +5 -5
- package/dist/atoms/org/index.cjs +2 -3
- package/dist/atoms/org/index.d.cts +2 -2
- package/dist/atoms/org/index.d.ts +2 -2
- package/dist/atoms/org/index.js +3 -3
- package/dist/atoms/org/newOrgConfigAtom.d.cts +2 -2
- package/dist/atoms/org/newOrgConfigAtom.d.ts +2 -2
- package/dist/atoms/org/orgAnalyticsConfig.cjs +1 -3
- package/dist/atoms/org/orgAnalyticsConfig.d.cts +7 -8
- package/dist/atoms/org/orgAnalyticsConfig.d.ts +7 -8
- package/dist/atoms/org/orgAnalyticsConfig.js +2 -3
- 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.ts +2 -2
- package/dist/contexts/amplitudeContext/amplitudeContext.cjs +1 -5
- package/dist/contexts/amplitudeContext/amplitudeContext.js +1 -5
- package/dist/contexts/enviveConfigContext/enviveConfigContext.cjs +18 -23
- package/dist/contexts/enviveConfigContext/enviveConfigContext.d.cts +10 -12
- package/dist/contexts/enviveConfigContext/enviveConfigContext.d.ts +10 -12
- package/dist/contexts/enviveConfigContext/enviveConfigContext.js +18 -23
- package/dist/contexts/enviveContext/enviveContext.cjs +41 -74
- package/dist/contexts/enviveContext/enviveContext.d.cts +15 -32
- package/dist/contexts/enviveContext/enviveContext.d.ts +15 -32
- package/dist/contexts/enviveContext/enviveContext.js +41 -74
- package/dist/contexts/enviveContext/index.d.cts +2 -2
- package/dist/contexts/enviveContext/index.d.ts +2 -2
- package/dist/contexts/enviveCssContext/enviveCssContext.cjs +31 -16
- package/dist/contexts/enviveCssContext/enviveCssContext.js +31 -16
- package/dist/contexts/graphqlContext/graphqlContext.cjs +3 -212
- package/dist/contexts/graphqlContext/graphqlContext.d.cts +2 -10
- package/dist/contexts/graphqlContext/graphqlContext.d.ts +2 -10
- package/dist/contexts/graphqlContext/graphqlContext.js +3 -212
- package/dist/contexts/graphqlContext/mockV3Config.cjs +31 -16
- package/dist/contexts/graphqlContext/mockV3Config.js +31 -16
- package/dist/contexts/hardcopyContext/hardcopyContext.cjs +9 -238
- package/dist/contexts/hardcopyContext/hardcopyContext.d.cts +5 -17
- package/dist/contexts/hardcopyContext/hardcopyContext.d.ts +5 -17
- package/dist/contexts/hardcopyContext/hardcopyContext.js +9 -238
- package/dist/contexts/hardcopyContext/index.d.cts +3 -2
- package/dist/contexts/hardcopyContext/index.d.ts +3 -2
- package/dist/contexts/newOrgConfigContext/newOrgConfigContext.cjs +10 -32
- package/dist/contexts/newOrgConfigContext/newOrgConfigContext.d.cts +2 -2
- package/dist/contexts/newOrgConfigContext/newOrgConfigContext.d.ts +2 -2
- package/dist/contexts/newOrgConfigContext/newOrgConfigContext.js +12 -34
- package/dist/contexts/pageContext/mapping.d.cts +1 -1
- package/dist/contexts/pageContext/mapping.d.ts +1 -1
- package/dist/contexts/pageContext/types.d.cts +1 -1
- package/dist/contexts/salesAgentContext/chatAPI.cjs +2 -2
- package/dist/contexts/salesAgentContext/chatAPI.js +2 -2
- package/dist/contexts/salesAgentContext/salesAgentService.cjs +1 -1
- package/dist/contexts/salesAgentContext/salesAgentService.js +1 -1
- 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/types.d.cts +2 -2
- package/dist/contexts/types.d.ts +2 -2
- package/dist/contexts/typesV3.cjs +31 -16
- package/dist/contexts/typesV3.d.cts +62 -31
- package/dist/contexts/typesV3.d.ts +62 -31
- package/dist/contexts/typesV3.js +31 -16
- package/dist/contexts/userIdentityContext/userIdentityContext.cjs +1 -1
- package/dist/contexts/userIdentityContext/userIdentityContext.d.cts +3 -3
- package/dist/contexts/userIdentityContext/userIdentityContext.d.ts +3 -3
- package/dist/contexts/userIdentityContext/userIdentityContext.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/GraphQLConfig/index.cjs +0 -1
- package/dist/hooks/GraphQLConfig/index.d.cts +2 -2
- package/dist/hooks/GraphQLConfig/index.d.ts +2 -2
- package/dist/hooks/GraphQLConfig/index.js +2 -2
- package/dist/hooks/GraphQLConfig/useGraphQLConfig.cjs +7 -66
- package/dist/hooks/GraphQLConfig/useGraphQLConfig.d.cts +5 -13
- package/dist/hooks/GraphQLConfig/useGraphQLConfig.d.ts +5 -13
- package/dist/hooks/GraphQLConfig/useGraphQLConfig.js +8 -66
- package/dist/hooks/Search/useSearch.cjs +3 -3
- package/dist/hooks/Search/useSearch.js +3 -3
- package/dist/services/amplitudeService/amplitudeService.cjs +4 -3
- package/dist/services/amplitudeService/amplitudeService.d.cts +1 -2
- package/dist/services/amplitudeService/amplitudeService.d.ts +1 -2
- package/dist/services/amplitudeService/amplitudeService.js +4 -3
- package/dist/services/enviveConfigService/enviveConfigService.cjs +25 -5
- package/dist/services/enviveConfigService/enviveConfigService.d.cts +24 -5
- package/dist/services/enviveConfigService/enviveConfigService.d.ts +24 -5
- package/dist/services/enviveConfigService/enviveConfigService.js +25 -6
- package/dist/services/enviveConfigService/fetchGraphQLConfig.cjs +181 -0
- package/dist/services/enviveConfigService/fetchGraphQLConfig.js +180 -0
- package/dist/services/enviveConfigService/index.cjs +2 -1
- package/dist/services/enviveConfigService/index.d.cts +2 -2
- package/dist/services/enviveConfigService/index.d.ts +2 -2
- package/dist/services/enviveConfigService/index.js +2 -2
- package/dist/services/hardcopyService/hardcopyService.cjs +232 -0
- package/dist/services/hardcopyService/hardcopyService.d.cts +39 -0
- package/dist/services/hardcopyService/hardcopyService.d.ts +39 -0
- package/dist/services/hardcopyService/hardcopyService.js +229 -0
- package/dist/services/hardcopyService/index.cjs +5 -0
- package/dist/services/hardcopyService/index.d.cts +2 -0
- package/dist/services/hardcopyService/index.d.ts +2 -0
- package/dist/services/hardcopyService/index.js +3 -0
- package/dist/services/userIdentityService/index.cjs +1 -0
- package/dist/services/userIdentityService/index.d.cts +2 -2
- package/dist/services/userIdentityService/index.d.ts +2 -2
- package/dist/services/userIdentityService/index.js +2 -2
- package/dist/services/userIdentityService/userIdentityService.cjs +13 -1
- package/dist/services/userIdentityService/userIdentityService.d.cts +12 -2
- package/dist/services/userIdentityService/userIdentityService.d.ts +12 -2
- package/dist/services/userIdentityService/userIdentityService.js +13 -2
- package/dist/types/enviveConfig.d.cts +1 -1
- package/dist/types/enviveConfig.d.ts +1 -1
- package/package.json +5 -1
- package/src/atoms/org/orgAnalyticsConfig.ts +0 -5
- package/src/contexts/amplitudeContext/amplitudeContext.tsx +0 -4
- package/src/contexts/enviveConfigContext/enviveConfigContext.tsx +37 -49
- package/src/contexts/enviveContext/enviveContext.tsx +72 -134
- package/src/contexts/enviveCssContext/enviveCssContext.tsx +32 -17
- package/src/contexts/graphqlContext/__tests__/graphqlContext.test.tsx +3 -36
- package/src/contexts/graphqlContext/graphqlContext.tsx +4 -304
- package/src/contexts/graphqlContext/mockV3Config.ts +30 -15
- package/src/contexts/hardcopyContext/hardcopyContext.tsx +12 -270
- package/src/contexts/newOrgConfigContext/__tests__/newOrgConfigContext.test.tsx +54 -478
- package/src/contexts/newOrgConfigContext/newOrgConfigContext.tsx +9 -26
- package/src/contexts/typesV3.ts +61 -30
- package/src/contexts/userIdentityContext/userIdentityContext.tsx +2 -2
- package/src/hooks/GraphQLConfig/useGraphQLConfig.ts +2 -62
- package/src/hooks/Search/__tests__/useSearch.test.tsx +2 -2
- package/src/services/amplitudeService/__tests__/amplitudeService.test.ts +3 -5
- package/src/services/amplitudeService/amplitudeService.ts +5 -3
- package/src/services/enviveConfigService/__tests__/fetchGraphQLConfig.test.ts +425 -0
- package/src/services/enviveConfigService/enviveConfigService.ts +41 -13
- package/src/services/enviveConfigService/fetchGraphQLConfig.ts +225 -0
- package/src/services/hardcopyService/__tests__/hardcopyService.test.ts +367 -0
- package/src/services/hardcopyService/hardcopyService.ts +271 -0
- package/src/services/hardcopyService/index.ts +1 -0
- package/src/services/userIdentityService/userIdentityService.ts +18 -0
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import React, { ReactNode, createContext, useContext, useMemo } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { orgShortNameAtom } from 'src/atoms/envive/enviveConfig';
|
|
5
|
-
import { newOrgConfigAtom } from 'src/atoms/org/newOrgConfigAtom'; // Import newOrgConfigAtom
|
|
1
|
+
import React, { ReactNode, createContext, useContext, useEffect, useMemo } from 'react';
|
|
2
|
+
import { useSetAtom } from 'jotai';
|
|
3
|
+
import { newOrgConfigAtom } from 'src/atoms/org/newOrgConfigAtom';
|
|
6
4
|
import { GraphQlConfigValues } from '../graphqlContext';
|
|
7
5
|
|
|
8
6
|
export type NewOrgConfigContextType = GraphQlConfigValues & {
|
|
@@ -14,32 +12,17 @@ const NewOrgConfigContext = createContext<NewOrgConfigContextType | undefined>(u
|
|
|
14
12
|
|
|
15
13
|
interface NewOrgConfigProviderProps {
|
|
16
14
|
children: ReactNode;
|
|
17
|
-
|
|
15
|
+
config: GraphQlConfigValues;
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
export const NewOrgConfigProvider: React.FC<NewOrgConfigProviderProps> = ({
|
|
21
|
-
children,
|
|
22
|
-
overrideConfig,
|
|
23
|
-
}) => {
|
|
24
|
-
const orgShortName = useAtomValue(orgShortNameAtom);
|
|
18
|
+
export const NewOrgConfigProvider: React.FC<NewOrgConfigProviderProps> = ({ children, config }) => {
|
|
25
19
|
const setNewOrgConfig = useSetAtom(newOrgConfigAtom);
|
|
26
20
|
|
|
27
|
-
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
setNewOrgConfig(config);
|
|
23
|
+
}, [config, setNewOrgConfig]);
|
|
28
24
|
|
|
29
|
-
const contextValue = useMemo(() => {
|
|
30
|
-
if (!orgShortName || loading) {
|
|
31
|
-
return { ...fetchedConfig, loading: true, error: null };
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (error) {
|
|
35
|
-
return { ...fetchedConfig, loading: false, error };
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const activeConfig = overrideConfig || fetchedConfig;
|
|
39
|
-
|
|
40
|
-
setNewOrgConfig(activeConfig);
|
|
41
|
-
return { ...activeConfig, loading: false, error: null };
|
|
42
|
-
}, [orgShortName, loading, error, setNewOrgConfig, fetchedConfig, overrideConfig]);
|
|
25
|
+
const contextValue = useMemo(() => ({ ...config, loading: false, error: null }), [config]);
|
|
43
26
|
|
|
44
27
|
return (
|
|
45
28
|
<NewOrgConfigContext.Provider value={contextValue}>{children}</NewOrgConfigContext.Provider>
|
package/src/contexts/typesV3.ts
CHANGED
|
@@ -11,27 +11,42 @@ import { CustomerServiceType } from '../types/customerService';
|
|
|
11
11
|
import type { SearchConfig } from './types';
|
|
12
12
|
|
|
13
13
|
export enum LetterSpacingCSSVar {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
T1 = 'envive-typography-letter-spacing-t1',
|
|
15
|
+
T2 = 'envive-typography-letter-spacing-t2',
|
|
16
|
+
T3 = 'envive-typography-letter-spacing-t3',
|
|
17
|
+
H1 = 'envive-typography-letter-spacing-h1',
|
|
18
|
+
H2 = 'envive-typography-letter-spacing-h2',
|
|
19
|
+
H3 = 'envive-typography-letter-spacing-h3',
|
|
20
|
+
B1 = 'envive-typography-letter-spacing-b1',
|
|
21
|
+
B2 = 'envive-typography-letter-spacing-b2',
|
|
22
|
+
B3 = 'envive-typography-letter-spacing-b3',
|
|
23
|
+
B4 = 'envive-typography-letter-spacing-b4',
|
|
24
|
+
B5 = 'envive-typography-letter-spacing-b5',
|
|
25
|
+
L1 = 'envive-typography-letter-spacing-l1',
|
|
26
|
+
L2 = 'envive-typography-letter-spacing-l2',
|
|
16
27
|
}
|
|
17
28
|
|
|
18
29
|
export enum LineHeightCSSVar {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
T1 = 'envive-typography-line-height-t1',
|
|
31
|
+
T2 = 'envive-typography-line-height-t2',
|
|
32
|
+
T3 = 'envive-typography-line-height-t3',
|
|
33
|
+
H1 = 'envive-typography-line-height-h1',
|
|
34
|
+
H2 = 'envive-typography-line-height-h2',
|
|
35
|
+
H3 = 'envive-typography-line-height-h3',
|
|
36
|
+
B1 = 'envive-typography-line-height-b1',
|
|
37
|
+
B2 = 'envive-typography-line-height-b2',
|
|
38
|
+
B3 = 'envive-typography-line-height-b3',
|
|
39
|
+
B4 = 'envive-typography-line-height-b4',
|
|
40
|
+
B5 = 'envive-typography-line-height-b5',
|
|
41
|
+
L1 = 'envive-typography-line-height-l1',
|
|
42
|
+
L2 = 'envive-typography-line-height-l2',
|
|
29
43
|
}
|
|
30
44
|
|
|
31
45
|
export enum FontWeightCSSVar {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
46
|
+
Title = 'envive-typography-font-weight-title',
|
|
47
|
+
Header = 'envive-typography-font-weight-header',
|
|
48
|
+
BodyEmphasis = 'envive-typography-font-weight-body-emphasis',
|
|
49
|
+
BodyStandard = 'envive-typography-font-weight-body-standard',
|
|
35
50
|
}
|
|
36
51
|
|
|
37
52
|
export enum FontSizeCSSVar {
|
|
@@ -125,27 +140,42 @@ type Typography = {
|
|
|
125
140
|
};
|
|
126
141
|
|
|
127
142
|
fontWeight?: {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
143
|
+
title: string;
|
|
144
|
+
header: string;
|
|
145
|
+
bodyEmphasis: string;
|
|
146
|
+
bodyStandard: string;
|
|
131
147
|
};
|
|
132
148
|
|
|
133
149
|
letterSpacing?: {
|
|
134
|
-
|
|
135
|
-
|
|
150
|
+
t1: string;
|
|
151
|
+
t2: string;
|
|
152
|
+
t3: string;
|
|
153
|
+
h1: string;
|
|
154
|
+
h2: string;
|
|
155
|
+
h3: string;
|
|
156
|
+
b1: string;
|
|
157
|
+
b2: string;
|
|
158
|
+
b3: string;
|
|
159
|
+
b4: string;
|
|
160
|
+
b5: string;
|
|
161
|
+
l1: string;
|
|
162
|
+
l2: string;
|
|
136
163
|
};
|
|
137
164
|
|
|
138
165
|
lineHeight?: {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
166
|
+
t1: number;
|
|
167
|
+
t2: number;
|
|
168
|
+
t3: number;
|
|
169
|
+
h1: number;
|
|
170
|
+
h2: number;
|
|
171
|
+
h3: number;
|
|
172
|
+
b1: number;
|
|
173
|
+
b2: number;
|
|
174
|
+
b3: number;
|
|
175
|
+
b4: number;
|
|
176
|
+
b5: number;
|
|
177
|
+
l1: number;
|
|
178
|
+
l2: number;
|
|
149
179
|
};
|
|
150
180
|
};
|
|
151
181
|
|
|
@@ -342,6 +372,7 @@ interface ProductCardWidgetV3Config extends BaseWidgetConfig<WidgetTypeV3.Produc
|
|
|
342
372
|
italicizeHeadline?: boolean;
|
|
343
373
|
fallbackColor?: string;
|
|
344
374
|
imageSrc?: string;
|
|
375
|
+
mode?: Mode;
|
|
345
376
|
}
|
|
346
377
|
|
|
347
378
|
interface FullPageSalesAgentWidgetV3Config extends BaseWidgetConfig<WidgetTypeV3.FullPageSalesAgentV3> {
|
|
@@ -11,7 +11,7 @@ import Logger from 'src/application/logging/logger';
|
|
|
11
11
|
import { useLocalStorage } from 'src/contexts/localStorageContext';
|
|
12
12
|
import { useSetAtom } from 'jotai';
|
|
13
13
|
import { userIdAtom } from 'src/atoms/app';
|
|
14
|
-
import {
|
|
14
|
+
import { IUserIdentityService } from 'src/services/userIdentityService';
|
|
15
15
|
|
|
16
16
|
const logger = new Logger('userIdentityContext');
|
|
17
17
|
|
|
@@ -26,7 +26,7 @@ export interface UserIdentityContextType {
|
|
|
26
26
|
const UserIdentityContext = createContext<UserIdentityContextType | undefined>(undefined);
|
|
27
27
|
|
|
28
28
|
interface UserIdentityProviderProps {
|
|
29
|
-
userIdService:
|
|
29
|
+
userIdService: IUserIdentityService;
|
|
30
30
|
children: ReactNode;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -1,62 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export const useColorsAndFrontendConfig = () => {
|
|
5
|
-
const { getColorsAndFrontendConfig, isReady } = useGraphQLClient();
|
|
6
|
-
const [data, setData] = useState<GraphQlConfigValues>({});
|
|
7
|
-
const [loading, setLoading] = useState(false);
|
|
8
|
-
const [error, setError] = useState<Error | null>(null);
|
|
9
|
-
|
|
10
|
-
const fetchConfig = useCallback(async () => {
|
|
11
|
-
if (!isReady) return;
|
|
12
|
-
|
|
13
|
-
setLoading(true);
|
|
14
|
-
setError(null);
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
const result = await getColorsAndFrontendConfig();
|
|
18
|
-
setData(result);
|
|
19
|
-
} catch (err) {
|
|
20
|
-
setError(err instanceof Error ? err : new Error('Unknown error'));
|
|
21
|
-
} finally {
|
|
22
|
-
setLoading(false);
|
|
23
|
-
}
|
|
24
|
-
}, [getColorsAndFrontendConfig, isReady]);
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
fetchConfig();
|
|
28
|
-
}, [fetchConfig]);
|
|
29
|
-
|
|
30
|
-
return { data, loading, error, refetch: fetchConfig };
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const useUIConfig = () => {
|
|
34
|
-
const { getConfig, isReady } = useGraphQLClient();
|
|
35
|
-
const [data, setData] = useState<GraphQlConfigValues>({});
|
|
36
|
-
const [loading, setLoading] = useState(false);
|
|
37
|
-
const [error, setError] = useState<Error | null>(null);
|
|
38
|
-
|
|
39
|
-
const fetchConfig = useCallback(async () => {
|
|
40
|
-
if (!isReady) return;
|
|
41
|
-
if (loading) return;
|
|
42
|
-
if (Object.keys(data).length > 0) return;
|
|
43
|
-
|
|
44
|
-
setLoading(true);
|
|
45
|
-
setError(null);
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
const result = await getConfig();
|
|
49
|
-
setData(result);
|
|
50
|
-
} catch (err) {
|
|
51
|
-
setError(err instanceof Error ? err : new Error('Unknown error'));
|
|
52
|
-
} finally {
|
|
53
|
-
setLoading(false);
|
|
54
|
-
}
|
|
55
|
-
}, [data, getConfig, isReady, loading]);
|
|
56
|
-
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
fetchConfig();
|
|
59
|
-
}, [fetchConfig]);
|
|
60
|
-
|
|
61
|
-
return { data, loading, error, refetch: fetchConfig };
|
|
62
|
-
};
|
|
1
|
+
// Hooks moved to EnviveConfigService — stub retained for test mock compatibility
|
|
2
|
+
export const useUIConfig = () => ({ data: {}, loading: false, error: null, refetch: () => {} });
|
|
@@ -413,7 +413,7 @@ const TestWrapper: React.FC<{
|
|
|
413
413
|
<UserIdentityProvider userIdService={testUserIdService}>
|
|
414
414
|
<FeatureFlagServiceProvider featureFlagService={testFeatureFlagService}>
|
|
415
415
|
<AmplitudeProvider>
|
|
416
|
-
<NewOrgConfigProvider>
|
|
416
|
+
<NewOrgConfigProvider config={{}}>
|
|
417
417
|
<SearchProvider>
|
|
418
418
|
<AtomManipulator
|
|
419
419
|
searchData={searchData}
|
|
@@ -616,7 +616,7 @@ describe('useSearch', () => {
|
|
|
616
616
|
|
|
617
617
|
await waitFor(() => {
|
|
618
618
|
const filterButtonText = screen.getByTestId('filter-button-text').textContent;
|
|
619
|
-
expect(filterButtonText).toContain('Filter & Sort
|
|
619
|
+
expect(filterButtonText).toContain('Filter & Sort');
|
|
620
620
|
});
|
|
621
621
|
});
|
|
622
622
|
});
|
|
@@ -323,9 +323,7 @@ describe('AmplitudeService', () => {
|
|
|
323
323
|
});
|
|
324
324
|
|
|
325
325
|
it('should send to Google Analytics when alsoSendToGoogleAnalytics is true', async () => {
|
|
326
|
-
const service = createService(
|
|
327
|
-
orgGaConfig: { enabled: true },
|
|
328
|
-
});
|
|
326
|
+
const service = createService();
|
|
329
327
|
|
|
330
328
|
const dataLayer: any[] = [];
|
|
331
329
|
Object.defineProperty(global, 'window', {
|
|
@@ -358,7 +356,7 @@ describe('AmplitudeService', () => {
|
|
|
358
356
|
});
|
|
359
357
|
});
|
|
360
358
|
|
|
361
|
-
it('should not send to Google Analytics when
|
|
359
|
+
it('should not send to Google Analytics when alsoSendToGoogleAnalytics is false', async () => {
|
|
362
360
|
const service = createService();
|
|
363
361
|
|
|
364
362
|
const dataLayer: any[] = [];
|
|
@@ -373,7 +371,7 @@ describe('AmplitudeService', () => {
|
|
|
373
371
|
await service.trackEvent({
|
|
374
372
|
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
375
373
|
eventProps: { message: 'test' },
|
|
376
|
-
alsoSendToGoogleAnalytics:
|
|
374
|
+
alsoSendToGoogleAnalytics: false,
|
|
377
375
|
});
|
|
378
376
|
|
|
379
377
|
expect(dataLayer).toHaveLength(0);
|
|
@@ -35,7 +35,6 @@ export interface AmplitudeServiceConfig {
|
|
|
35
35
|
orgShortName: string;
|
|
36
36
|
orgId: string;
|
|
37
37
|
featureFlagService: FeatureFlagService;
|
|
38
|
-
orgGaConfig?: unknown;
|
|
39
38
|
show: boolean;
|
|
40
39
|
enviveOn: boolean;
|
|
41
40
|
enabledFeatures?: Record<string, boolean>;
|
|
@@ -412,13 +411,16 @@ export class AmplitudeService {
|
|
|
412
411
|
},
|
|
413
412
|
);
|
|
414
413
|
|
|
415
|
-
|
|
414
|
+
// TODO: Pull gaEnabled from org config when available. Hardcoded to true for now.
|
|
415
|
+
const gaEnabled = true;
|
|
416
|
+
|
|
417
|
+
if (AmplitudeService.isV3EnviveEvent(eventName) && gaEnabled) {
|
|
416
418
|
const mergedPropsForGA4 = {
|
|
417
419
|
...this.getDefaultTrackingProps(eventName),
|
|
418
420
|
...mappedEventProps,
|
|
419
421
|
};
|
|
420
422
|
projectToGA4(eventName as EnviveMetricsEventName, mergedPropsForGA4);
|
|
421
|
-
} else if (alsoSendToGoogleAnalytics &&
|
|
423
|
+
} else if (alsoSendToGoogleAnalytics && gaEnabled) {
|
|
422
424
|
logger.logDebug('GA tracking', decoratedEventName);
|
|
423
425
|
if (typeof window !== 'undefined' && window.dataLayer) {
|
|
424
426
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|