@envive-ai/react-widgets-v3 0.3.13 → 0.3.14
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/CXIntegration/implementations/useHelpScoutUnifiedCXButton.cjs +65 -0
- package/dist/CXIntegration/implementations/useHelpScoutUnifiedCXButton.js +64 -0
- package/dist/CXIntegration/implementations/useTalkdeskUnifiedCXButton.cjs +64 -0
- package/dist/CXIntegration/implementations/useTalkdeskUnifiedCXButton.js +63 -0
- package/dist/CXIntegration/types.cjs +2 -0
- package/dist/CXIntegration/types.js +2 -0
- package/dist/CXIntegration/utils/functions.cjs +4 -0
- package/dist/CXIntegration/utils/functions.js +4 -0
- package/dist/hocs/withBaseWidget/withBaseWidget.d.cts +2 -2
- package/dist/hocs/withBaseWidget/withBaseWidget.d.ts +2 -2
- package/dist/packages/widgets/dist/SearchResults/SearchResults.d.ts +2 -2
- package/dist/packages/widgets/dist/SearchResults/SearchResultsWidget.d.ts +2 -2
- package/dist/packages/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.ts +2 -2
- package/dist/packages/widgets/dist/SuggestionBar/SuggestionBar.d.ts +2 -2
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +3 -3
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +2 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +2 -2
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.cts +2 -2
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.cjs +19 -3
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.js +20 -4
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +10 -0
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +12 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +2 -9
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +1 -8
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
- package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +10 -0
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.js +12 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +11 -0
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +12 -1
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +2 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +23 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +24 -4
- package/dist/widgets/dist/SearchResults/SearchResults.d.cts +2 -2
- package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.cts +2 -2
- package/dist/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.cts +2 -2
- package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.cts +2 -2
- package/dist/widgets/utils/functions.cjs +9 -0
- package/dist/widgets/utils/functions.js +9 -1
- package/package.json +1 -1
- package/src/CXIntegration/implementations/useHelpScoutUnifiedCXButton.ts +108 -0
- package/src/CXIntegration/implementations/useTalkdeskUnifiedCXButton.ts +94 -0
- package/src/CXIntegration/types.ts +2 -0
- package/src/CXIntegration/utils/functions.ts +8 -0
- package/src/hocs/withBaseWidget/__tests__/withBaseWidget.test.tsx +15 -3
- package/src/widgets/ChatPreviewWidget/__tests__/ChatPreviewWidget.test.tsx +114 -0
- package/src/widgets/FloatingChatWidget/__tests__/FloatingChatWidget.test.tsx +119 -0
- package/src/widgets/ProductCardWidget/ProductCardWidget.tsx +15 -3
- package/src/widgets/ProductCardWidget/__tests__/ProductCardWidget.test.tsx +144 -0
- package/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx +12 -1
- package/src/widgets/PromptButtonCarouselWithImageWidget/__tests__/PromptButtonCarouselWithImageWidget.test.tsx +179 -0
- package/src/widgets/PromptCarouselWidget/PromptCarouselWidget.tsx +1 -14
- package/src/widgets/PromptCarouselWidget/__tests__/PromptCarouselWidget.test.tsx +150 -0
- package/src/widgets/SocialProofWidget/SocialProofWidget.tsx +12 -1
- package/src/widgets/SocialProofWidget/__tests__/SocialProofWidget.test.tsx +184 -0
- package/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.tsx +12 -0
- package/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.tsx +150 -0
- package/src/widgets/TypingAnimationWidget/TypingAnimationWidget.tsx +19 -2
- package/src/widgets/TypingAnimationWidget/__tests__/TypingAnimationWidget.test.tsx +163 -0
- package/src/widgets/__tests__/testUtils.tsx +63 -0
- package/src/widgets/__tests__/trackEventCanary.test.ts +45 -0
- package/src/widgets/utils/functions.ts +16 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { readFileSync, readdirSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
|
|
4
|
+
const WIDGETS_SRC_DIR = join(process.cwd(), 'src');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Known count of trackEvent({ invocations in widget source files (excluding tests and stories).
|
|
8
|
+
* Update this when adding new trackEvent calls - and add a test for the new event!
|
|
9
|
+
*/
|
|
10
|
+
const EXPECTED_TRACK_EVENT_CALL_COUNT = 15;
|
|
11
|
+
|
|
12
|
+
function getAllSourceFiles(dir: string, files: string[] = []): string[] {
|
|
13
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
14
|
+
for (const entry of entries) {
|
|
15
|
+
const fullPath = join(dir, entry.name);
|
|
16
|
+
if (entry.isDirectory()) {
|
|
17
|
+
if (!entry.name.startsWith('.') && entry.name !== 'node_modules') {
|
|
18
|
+
getAllSourceFiles(fullPath, files);
|
|
19
|
+
}
|
|
20
|
+
} else if (entry.isFile() && /\.(ts|tsx)$/.test(entry.name)) {
|
|
21
|
+
files.push(fullPath);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return files;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
describe('trackEvent canary', () => {
|
|
28
|
+
it('should not add new trackEvent calls without updating this test', () => {
|
|
29
|
+
const files = getAllSourceFiles(WIDGETS_SRC_DIR).filter(
|
|
30
|
+
file =>
|
|
31
|
+
!file.includes('__tests__') && !file.includes('.test.') && !file.includes('.stories.'),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
let count = 0;
|
|
35
|
+
for (const file of files) {
|
|
36
|
+
const content = readFileSync(file, 'utf-8');
|
|
37
|
+
const matches = content.match(/trackEvent\s*\(\s*\{/g);
|
|
38
|
+
if (matches) {
|
|
39
|
+
count += matches.length;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
expect(count).toBe(EXPECTED_TRACK_EVENT_CALL_COUNT);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -102,3 +102,19 @@ export const isProductComparison = (lastMsg?: Message[] | null | undefined): boo
|
|
|
102
102
|
const lastAssistantMessage = atomStore.get(lastAssistantMessageAtom);
|
|
103
103
|
return lastAssistantMessage?.filter(msg => msg.type === MessageType.Product).length === 2;
|
|
104
104
|
};
|
|
105
|
+
|
|
106
|
+
type RawWidgetString = { id: string; value: string };
|
|
107
|
+
export type RawValues = Record<string, RawWidgetString | RawWidgetString[]>;
|
|
108
|
+
/** Finds the string_id (id) from raw widget text values for the given display text */
|
|
109
|
+
export const getStringIdForText = (
|
|
110
|
+
rawValues: RawValues | undefined,
|
|
111
|
+
text: string,
|
|
112
|
+
): string | undefined => {
|
|
113
|
+
if (!rawValues) return undefined;
|
|
114
|
+
for (const raw of Object.values(rawValues)) {
|
|
115
|
+
const list = Array.isArray(raw) ? raw : [raw];
|
|
116
|
+
const found = list.find((s: RawWidgetString) => s.value === text);
|
|
117
|
+
if (found) return found.id;
|
|
118
|
+
}
|
|
119
|
+
return undefined;
|
|
120
|
+
};
|