@envive-ai/react-hooks 0.3.11 → 0.3.12
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.cjs +18 -14
- package/dist/application/commerce-api.d.cts +2 -2
- package/dist/application/commerce-api.d.ts +2 -2
- package/dist/application/commerce-api.js +18 -14
- package/dist/application/models/api/widgetTextRequest.d.cts +2 -1
- package/dist/application/models/api/widgetTextRequest.d.ts +2 -1
- package/dist/application/models/chatElementDisplayLocationV3.cjs +3 -1
- package/dist/application/models/chatElementDisplayLocationV3.d.cts +3 -1
- package/dist/application/models/chatElementDisplayLocationV3.d.ts +3 -1
- package/dist/application/models/chatElementDisplayLocationV3.js +3 -1
- package/dist/application/models/guards/api/index.cjs +6 -6
- package/dist/application/models/guards/api/index.js +6 -6
- package/dist/application/models/index.cjs +18 -18
- package/dist/application/models/index.js +18 -18
- package/dist/application/models/validators/validateResponse.cjs +3 -3
- package/dist/application/models/validators/validateResponse.js +3 -3
- package/dist/application/models/variantInfo/variantInfo.cjs +1 -1
- package/dist/application/models/variantInfo/variantInfo.d.cts +1 -1
- package/dist/application/models/variantInfo/variantInfo.d.ts +1 -1
- package/dist/application/models/variantInfo/variantInfo.js +1 -1
- package/dist/application/utils/nodeSelector.cjs +12 -14
- package/dist/application/utils/nodeSelector.js +12 -14
- package/dist/application/utils/widgetTextRequestToApiRequest.cjs +2 -1
- package/dist/application/utils/widgetTextRequestToApiRequest.js +2 -1
- package/dist/atoms/app/index.d.cts +1 -1
- package/dist/atoms/app/index.d.ts +7 -7
- 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.d.cts +2 -2
- package/dist/atoms/chat/index.d.ts +2 -2
- 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.ts +2 -2
- package/dist/atoms/chat/replies.d.cts +3 -3
- 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.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/newOrgConfigAtom.d.cts +2 -2
- package/dist/atoms/org/newOrgConfigAtom.d.ts +2 -2
- package/dist/atoms/org/orgAnalyticsConfig.d.cts +5 -5
- package/dist/atoms/org/orgAnalyticsConfig.d.ts +5 -5
- package/dist/atoms/search/chatSearch.d.cts +17 -17
- package/dist/atoms/search/chatSearch.d.ts +17 -17
- package/dist/atoms/search/searchAPI.d.cts +13 -13
- package/dist/atoms/search/searchAPI.d.ts +13 -13
- package/dist/atoms/search/types.d.cts +1 -1
- package/dist/atoms/widget/chatPreviewLoading.d.ts +2 -2
- package/dist/config/locators/components/search/index.d.cts +1 -1
- package/dist/contexts/amplitudeContext/amplitudeContext.cjs +1 -2
- package/dist/contexts/amplitudeContext/amplitudeContext.js +1 -2
- package/dist/contexts/enviveContext/enviveContext.cjs +17 -14
- package/dist/contexts/enviveContext/enviveContext.d.cts +4 -1
- package/dist/contexts/enviveContext/enviveContext.d.ts +4 -1
- package/dist/contexts/enviveContext/enviveContext.js +17 -14
- package/dist/contexts/enviveContext/types.d.cts +1 -1
- package/dist/contexts/hardcopyContext/hardcopyContext.cjs +11 -2
- package/dist/contexts/hardcopyContext/hardcopyContext.d.cts +6 -4
- package/dist/contexts/hardcopyContext/hardcopyContext.d.ts +6 -4
- package/dist/contexts/hardcopyContext/hardcopyContext.js +11 -2
- package/dist/contexts/pageContext/pageContext.cjs +10 -6
- package/dist/contexts/pageContext/pageContext.js +10 -6
- package/dist/contexts/pageContext/types.d.cts +1 -1
- package/dist/contexts/salesAgentContext/chatAPI.cjs +1 -2
- package/dist/contexts/salesAgentContext/chatAPI.js +1 -2
- package/dist/contexts/systemSettingsContext/systemSettingsContext.d.cts +2 -2
- package/dist/contexts/systemSettingsContext/systemSettingsContext.d.ts +2 -2
- package/dist/contexts/types.cjs +1 -1
- package/dist/contexts/types.d.cts +4 -2
- package/dist/contexts/types.d.ts +4 -2
- package/dist/contexts/types.js +1 -1
- package/dist/contexts/typesV3.cjs +1 -1
- package/dist/contexts/typesV3.d.cts +18 -2
- package/dist/contexts/typesV3.d.ts +18 -2
- package/dist/contexts/typesV3.js +1 -1
- package/dist/hooks/GrabAndScroll/useGrabAndScroll.d.cts +2 -2
- package/dist/hooks/GrabAndScroll/useGrabAndScroll.d.ts +2 -2
- package/dist/hooks/Search/useSearchInput.cjs +1 -1
- package/dist/hooks/Search/useSearchInput.js +1 -1
- package/dist/hooks/utils.d.cts +1 -1
- package/dist/types/enviveConfig.d.cts +4 -1
- package/dist/types/enviveConfig.d.ts +4 -1
- package/package.json +2 -2
- package/src/application/commerce-api.ts +25 -20
- package/src/application/models/api/widgetTextRequest.ts +1 -0
- package/src/application/models/chatElementDisplayLocationV3.ts +2 -0
- package/src/application/models/variantInfo/variantInfo.ts +1 -1
- package/src/application/utils/nodeSelector.ts +15 -14
- package/src/application/utils/widgetTextRequestToApiRequest.ts +1 -0
- package/src/contexts/amplitudeContext/amplitudeContext.tsx +0 -1
- package/src/contexts/enviveContext/enviveContext.tsx +5 -2
- package/src/contexts/hardcopyContext/hardcopyContext.tsx +20 -2
- package/src/contexts/pageContext/pageContext.tsx +9 -5
- package/src/contexts/salesAgentContext/chatAPI.ts +0 -1
- package/src/contexts/types.ts +3 -1
- package/src/contexts/typesV3.ts +18 -0
- package/src/types/enviveConfig.ts +3 -0
|
@@ -32,7 +32,11 @@ class QuerySelector extends NodeSelector {
|
|
|
32
32
|
|
|
33
33
|
class IDSelector extends NodeSelector {
|
|
34
34
|
parse(): Node | null {
|
|
35
|
-
|
|
35
|
+
const root = this.getRoot();
|
|
36
|
+
if (typeof root?.getElementById !== 'function') {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return root.getElementById(this.getPattern()) as Node;
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
|
|
@@ -50,19 +54,19 @@ class XpathSelector extends NodeSelector {
|
|
|
50
54
|
|
|
51
55
|
class ChainSelector extends NodeSelector {
|
|
52
56
|
parse(): Node | null {
|
|
53
|
-
let selectorIndex = 0;
|
|
54
57
|
const selectors = this.getPattern().split('@');
|
|
55
|
-
|
|
58
|
+
let currentRoot: Node | null = null;
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
const selector = SelectorFactory.parse(
|
|
60
|
+
for (let i = 0; i < selectors.length; i += 1) {
|
|
61
|
+
const selector = SelectorFactory.parse(selectors[i].trim());
|
|
59
62
|
|
|
60
|
-
if (
|
|
61
|
-
selector.setRoot(
|
|
63
|
+
if (currentRoot) {
|
|
64
|
+
selector.setRoot(currentRoot as Document);
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
const currentNode = selector.parse();
|
|
65
|
-
|
|
68
|
+
|
|
69
|
+
if (i === selectors.length - 1) {
|
|
66
70
|
return currentNode;
|
|
67
71
|
}
|
|
68
72
|
|
|
@@ -75,13 +79,10 @@ class ChainSelector extends NodeSelector {
|
|
|
75
79
|
node = (currentNode as HTMLIFrameElement).contentWindow?.document;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
selectorIndex = nextIndex; // Update the outer scope variable to reflect the advancement
|
|
81
|
-
return result;
|
|
82
|
-
};
|
|
82
|
+
currentRoot = node ?? null;
|
|
83
|
+
}
|
|
83
84
|
|
|
84
|
-
return
|
|
85
|
+
return null;
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
|
|
@@ -47,5 +47,6 @@ export const coreWidgetTextRequestToApiRequest = (
|
|
|
47
47
|
feature_flags: coreWidgetTextRequest.featureFlags,
|
|
48
48
|
language: coreWidgetTextRequest.language,
|
|
49
49
|
url: coreWidgetTextRequest.url,
|
|
50
|
+
org_base_config_version: coreWidgetTextRequest.overrideConfigVersion,
|
|
50
51
|
widget_type: coreWidgetTypeToApiWidgetType(coreWidgetTextRequest.widgetType),
|
|
51
52
|
});
|
|
@@ -104,7 +104,6 @@ export const AmplitudeProvider: React.FC<{
|
|
|
104
104
|
const value = useMemo(
|
|
105
105
|
() => ({
|
|
106
106
|
trackEvent: async (params: TrackEventParams): Promise<void> => {
|
|
107
|
-
console.log('=== trackEvent ===', params);
|
|
108
107
|
if (service) {
|
|
109
108
|
await service.trackEvent(params);
|
|
110
109
|
}
|
|
@@ -17,7 +17,8 @@ import { EnviveAgent } from './types';
|
|
|
17
17
|
import { SearchProvider } from '../searchContext';
|
|
18
18
|
import { SalesAgentProvider } from '../salesAgentContext/salesAgentContext';
|
|
19
19
|
import { SystemSettingsContextProvider } from '../systemSettingsContext';
|
|
20
|
-
import { HardcopyProvider } from '../hardcopyContext';
|
|
20
|
+
import { HardcopyProvider, HardcopyResponse } from '../hardcopyContext';
|
|
21
|
+
import { WidgetTypeV3 } from '../typesV3';
|
|
21
22
|
import { WidgetConfigProvider } from '../widgetConfigContext';
|
|
22
23
|
import { PageProvider } from '../pageContext';
|
|
23
24
|
import { UiConfigProvider } from '../uiConfigContext';
|
|
@@ -57,6 +58,7 @@ interface EnviveProviderProps extends AgentWrapperProps {
|
|
|
57
58
|
previewMode?: boolean;
|
|
58
59
|
overrideConfig?: GraphQlConfigValues;
|
|
59
60
|
mockSalesAgentData?: any;
|
|
61
|
+
hardcopyOverride?: Partial<Record<WidgetTypeV3, HardcopyResponse>>;
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
const SearchAgentWrapper: React.FC<AgentWrapperProps> = ({ children, enabledAgents }) => {
|
|
@@ -106,6 +108,7 @@ export const EnviveProvider: React.FC<EnviveProviderProps> = ({
|
|
|
106
108
|
mockV3ConfigToDeprecatedConfig = false,
|
|
107
109
|
requestV3Config = false,
|
|
108
110
|
mockSalesAgentData,
|
|
111
|
+
hardcopyOverride,
|
|
109
112
|
...config
|
|
110
113
|
}) => {
|
|
111
114
|
const [userId, setUserId] = useState<string>('');
|
|
@@ -184,7 +187,7 @@ export const EnviveProvider: React.FC<EnviveProviderProps> = ({
|
|
|
184
187
|
<PageProvider previewMode={previewMode}>
|
|
185
188
|
<UiConfigProvider>
|
|
186
189
|
<WidgetConfigProvider>
|
|
187
|
-
<HardcopyProvider>
|
|
190
|
+
<HardcopyProvider hardcopyOverride={hardcopyOverride}>
|
|
188
191
|
<EnviveCssProvider>
|
|
189
192
|
<SearchAgentWrapper enabledAgents={enabledAgents}>
|
|
190
193
|
<WindowChatToggleBinder />
|
|
@@ -10,6 +10,7 @@ import { appDetailsAtom } from 'src/atoms/app';
|
|
|
10
10
|
import { EnviveMetricsEventName } from 'src/services/amplitudeService/amplitudeService';
|
|
11
11
|
import { toCamelCase } from 'src/application/models/utils/snakeToCamelTransformer';
|
|
12
12
|
import { UserEvent } from 'src/application/models';
|
|
13
|
+
import { getQueryParam } from 'src/application/utils';
|
|
13
14
|
import { WidgetTypeV3 } from '../typesV3';
|
|
14
15
|
import { useFeatureFlagService } from '../featureFlagServiceContext/featureFlagServiceContext';
|
|
15
16
|
import { useAmplitude } from '../amplitudeContext';
|
|
@@ -197,7 +198,15 @@ const MOCK_HARDCOPY_RESPONSE: Partial<Record<WidgetTypeV3, HardcopyResponse>> =
|
|
|
197
198
|
|
|
198
199
|
const HardcopyContext = createContext<HardcopyContextType | undefined>(undefined);
|
|
199
200
|
|
|
200
|
-
|
|
201
|
+
interface HardcopyProviderProps {
|
|
202
|
+
children: ReactNode;
|
|
203
|
+
hardcopyOverride?: Partial<Record<WidgetTypeV3, HardcopyResponse>>;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export const HardcopyProvider: React.FC<HardcopyProviderProps> = ({
|
|
207
|
+
children,
|
|
208
|
+
hardcopyOverride,
|
|
209
|
+
}) => {
|
|
201
210
|
const languages = useMemo(() => navigator.languages, []);
|
|
202
211
|
const [isLoading, setIsLoading] = useState(false);
|
|
203
212
|
const context = useAtomValue(appDetailsAtom);
|
|
@@ -206,12 +215,21 @@ export const HardcopyProvider: React.FC<{ children: ReactNode }> = ({ children }
|
|
|
206
215
|
const { featureFlagService } = useFeatureFlagService();
|
|
207
216
|
const getHardcopyFromBackend = useCallback(
|
|
208
217
|
async (request: HardcopyRequest): Promise<HardcopyResponse> => {
|
|
218
|
+
if (hardcopyOverride?.[request.widgetType]) {
|
|
219
|
+
Logger.logInfo('hardcopyContext | using hardcopy override', request.widgetType);
|
|
220
|
+
return hardcopyOverride[request.widgetType]!;
|
|
221
|
+
}
|
|
222
|
+
const overrideConfigVersion =
|
|
223
|
+
getQueryParam('spiffy_config_version') ||
|
|
224
|
+
getQueryParam('envive_config_version') ||
|
|
225
|
+
undefined;
|
|
209
226
|
const widgetTextRequest: WidgetTextRequest = {
|
|
210
227
|
requestId: uuid(),
|
|
211
228
|
widgetType: request.widgetType,
|
|
212
229
|
context,
|
|
213
230
|
featureFlags: featureFlagService?.getFeatureFlags() || {},
|
|
214
231
|
language: languages[0] || 'en',
|
|
232
|
+
overrideConfigVersion,
|
|
215
233
|
url: window.location.href,
|
|
216
234
|
};
|
|
217
235
|
trackEvent({
|
|
@@ -247,7 +265,7 @@ export const HardcopyProvider: React.FC<{ children: ReactNode }> = ({ children }
|
|
|
247
265
|
}
|
|
248
266
|
throw new Error(`No hardcopy response found for widget type: ${request.widgetType}`);
|
|
249
267
|
},
|
|
250
|
-
[context, featureFlagService, languages, trackEvent],
|
|
268
|
+
[context, featureFlagService, hardcopyOverride, languages, trackEvent],
|
|
251
269
|
);
|
|
252
270
|
|
|
253
271
|
const getHardcopy = useCallback(
|
|
@@ -67,11 +67,15 @@ export const PageProvider: React.FC<{
|
|
|
67
67
|
|
|
68
68
|
const setVariantFromUrlResolver = useCallback(
|
|
69
69
|
(url: string, response: UrlResolverResponse) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
if (response.ready) {
|
|
71
|
+
const newVariantInfo = mapUrlResolverResponseToVariantInfo(url, response);
|
|
72
|
+
const newUserEvent = mapApiUserEventToUserEvent(response.user_event ?? undefined);
|
|
73
|
+
setVariantInfo(newVariantInfo);
|
|
74
|
+
setUserEvent(newUserEvent);
|
|
75
|
+
} else {
|
|
76
|
+
setUserEvent(undefined);
|
|
77
|
+
setVariantInfo(undefined);
|
|
78
|
+
}
|
|
75
79
|
},
|
|
76
80
|
[setVariantInfo, setUserEvent],
|
|
77
81
|
);
|
|
@@ -56,7 +56,6 @@ export const useSalesAgentChatAPI = () => {
|
|
|
56
56
|
const logPageVisit = useCallback(
|
|
57
57
|
({ pageVisitCategory }: { pageVisitCategory: PageVisitCategory }) => {
|
|
58
58
|
const eventId = uuid();
|
|
59
|
-
console.log('=== logPageVisit ===', eventId);
|
|
60
59
|
trackEvent({
|
|
61
60
|
eventName: EnviveMetricsEventName.ChatRequest,
|
|
62
61
|
eventProps: {
|
package/src/contexts/types.ts
CHANGED
|
@@ -13,7 +13,8 @@ import { ChatState } from 'src/types/custservice-types';
|
|
|
13
13
|
import { SuggestionBarLocationForMetrics } from 'src/types/suggestionBarV2-types';
|
|
14
14
|
import { TestProps } from 'src/types/test-types';
|
|
15
15
|
import { OrgConfigFeatureGate } from 'src/application/models/api/orgConfigResults';
|
|
16
|
-
import { WidgetConfigV3 } from './typesV3';
|
|
16
|
+
import { WidgetConfigV3, WidgetTypeV3 } from './typesV3';
|
|
17
|
+
import type { HardcopyResponse } from './hardcopyContext/hardcopyContext';
|
|
17
18
|
|
|
18
19
|
type ShowFloatingButtonOptions =
|
|
19
20
|
| 'always'
|
|
@@ -937,6 +938,7 @@ export interface EnviveConfig {
|
|
|
937
938
|
enviveOn?: boolean;
|
|
938
939
|
publicKey?: string;
|
|
939
940
|
featureGates?: OrgConfigFeatureGate[];
|
|
941
|
+
hardcopyOverride?: Partial<Record<WidgetTypeV3, HardcopyResponse>>;
|
|
940
942
|
}
|
|
941
943
|
|
|
942
944
|
export type {
|
package/src/contexts/typesV3.ts
CHANGED
|
@@ -184,6 +184,23 @@ type FloatingButtonConfig = {
|
|
|
184
184
|
style: Style;
|
|
185
185
|
};
|
|
186
186
|
|
|
187
|
+
export type ReferrerPopupTrigger = {
|
|
188
|
+
type: 'referrer';
|
|
189
|
+
referrers: string[];
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export type AutomaticPopupTrigger = {
|
|
193
|
+
type: 'automatic';
|
|
194
|
+
};
|
|
195
|
+
export type PopupTrigger = ReferrerPopupTrigger | AutomaticPopupTrigger;
|
|
196
|
+
export type AutoPopupTrigger = {
|
|
197
|
+
delay: number;
|
|
198
|
+
trigger: PopupTrigger;
|
|
199
|
+
};
|
|
200
|
+
export interface AutoPopupConfig {
|
|
201
|
+
triggers: AutoPopupTrigger[];
|
|
202
|
+
}
|
|
203
|
+
|
|
187
204
|
type FloatingChatConfig = {
|
|
188
205
|
headerBackgroundColor?: string;
|
|
189
206
|
headerMode: Mode;
|
|
@@ -196,6 +213,7 @@ type FloatingChatConfig = {
|
|
|
196
213
|
welcomeMessageTitle: string;
|
|
197
214
|
welcomeMessageText: string;
|
|
198
215
|
chatFooterTextFieldPlaceholderText: string;
|
|
216
|
+
autoPopupConfig?: AutoPopupConfig;
|
|
199
217
|
};
|
|
200
218
|
|
|
201
219
|
type CustomerServiceIntegration = {
|
|
@@ -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 {
|