@patternfly/chatbot 2.2.0-prerelease.30 → 2.2.0-prerelease.32
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/cjs/Chatbot/Chatbot.d.ts +2 -1
- package/dist/cjs/Chatbot/Chatbot.js +1 -0
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +1 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderTitle.d.ts +3 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderTitle.js +4 -2
- package/dist/cjs/ChatbotHeader/ChatbotHeaderTitle.test.js +15 -7
- package/dist/cjs/Message/ErrorMessage/ErrorMessage.d.ts +4 -0
- package/dist/cjs/Message/ErrorMessage/ErrorMessage.js +26 -0
- package/dist/cjs/Message/Message.d.ts +3 -1
- package/dist/cjs/Message/Message.js +4 -3
- package/dist/cjs/Message/Message.test.js +25 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/tracking/console_tracking_provider.d.ts +10 -0
- package/dist/cjs/tracking/console_tracking_provider.js +27 -0
- package/dist/cjs/tracking/index.d.ts +2 -0
- package/dist/cjs/tracking/index.js +23 -0
- package/dist/cjs/tracking/posthog_tracking_provider.d.ts +9 -0
- package/dist/cjs/tracking/posthog_tracking_provider.js +37 -0
- package/dist/cjs/tracking/segment_tracking_provider.d.ts +10 -0
- package/dist/cjs/tracking/segment_tracking_provider.js +50 -0
- package/dist/cjs/tracking/trackingProviderProxy.d.ts +9 -0
- package/dist/cjs/tracking/trackingProviderProxy.js +24 -0
- package/dist/cjs/tracking/tracking_api.d.ts +8 -0
- package/dist/cjs/tracking/tracking_api.js +2 -0
- package/dist/cjs/tracking/tracking_registry.d.ts +4 -0
- package/dist/cjs/tracking/tracking_registry.js +33 -0
- package/dist/cjs/tracking/tracking_spi.d.ts +9 -0
- package/dist/cjs/tracking/tracking_spi.js +2 -0
- package/dist/cjs/tracking/umami_tracking_provider.d.ts +14 -0
- package/dist/cjs/tracking/umami_tracking_provider.js +44 -0
- package/dist/css/main.css +28 -3
- package/dist/css/main.css.map +1 -1
- package/dist/dynamic/tracking/package.json +1 -0
- package/dist/esm/Chatbot/Chatbot.d.ts +2 -1
- package/dist/esm/Chatbot/Chatbot.js +1 -0
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +1 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderTitle.d.ts +3 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderTitle.js +4 -2
- package/dist/esm/ChatbotHeader/ChatbotHeaderTitle.test.js +15 -7
- package/dist/esm/Message/ErrorMessage/ErrorMessage.d.ts +4 -0
- package/dist/esm/Message/ErrorMessage/ErrorMessage.js +21 -0
- package/dist/esm/Message/Message.d.ts +3 -1
- package/dist/esm/Message/Message.js +4 -3
- package/dist/esm/Message/Message.test.js +25 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/tracking/console_tracking_provider.d.ts +10 -0
- package/dist/esm/tracking/console_tracking_provider.js +23 -0
- package/dist/esm/tracking/index.d.ts +2 -0
- package/dist/esm/tracking/index.js +2 -0
- package/dist/esm/tracking/posthog_tracking_provider.d.ts +9 -0
- package/dist/esm/tracking/posthog_tracking_provider.js +33 -0
- package/dist/esm/tracking/segment_tracking_provider.d.ts +10 -0
- package/dist/esm/tracking/segment_tracking_provider.js +46 -0
- package/dist/esm/tracking/trackingProviderProxy.d.ts +9 -0
- package/dist/esm/tracking/trackingProviderProxy.js +22 -0
- package/dist/esm/tracking/tracking_api.d.ts +8 -0
- package/dist/esm/tracking/tracking_api.js +1 -0
- package/dist/esm/tracking/tracking_registry.d.ts +4 -0
- package/dist/esm/tracking/tracking_registry.js +26 -0
- package/dist/esm/tracking/tracking_spi.d.ts +9 -0
- package/dist/esm/tracking/tracking_spi.js +1 -0
- package/dist/esm/tracking/umami_tracking_provider.d.ts +14 -0
- package/dist/esm/tracking/umami_tracking_provider.js +40 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -3
- package/patternfly-docs/content/extensions/chatbot/about-chatbot.md +3 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Analytics/Analytics.md +219 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/BotMessage.tsx +24 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessage.tsx +24 -1
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +13 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.tsx +37 -24
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotInDrawer.tsx +453 -0
- package/patternfly-docs/content/extensions/chatbot/img/analytics-example.svg +118 -0
- package/patternfly-docs/content/extensions/chatbot/img/chatbot-analytics.svg +51 -0
- package/patternfly-docs/content/extensions/chatbot/img/posthog.svg +30 -0
- package/patternfly-docs/content/extensions/chatbot/img/segment.svg +36 -0
- package/patternfly-docs/content/extensions/chatbot/img/umami.svg +30 -0
- package/src/Chatbot/Chatbot.scss +19 -0
- package/src/Chatbot/Chatbot.tsx +2 -1
- package/src/ChatbotContent/ChatbotContent.scss +1 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +2 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +1 -1
- package/src/ChatbotFooter/ChatbotFooter.scss +9 -0
- package/src/ChatbotHeader/ChatbotHeader.scss +2 -1
- package/src/ChatbotHeader/ChatbotHeaderTitle.test.tsx +23 -7
- package/src/ChatbotHeader/ChatbotHeaderTitle.tsx +7 -2
- package/src/Message/ErrorMessage/ErrorMessage.tsx +14 -0
- package/src/Message/Message.test.tsx +32 -0
- package/src/Message/Message.tsx +50 -41
- package/src/MessageBar/MessageBar.scss +3 -3
- package/src/MessageBox/MessageBox.scss +1 -0
- package/src/index.ts +3 -0
- package/src/tracking/console_tracking_provider.ts +30 -0
- package/src/tracking/index.ts +3 -0
- package/src/tracking/posthog_tracking_provider.ts +42 -0
- package/src/tracking/segment_tracking_provider.ts +62 -0
- package/src/tracking/trackingProviderProxy.ts +28 -0
- package/src/tracking/tracking_api.ts +11 -0
- package/src/tracking/tracking_registry.ts +33 -0
- package/src/tracking/tracking_spi.ts +14 -0
- package/src/tracking/umami_tracking_provider.ts +54 -0
@@ -0,0 +1,9 @@
|
|
1
|
+
import { TrackingApi, TrackingEventProperties } from './tracking_api';
|
2
|
+
export interface InitProps {
|
3
|
+
[key: string]: string | number | boolean;
|
4
|
+
}
|
5
|
+
export interface TrackingSpi extends TrackingApi {
|
6
|
+
getKey: () => string;
|
7
|
+
initialize: (props: InitProps) => void;
|
8
|
+
trackSingleItem: (item: string, properties?: TrackingEventProperties) => void;
|
9
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { InitProps, TrackingSpi } from './tracking_spi';
|
2
|
+
import { TrackingApi, TrackingEventProperties } from './tracking_api';
|
3
|
+
declare global {
|
4
|
+
interface Window {
|
5
|
+
umami: any;
|
6
|
+
}
|
7
|
+
}
|
8
|
+
export declare class UmamiTrackingProvider implements TrackingSpi, TrackingApi {
|
9
|
+
getKey(): string;
|
10
|
+
initialize(props: InitProps): void;
|
11
|
+
identify(userID: string): void;
|
12
|
+
trackPageView(url: string | undefined): void;
|
13
|
+
trackSingleItem(item: string, properties?: TrackingEventProperties): void;
|
14
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
export class UmamiTrackingProvider {
|
2
|
+
getKey() {
|
3
|
+
return 'umamiKey';
|
4
|
+
}
|
5
|
+
initialize(props) {
|
6
|
+
// eslint-disable-next-line no-console
|
7
|
+
console.log('UmamiProvider initialize');
|
8
|
+
const umamiKey = props.umamiKey;
|
9
|
+
const hostUrl = props.umamiHostUrl;
|
10
|
+
const script = document.createElement('script');
|
11
|
+
script.src = hostUrl + '/script.js';
|
12
|
+
script.async = true;
|
13
|
+
script.defer = true;
|
14
|
+
// Configure Umami properties
|
15
|
+
script.setAttribute('data-website-id', umamiKey);
|
16
|
+
script.setAttribute('data-domains', 'localhost'); // TODO ?
|
17
|
+
script.setAttribute('data-auto-track', 'false');
|
18
|
+
script.setAttribute('data-host-url', hostUrl); // TODO ?
|
19
|
+
script.setAttribute('data-exclude-search', 'false'); // TODO ?
|
20
|
+
document.body.appendChild(script);
|
21
|
+
}
|
22
|
+
identify(userID) {
|
23
|
+
var _a;
|
24
|
+
// eslint-disable-next-line no-console
|
25
|
+
console.log('UmamiProvider userID: ' + userID);
|
26
|
+
(_a = window.umami) === null || _a === void 0 ? void 0 : _a.identify({ userID });
|
27
|
+
}
|
28
|
+
trackPageView(url) {
|
29
|
+
var _a;
|
30
|
+
// eslint-disable-next-line no-console
|
31
|
+
console.log('UmamiProvider url', url);
|
32
|
+
(_a = window.umami) === null || _a === void 0 ? void 0 : _a.track({ url });
|
33
|
+
}
|
34
|
+
trackSingleItem(item, properties) {
|
35
|
+
var _a;
|
36
|
+
// eslint-disable-next-line no-console
|
37
|
+
console.log('UmamiProvider: trackSingleItem' + item, properties);
|
38
|
+
(_a = window.umami) === null || _a === void 0 ? void 0 : _a.track(item, properties);
|
39
|
+
}
|
40
|
+
}
|
@@ -1 +1 @@
|
|
1
|
-
{"root":["../src/index.ts","../src/AttachMenu/AttachMenu.tsx","../src/AttachMenu/index.ts","../src/AttachmentEdit/AttachmentEdit.test.tsx","../src/AttachmentEdit/AttachmentEdit.tsx","../src/AttachmentEdit/index.ts","../src/Chatbot/Chatbot.test.tsx","../src/Chatbot/Chatbot.tsx","../src/Chatbot/index.ts","../src/ChatbotAlert/ChatbotAlert.test.tsx","../src/ChatbotAlert/ChatbotAlert.tsx","../src/ChatbotAlert/index.ts","../src/ChatbotContent/ChatbotContent.test.tsx","../src/ChatbotContent/ChatbotContent.tsx","../src/ChatbotContent/index.ts","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx","../src/ChatbotConversationHistoryNav/EmptyState.tsx","../src/ChatbotConversationHistoryNav/LoadingState.tsx","../src/ChatbotConversationHistoryNav/index.ts","../src/ChatbotFooter/ChatbotFooter.test.tsx","../src/ChatbotFooter/ChatbotFooter.tsx","../src/ChatbotFooter/ChatbotFooternote.test.tsx","../src/ChatbotFooter/ChatbotFootnote.tsx","../src/ChatbotFooter/index.ts","../src/ChatbotHeader/ChatbotHeader.test.tsx","../src/ChatbotHeader/ChatbotHeader.tsx","../src/ChatbotHeader/ChatbotHeaderActions.test.tsx","../src/ChatbotHeader/ChatbotHeaderActions.tsx","../src/ChatbotHeader/ChatbotHeaderCloseButton.test.tsx","../src/ChatbotHeader/ChatbotHeaderCloseButton.tsx","../src/ChatbotHeader/ChatbotHeaderMain.test.tsx","../src/ChatbotHeader/ChatbotHeaderMain.tsx","../src/ChatbotHeader/ChatbotHeaderMenu.test.tsx","../src/ChatbotHeader/ChatbotHeaderMenu.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.test.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.tsx","../src/ChatbotHeader/index.ts","../src/ChatbotModal/ChatbotModal.tsx","../src/ChatbotModal/index.ts","../src/ChatbotPopover/ChatbotPopover.tsx","../src/ChatbotPopover/index.ts","../src/ChatbotToggle/ChatbotToggle.test.tsx","../src/ChatbotToggle/ChatbotToggle.tsx","../src/ChatbotToggle/index.ts","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.tsx","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.tsx","../src/ChatbotWelcomePrompt/index.ts","../src/CodeModal/CodeModal.tsx","../src/CodeModal/index.ts","../src/Compare/Compare.test.tsx","../src/Compare/Compare.tsx","../src/Compare/index.ts","../src/FileDetails/FileDetails.test.tsx","../src/FileDetails/FileDetails.tsx","../src/FileDetails/index.ts","../src/FileDetailsLabel/FileDetailsLabel.test.tsx","../src/FileDetailsLabel/FileDetailsLabel.tsx","../src/FileDetailsLabel/index.ts","../src/FileDropZone/FileDropZone.test.tsx","../src/FileDropZone/FileDropZone.tsx","../src/FileDropZone/index.ts","../src/LoadingMessage/LoadingMessage.test.tsx","../src/LoadingMessage/LoadingMessage.tsx","../src/LoadingMessage/index.ts","../src/Message/Message.test.tsx","../src/Message/Message.tsx","../src/Message/MessageLoading.tsx","../src/Message/index.ts","../src/Message/CodeBlockMessage/CodeBlockMessage.tsx","../src/Message/ImageMessage/ImageMessage.tsx","../src/Message/LinkMessage/LinkMessage.tsx","../src/Message/ListMessage/ListItemMessage.tsx","../src/Message/ListMessage/OrderedListMessage.tsx","../src/Message/ListMessage/UnorderedListMessage.tsx","../src/Message/QuickResponse/QuickResponse.tsx","../src/Message/QuickStarts/FallbackImg.tsx","../src/Message/QuickStarts/QuickStartTile.tsx","../src/Message/QuickStarts/QuickStartTileDescription.test.tsx","../src/Message/QuickStarts/QuickStartTileDescription.tsx","../src/Message/QuickStarts/QuickStartTileHeader.tsx","../src/Message/QuickStarts/monitor-sampleapp-quickstart-with-image.ts","../src/Message/QuickStarts/monitor-sampleapp-quickstart.ts","../src/Message/QuickStarts/types.ts","../src/Message/TableMessage/TableMessage.tsx","../src/Message/TableMessage/TbodyMessage.tsx","../src/Message/TableMessage/TdMessage.tsx","../src/Message/TableMessage/ThMessage.tsx","../src/Message/TableMessage/TheadMessage.tsx","../src/Message/TableMessage/TrMessage.tsx","../src/Message/TextMessage/TextMessage.tsx","../src/Message/UserFeedback/CloseButton.tsx","../src/Message/UserFeedback/UserFeedback.test.tsx","../src/Message/UserFeedback/UserFeedback.tsx","../src/Message/UserFeedback/UserFeedbackComplete.test.tsx","../src/Message/UserFeedback/UserFeedbackComplete.tsx","../src/MessageBar/AttachButton.test.tsx","../src/MessageBar/AttachButton.tsx","../src/MessageBar/MessageBar.test.tsx","../src/MessageBar/MessageBar.tsx","../src/MessageBar/MicrophoneButton.tsx","../src/MessageBar/SendButton.test.tsx","../src/MessageBar/SendButton.tsx","../src/MessageBar/StopButton.test.tsx","../src/MessageBar/StopButton.tsx","../src/MessageBar/index.ts","../src/MessageBox/JumpButton.test.tsx","../src/MessageBox/JumpButton.tsx","../src/MessageBox/MessageBox.test.tsx","../src/MessageBox/MessageBox.tsx","../src/MessageBox/index.ts","../src/PreviewAttachment/PreviewAttachment.test.tsx","../src/PreviewAttachment/PreviewAttachment.tsx","../src/PreviewAttachment/index.ts","../src/ResponseActions/ResponseActionButton.test.tsx","../src/ResponseActions/ResponseActionButton.tsx","../src/ResponseActions/ResponseActions.test.tsx","../src/ResponseActions/ResponseActions.tsx","../src/ResponseActions/index.ts","../src/Settings/SettingsForm.test.tsx","../src/Settings/SettingsForm.tsx","../src/Settings/index.ts","../src/SourceDetailsMenuItem/SourceDetailsMenuItem.tsx","../src/SourceDetailsMenuItem/index.ts","../src/SourcesCard/SourcesCard.test.tsx","../src/SourcesCard/SourcesCard.tsx","../src/SourcesCard/index.ts","../src/TermsOfUse/TermsOfUse.test.tsx","../src/TermsOfUse/TermsOfUse.tsx","../src/TermsOfUse/index.ts","../src/__mocks__/rehype-external-links.ts","../src/__mocks__/rehype-sanitize.ts","../src/__mocks__/rehype-unwrap-images.tsx"],"version":"5.6.3"}
|
1
|
+
{"root":["../src/index.ts","../src/AttachMenu/AttachMenu.tsx","../src/AttachMenu/index.ts","../src/AttachmentEdit/AttachmentEdit.test.tsx","../src/AttachmentEdit/AttachmentEdit.tsx","../src/AttachmentEdit/index.ts","../src/Chatbot/Chatbot.test.tsx","../src/Chatbot/Chatbot.tsx","../src/Chatbot/index.ts","../src/ChatbotAlert/ChatbotAlert.test.tsx","../src/ChatbotAlert/ChatbotAlert.tsx","../src/ChatbotAlert/index.ts","../src/ChatbotContent/ChatbotContent.test.tsx","../src/ChatbotContent/ChatbotContent.tsx","../src/ChatbotContent/index.ts","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx","../src/ChatbotConversationHistoryNav/EmptyState.tsx","../src/ChatbotConversationHistoryNav/LoadingState.tsx","../src/ChatbotConversationHistoryNav/index.ts","../src/ChatbotFooter/ChatbotFooter.test.tsx","../src/ChatbotFooter/ChatbotFooter.tsx","../src/ChatbotFooter/ChatbotFooternote.test.tsx","../src/ChatbotFooter/ChatbotFootnote.tsx","../src/ChatbotFooter/index.ts","../src/ChatbotHeader/ChatbotHeader.test.tsx","../src/ChatbotHeader/ChatbotHeader.tsx","../src/ChatbotHeader/ChatbotHeaderActions.test.tsx","../src/ChatbotHeader/ChatbotHeaderActions.tsx","../src/ChatbotHeader/ChatbotHeaderCloseButton.test.tsx","../src/ChatbotHeader/ChatbotHeaderCloseButton.tsx","../src/ChatbotHeader/ChatbotHeaderMain.test.tsx","../src/ChatbotHeader/ChatbotHeaderMain.tsx","../src/ChatbotHeader/ChatbotHeaderMenu.test.tsx","../src/ChatbotHeader/ChatbotHeaderMenu.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.test.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.tsx","../src/ChatbotHeader/index.ts","../src/ChatbotModal/ChatbotModal.tsx","../src/ChatbotModal/index.ts","../src/ChatbotPopover/ChatbotPopover.tsx","../src/ChatbotPopover/index.ts","../src/ChatbotToggle/ChatbotToggle.test.tsx","../src/ChatbotToggle/ChatbotToggle.tsx","../src/ChatbotToggle/index.ts","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.tsx","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.tsx","../src/ChatbotWelcomePrompt/index.ts","../src/CodeModal/CodeModal.tsx","../src/CodeModal/index.ts","../src/Compare/Compare.test.tsx","../src/Compare/Compare.tsx","../src/Compare/index.ts","../src/FileDetails/FileDetails.test.tsx","../src/FileDetails/FileDetails.tsx","../src/FileDetails/index.ts","../src/FileDetailsLabel/FileDetailsLabel.test.tsx","../src/FileDetailsLabel/FileDetailsLabel.tsx","../src/FileDetailsLabel/index.ts","../src/FileDropZone/FileDropZone.test.tsx","../src/FileDropZone/FileDropZone.tsx","../src/FileDropZone/index.ts","../src/LoadingMessage/LoadingMessage.test.tsx","../src/LoadingMessage/LoadingMessage.tsx","../src/LoadingMessage/index.ts","../src/Message/Message.test.tsx","../src/Message/Message.tsx","../src/Message/MessageLoading.tsx","../src/Message/index.ts","../src/Message/CodeBlockMessage/CodeBlockMessage.tsx","../src/Message/ErrorMessage/ErrorMessage.tsx","../src/Message/ImageMessage/ImageMessage.tsx","../src/Message/LinkMessage/LinkMessage.tsx","../src/Message/ListMessage/ListItemMessage.tsx","../src/Message/ListMessage/OrderedListMessage.tsx","../src/Message/ListMessage/UnorderedListMessage.tsx","../src/Message/QuickResponse/QuickResponse.tsx","../src/Message/QuickStarts/FallbackImg.tsx","../src/Message/QuickStarts/QuickStartTile.tsx","../src/Message/QuickStarts/QuickStartTileDescription.test.tsx","../src/Message/QuickStarts/QuickStartTileDescription.tsx","../src/Message/QuickStarts/QuickStartTileHeader.tsx","../src/Message/QuickStarts/monitor-sampleapp-quickstart-with-image.ts","../src/Message/QuickStarts/monitor-sampleapp-quickstart.ts","../src/Message/QuickStarts/types.ts","../src/Message/TableMessage/TableMessage.tsx","../src/Message/TableMessage/TbodyMessage.tsx","../src/Message/TableMessage/TdMessage.tsx","../src/Message/TableMessage/ThMessage.tsx","../src/Message/TableMessage/TheadMessage.tsx","../src/Message/TableMessage/TrMessage.tsx","../src/Message/TextMessage/TextMessage.tsx","../src/Message/UserFeedback/CloseButton.tsx","../src/Message/UserFeedback/UserFeedback.test.tsx","../src/Message/UserFeedback/UserFeedback.tsx","../src/Message/UserFeedback/UserFeedbackComplete.test.tsx","../src/Message/UserFeedback/UserFeedbackComplete.tsx","../src/MessageBar/AttachButton.test.tsx","../src/MessageBar/AttachButton.tsx","../src/MessageBar/MessageBar.test.tsx","../src/MessageBar/MessageBar.tsx","../src/MessageBar/MicrophoneButton.tsx","../src/MessageBar/SendButton.test.tsx","../src/MessageBar/SendButton.tsx","../src/MessageBar/StopButton.test.tsx","../src/MessageBar/StopButton.tsx","../src/MessageBar/index.ts","../src/MessageBox/JumpButton.test.tsx","../src/MessageBox/JumpButton.tsx","../src/MessageBox/MessageBox.test.tsx","../src/MessageBox/MessageBox.tsx","../src/MessageBox/index.ts","../src/PreviewAttachment/PreviewAttachment.test.tsx","../src/PreviewAttachment/PreviewAttachment.tsx","../src/PreviewAttachment/index.ts","../src/ResponseActions/ResponseActionButton.test.tsx","../src/ResponseActions/ResponseActionButton.tsx","../src/ResponseActions/ResponseActions.test.tsx","../src/ResponseActions/ResponseActions.tsx","../src/ResponseActions/index.ts","../src/Settings/SettingsForm.test.tsx","../src/Settings/SettingsForm.tsx","../src/Settings/index.ts","../src/SourceDetailsMenuItem/SourceDetailsMenuItem.tsx","../src/SourceDetailsMenuItem/index.ts","../src/SourcesCard/SourcesCard.test.tsx","../src/SourcesCard/SourcesCard.tsx","../src/SourcesCard/index.ts","../src/TermsOfUse/TermsOfUse.test.tsx","../src/TermsOfUse/TermsOfUse.tsx","../src/TermsOfUse/index.ts","../src/__mocks__/rehype-external-links.ts","../src/__mocks__/rehype-sanitize.ts","../src/__mocks__/rehype-unwrap-images.tsx","../src/tracking/console_tracking_provider.ts","../src/tracking/index.ts","../src/tracking/posthog_tracking_provider.ts","../src/tracking/segment_tracking_provider.ts","../src/tracking/trackingProviderProxy.ts","../src/tracking/tracking_api.ts","../src/tracking/tracking_registry.ts","../src/tracking/tracking_spi.ts","../src/tracking/umami_tracking_provider.ts"],"version":"5.6.3"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@patternfly/chatbot",
|
3
|
-
"version": "2.2.0-prerelease.
|
3
|
+
"version": "2.2.0-prerelease.32",
|
4
4
|
"description": "This library provides React components based on PatternFly 6 that can be used to build chatbots.",
|
5
5
|
"main": "dist/cjs/index.js",
|
6
6
|
"module": "dist/esm/index.js",
|
@@ -49,7 +49,7 @@
|
|
49
49
|
"react-dom": "^17 || ^18"
|
50
50
|
},
|
51
51
|
"devDependencies": {
|
52
|
-
"@patternfly/documentation-framework": "^6.5.
|
52
|
+
"@patternfly/documentation-framework": "^6.5.13",
|
53
53
|
"@patternfly/patternfly": "^6.1.0",
|
54
54
|
"@patternfly/patternfly-a11y": "^5.0.0",
|
55
55
|
"@patternfly/react-table": "^6.1.0",
|
@@ -71,7 +71,9 @@
|
|
71
71
|
"victory-create-container": "^37.1.1",
|
72
72
|
"victory-cursor-container": "^37.1.1",
|
73
73
|
"victory-tooltip": "^37.1.1",
|
74
|
-
"victory-bar": "^37.1.1"
|
74
|
+
"victory-bar": "^37.1.1",
|
75
|
+
"@segment/analytics-next": "^1.76.0",
|
76
|
+
"posthog-js": "^1.194.4"
|
75
77
|
},
|
76
78
|
"overrides": {
|
77
79
|
"puppeteer": "^23.6.1",
|
@@ -37,5 +37,8 @@ Explore our documentation, which covers both ChatBot UI components and message-r
|
|
37
37
|
- Messages
|
38
38
|
- [Bot and user messages](/patternfly-ai/chatbot/messages)
|
39
39
|
- [File attachments](/patternfly-ai/chatbot/messages#attachments)
|
40
|
+
- Analytics support
|
41
|
+
- [Overview](/patternfly-ai/chatbot/analytics)
|
42
|
+
|
40
43
|
|
41
44
|
We will continue to grow and evolve our ChatBot. If you notice a bug or have any suggestions, feel free to file an issue in our [GitHub repository!](https://github.com/patternfly/chatbot/issues) Make sure to check if there is already a pre-existing issue before creating a new one.
|
@@ -0,0 +1,219 @@
|
|
1
|
+
---
|
2
|
+
# Sidenav top-level section
|
3
|
+
# should be the same for all markdown files
|
4
|
+
section: PatternFly-AI
|
5
|
+
subsection: ChatBot
|
6
|
+
# Sidenav secondary level section
|
7
|
+
# should be the same for all markdown files
|
8
|
+
id: Analytics
|
9
|
+
source: Analytics
|
10
|
+
# Tab (react | react-demos | html | html-demos | design-guidelines | accessibility)
|
11
|
+
# If you use typescript, the name of the interface to display props for
|
12
|
+
# These are found through the sourceProps function provided in patternfly-docs.source.js
|
13
|
+
sortValue: 4
|
14
|
+
---
|
15
|
+
|
16
|
+
import "../../images.css"
|
17
|
+
|
18
|
+
To gain more insight into the ways that your users interact with your ChatBot, you can add support for **analytics**. To add analytics tracking, you can refer to this guide and configure tracking for the interactions you care about most.
|
19
|
+
|
20
|
+
## Elements
|
21
|
+
|
22
|
+
This following diagram shows the main components of ChatBot analytics tracking code, as well as the flow of information between components:
|
23
|
+
|
24
|
+
<div class="ws-docs-content-img">
|
25
|
+

|
26
|
+
</div>
|
27
|
+
|
28
|
+
The user code (1) first calls the static `getTrackingProviders()` method (3) which initializes the tracking providers (4). This returns an instance of the `trackingAPI` (2), which can then subsequently be used to emit analytics events.
|
29
|
+
|
30
|
+
Note that user code only interacts with:
|
31
|
+
|
32
|
+
- `trackingAPI` (including `identify`, `trackPageview`, `trackSingleItem`)
|
33
|
+
- `TrackingRegistry` (including `getTrackingProviders`)
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
### Setup
|
38
|
+
|
39
|
+
1. Before you can use the `trackingAPI`, you must first supply the API keys of the respective providers.
|
40
|
+
|
41
|
+
```nolive
|
42
|
+
const initProps: InitProps = {
|
43
|
+
segmentKey: 'TODO-key', // TODO add your key here
|
44
|
+
// segmentCdn: 'https://my.org/cdn', // Set up segment cdn (optional)
|
45
|
+
// segmentIntegrations: { // Provide Segment integrations (optional)
|
46
|
+
// 'Segment.io': {
|
47
|
+
// apiHost: 'my.api.host/api/v1',
|
48
|
+
// protocol: 'https'
|
49
|
+
// }
|
50
|
+
},
|
51
|
+
|
52
|
+
posthogKey: 'TODO-key',
|
53
|
+
umamiKey: 'TODO-key',
|
54
|
+
umamiHostUrl: 'http://localhost:3000', // TODO where is your JS provider?
|
55
|
+
something: 'test',
|
56
|
+
console: 'true' // Console provider
|
57
|
+
};
|
58
|
+
```
|
59
|
+
|
60
|
+
1. Once this is done, you can create an instance of the `trackingAPI` and start sending events.
|
61
|
+
|
62
|
+
```nolive
|
63
|
+
const trackingAPI = getTrackingProviders(initProps);
|
64
|
+
```
|
65
|
+
|
66
|
+
1. One of your first events should identify the user in some way, such as a UUID that stays consistent for the same user.
|
67
|
+
|
68
|
+
```nolive
|
69
|
+
const trackingAPI = getTrackingProviders(initProps);
|
70
|
+
trackingAPI.identify('user-123'); // TODO get real user id
|
71
|
+
// Track the page that is currently visited. Best put into a react effect (see below)
|
72
|
+
trackingAPI.trackPageView();
|
73
|
+
// Track a single Event
|
74
|
+
trackingAPI.trackSingleItem("MyEvent", { response: 'Good response' })
|
75
|
+
```
|
76
|
+
|
77
|
+
#### Tracking providers
|
78
|
+
|
79
|
+
Only providers with a matching key in the `InitProps` will be started and used.
|
80
|
+
|
81
|
+
```nolive
|
82
|
+
const initProps: InitProps = {
|
83
|
+
segmentKey: 'TODO-key', // TODO add your key here
|
84
|
+
posthogKey: 'TODO-key',
|
85
|
+
umamiKey: 'TODO-key',
|
86
|
+
umamiHostUrl: 'http://localhost:3000', // TODO where is your JS provider?
|
87
|
+
console: true
|
88
|
+
```
|
89
|
+
|
90
|
+
##### Modifying providers
|
91
|
+
|
92
|
+
If you know upfront that you only want to use 1 of the supported providers, you can modify `getTrackingProviders()` and remove all other providers in the providers array.
|
93
|
+
|
94
|
+
When using the providers you need to add additional dependencies to your package.json file:
|
95
|
+
|
96
|
+
```nolive
|
97
|
+
"dependencies": {
|
98
|
+
"@segment/analytics-next": "^1.76.0",
|
99
|
+
"posthog-js": "^1.194.4"
|
100
|
+
```
|
101
|
+
|
102
|
+
##### Adding providers
|
103
|
+
|
104
|
+
To add another analytics provider, you need to implement 2 interfaces, `TrackingSpi` and `trackingApi`.
|
105
|
+
|
106
|
+
1. It is easiest to start by copying the `ConsoleTrackingProvider`
|
107
|
+
1. The first thing you should do is to provide a correct value in `getKey()`
|
108
|
+
1. Once you are happy enough with the implementation, add it to the array of providers in `getTrackingProviders()`
|
109
|
+
|
110
|
+
### Page flow tracking
|
111
|
+
|
112
|
+
To understand how users move through their ChatBot journey, you can track their page flow.
|
113
|
+
|
114
|
+
To add tracking to each page view, use the `trackPageView()` method.
|
115
|
+
|
116
|
+
```nolive
|
117
|
+
import React from 'react';
|
118
|
+
import { useLocation } from 'react-router-dom';
|
119
|
+
|
120
|
+
export const useTrackPageFlow = (): void => {
|
121
|
+
const { pathname } = useLocation();
|
122
|
+
|
123
|
+
// notify url change events
|
124
|
+
React.useEffect(() => {
|
125
|
+
trackingAPI.trackPageView();
|
126
|
+
}, [pathname]);
|
127
|
+
};
|
128
|
+
```
|
129
|
+
|
130
|
+
### Event tracking
|
131
|
+
|
132
|
+
To get more specific insight into how users are interacting with the UI, you can track single events, including button clicks, form submissions, and so on.
|
133
|
+
|
134
|
+
To add tracking to an interaction of your choice, use the `trackSingleItem` method.
|
135
|
+
|
136
|
+
```nolive
|
137
|
+
trackingAPI.trackSingleItem(eventName, propertyDict)
|
138
|
+
```
|
139
|
+
|
140
|
+
This method takes 2 parameters:
|
141
|
+
|
142
|
+
- `eventName`: The unique name of the event. To differentiate different events that use the same name, you'll need to add an additional property.
|
143
|
+
- `propertyDict`: A dict with key-value pairs that represent important properties of the event. If there are none, this value can be empty.
|
144
|
+
|
145
|
+
#### Form submissions
|
146
|
+
|
147
|
+
Only add tracking to the form itself, not the button that opens the form. You should track both successful and failed form submissions, as well as cancelled forms
|
148
|
+
|
149
|
+
```nolive
|
150
|
+
trackingAPI.trackSingleItem(Event_Name, {
|
151
|
+
outcome: << submit , cancel >>,
|
152
|
+
success? : boolean,
|
153
|
+
error? : string,
|
154
|
+
<properties>, string/number/boolean } )
|
155
|
+
```
|
156
|
+
|
157
|
+
Parameters to pass with the `trackSingleItem` method can include:
|
158
|
+
|
159
|
+
- `outcome`: Communicates if the form was submitted or cancelled.
|
160
|
+
- `success`: Used for a "submit" outcome to communicate if the submission was successful for not in the backend.
|
161
|
+
- `error`: Used for a "submit" outcome to communicate the error message associated with a failed submission. Try to remove extraneous parts of the message, like part of a container-name.
|
162
|
+
- `properties`: Any additional properties from the form, to be tracked for analytics.
|
163
|
+
- Use your judgement to determine what will be useful for your analytics.
|
164
|
+
- Highly specific data, like names provided by the user or description text input, should not be tracked.
|
165
|
+
- Less personal data, like deployment replica count or memory server size, is more likely to help you understand your users.
|
166
|
+
|
167
|
+
## Examples
|
168
|
+
|
169
|
+
To better understand the analytics tracking process, here are 3 examples of what you could see in an analytics tool.
|
170
|
+
|
171
|
+
For all 3 tools, consider the following example, where the user has started a ChatBot and taken actions 1-5 in order:
|
172
|
+
|
173
|
+
<div class="ws-docs-content-img" style="width:60%">
|
174
|
+

|
175
|
+
</div>
|
176
|
+
|
177
|
+
1. Selected a model
|
178
|
+
2. Sent a question
|
179
|
+
3. Received a response from the model
|
180
|
+
4. Clicked the "thumbs up" button
|
181
|
+
5. Closed the ChatBot window
|
182
|
+
|
183
|
+
This pattern of actions will be applied to the following 3 analytics tools.
|
184
|
+
|
185
|
+
1. Segment
|
186
|
+
|
187
|
+
- [Segment](https://segment.com/) shows all user events in its source debugger:
|
188
|
+
|
189
|
+
<div class="ws-docs-content-img" style="width:70%">
|
190
|
+

|
191
|
+
</div>
|
192
|
+
|
193
|
+
- 1-5: User actions with the newest event at the top.
|
194
|
+
- 6-7: You can also see the results of `identify` (6) and `trackPageView` (7).
|
195
|
+
- If you clicked on an event, you would also see the properties.
|
196
|
+
|
197
|
+
- **Note**: When using the Segment provider, you may also want to set the `segmentCdn` and `segmentIntegrations` initialization properties.
|
198
|
+
|
199
|
+
1. Umami
|
200
|
+
|
201
|
+
- In [Umami](https://umami.is/), events are visible within **Website** / **Events**.
|
202
|
+
- The list is similar to Segment, with different formatting:
|
203
|
+
|
204
|
+
<div class="ws-docs-content-img">
|
205
|
+

|
206
|
+
</div>
|
207
|
+
|
208
|
+
- 1-5: User actions with the newest event at the top.
|
209
|
+
|
210
|
+
1. PostHog
|
211
|
+
|
212
|
+
- In [PostHog](https://posthog.com/), events are located in the **Activity** section.
|
213
|
+
- PostHog integrates deeper in the provided code, so there are more default events tracked:
|
214
|
+
|
215
|
+
<div class="ws-docs-content-img">
|
216
|
+

|
217
|
+
</div>
|
218
|
+
|
219
|
+
- 1-5: User actions with the newest event at the top.
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
2
2
|
import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
3
3
|
import patternflyAvatar from './patternfly_avatar.jpg';
|
4
4
|
import squareImg from './PF-social-color-square.svg';
|
5
|
-
import { Form, FormGroup, Radio } from '@patternfly/react-core';
|
5
|
+
import { AlertActionLink, Form, FormGroup, Radio } from '@patternfly/react-core';
|
6
6
|
|
7
7
|
export const BotMessageExample: React.FunctionComponent = () => {
|
8
8
|
const [variant, setVariant] = React.useState('code');
|
@@ -140,6 +140,21 @@ _Italic text, formatted with single underscores_
|
|
140
140
|
|
141
141
|
const image = ``;
|
142
142
|
|
143
|
+
const error = {
|
144
|
+
title: 'Could not load chat',
|
145
|
+
children: 'Wait a few minutes and check your network settings. If the issue persists: ',
|
146
|
+
actionLinks: (
|
147
|
+
<React.Fragment>
|
148
|
+
<AlertActionLink component="a" href="#">
|
149
|
+
Start a new chat
|
150
|
+
</AlertActionLink>
|
151
|
+
<AlertActionLink component="a" href="#">
|
152
|
+
Contact support
|
153
|
+
</AlertActionLink>
|
154
|
+
</React.Fragment>
|
155
|
+
)
|
156
|
+
};
|
157
|
+
|
143
158
|
return (
|
144
159
|
<>
|
145
160
|
<Message
|
@@ -258,6 +273,13 @@ _Italic text, formatted with single underscores_
|
|
258
273
|
label="Image"
|
259
274
|
id="image"
|
260
275
|
/>
|
276
|
+
<Radio
|
277
|
+
isChecked={variant === 'error'}
|
278
|
+
onChange={() => setVariant('error')}
|
279
|
+
name="bot-message-error"
|
280
|
+
label="Error"
|
281
|
+
id="error"
|
282
|
+
/>
|
261
283
|
</FormGroup>
|
262
284
|
</Form>
|
263
285
|
<Message
|
@@ -268,6 +290,7 @@ _Italic text, formatted with single underscores_
|
|
268
290
|
tableProps={
|
269
291
|
variant === 'table' ? { 'aria-label': 'App information and user roles for bot messages' } : undefined
|
270
292
|
}
|
293
|
+
error={variant === 'error' ? error : undefined}
|
271
294
|
/>
|
272
295
|
</>
|
273
296
|
);
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
2
2
|
|
3
3
|
import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
4
4
|
import userAvatar from './user_avatar.svg';
|
5
|
-
import { Form, FormGroup, Radio } from '@patternfly/react-core';
|
5
|
+
import { AlertActionLink, Form, FormGroup, Radio } from '@patternfly/react-core';
|
6
6
|
|
7
7
|
export const UserMessageExample: React.FunctionComponent = () => {
|
8
8
|
const [variant, setVariant] = React.useState('code');
|
@@ -140,6 +140,21 @@ _Italic text, formatted with single underscores_
|
|
140
140
|
|
141
141
|
const image = ``;
|
142
142
|
|
143
|
+
const error = {
|
144
|
+
title: 'Could not load chat',
|
145
|
+
children: 'Wait a few minutes and check your network settings. If the issue persists: ',
|
146
|
+
actionLinks: (
|
147
|
+
<React.Fragment>
|
148
|
+
<AlertActionLink component="a" href="#">
|
149
|
+
Start a new chat
|
150
|
+
</AlertActionLink>
|
151
|
+
<AlertActionLink component="a" href="#">
|
152
|
+
Contact support
|
153
|
+
</AlertActionLink>
|
154
|
+
</React.Fragment>
|
155
|
+
)
|
156
|
+
};
|
157
|
+
|
143
158
|
return (
|
144
159
|
<>
|
145
160
|
<Message
|
@@ -235,6 +250,13 @@ _Italic text, formatted with single underscores_
|
|
235
250
|
label="Image"
|
236
251
|
id="user-image"
|
237
252
|
/>
|
253
|
+
<Radio
|
254
|
+
isChecked={variant === 'error'}
|
255
|
+
onChange={() => setVariant('error')}
|
256
|
+
name="user-message-error"
|
257
|
+
label="Error"
|
258
|
+
id="user-error"
|
259
|
+
/>
|
238
260
|
</FormGroup>
|
239
261
|
</Form>
|
240
262
|
<Message
|
@@ -245,6 +267,7 @@ _Italic text, formatted with single underscores_
|
|
245
267
|
tableProps={
|
246
268
|
variant === 'table' ? { 'aria-label': 'App information and user roles for user messages' } : undefined
|
247
269
|
}
|
270
|
+
error={variant === 'error' ? error : undefined}
|
248
271
|
/>
|
249
272
|
</>
|
250
273
|
);
|
@@ -57,6 +57,8 @@ import PFIconLogoColor from '../UI/PF-IconLogo-Color.svg';
|
|
57
57
|
import PFIconLogoReverse from '../UI/PF-IconLogo-Reverse.svg';
|
58
58
|
import userAvatar from '../Messages/user_avatar.svg';
|
59
59
|
import patternflyAvatar from '../Messages/patternfly_avatar.jpg';
|
60
|
+
import { getTrackingProviders } from "@patternfly/chatbot/dist/dynamic/tracking";
|
61
|
+
|
60
62
|
|
61
63
|
### Basic ChatBot
|
62
64
|
|
@@ -106,6 +108,17 @@ This demo displays an embedded ChatBot. Embedded ChatBots are meant to be placed
|
|
106
108
|
|
107
109
|
```
|
108
110
|
|
111
|
+
### Inline drawer ChatBot
|
112
|
+
|
113
|
+
This demo displays a ChatBot in a static, inline drawer. This demo includes:
|
114
|
+
|
115
|
+
1. An empty [PatternFly page](/components/page) with a sidebar and masthead.
|
116
|
+
2. A [basic ChatBot](#basic-chatbot), placed beside the page content. It does not overlay the page content, cannot be minimized, and does not allow you to change the display mode by default.
|
117
|
+
|
118
|
+
```js file="./ChatbotInDrawer.tsx" isFullscreen
|
119
|
+
|
120
|
+
```
|
121
|
+
|
109
122
|
### Comparing ChatBots
|
110
123
|
|
111
124
|
To let users compare how different ChatBots respond to the same prompt, you can add multiple ChatBots within the same window. The following demo illustrates a comparison view pattern that allows users to toggle between different conversations in a single ChatBot window.
|
@@ -32,6 +32,8 @@ import PFIconLogoColor from '../UI/PF-IconLogo-Color.svg';
|
|
32
32
|
import PFIconLogoReverse from '../UI/PF-IconLogo-Reverse.svg';
|
33
33
|
import userAvatar from '../Messages/user_avatar.svg';
|
34
34
|
import patternflyAvatar from '../Messages/patternfly_avatar.jpg';
|
35
|
+
import { getTrackingProviders } from '@patternfly/chatbot/dist/dynamic/tracking';
|
36
|
+
import { InitProps } from '@patternfly/chatbot/dist/dynamic/tracking';
|
35
37
|
|
36
38
|
const footnoteProps = {
|
37
39
|
label: 'ChatBot uses AI. Check for mistakes.',
|
@@ -95,6 +97,20 @@ export default MessageLoading;
|
|
95
97
|
// The timestamps re-render with them.
|
96
98
|
const date = new Date();
|
97
99
|
|
100
|
+
const initProps: InitProps = {
|
101
|
+
segmentKey: 'TODO-key', // TODO add your key here
|
102
|
+
posthogKey: 'TODO-key',
|
103
|
+
umamiKey: 'TODO-key',
|
104
|
+
umamiHostUrl: 'http://localhost:3000', // TODO where is your JS provider?
|
105
|
+
console: true,
|
106
|
+
something: 'test'
|
107
|
+
};
|
108
|
+
|
109
|
+
const tracking = getTrackingProviders(initProps);
|
110
|
+
tracking.identify('user-123'); // TODO get real user id
|
111
|
+
tracking.trackPageView(window.document.documentURI);
|
112
|
+
|
113
|
+
const actionEventName = 'MessageAction';
|
98
114
|
const initialMessages: MessageProps[] = [
|
99
115
|
{
|
100
116
|
id: '1',
|
@@ -113,16 +129,11 @@ const initialMessages: MessageProps[] = [
|
|
113
129
|
avatar: patternflyAvatar,
|
114
130
|
timestamp: date.toLocaleString(),
|
115
131
|
actions: {
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
copy: { onClick: () => console.log('Copy') },
|
122
|
-
// eslint-disable-next-line no-console
|
123
|
-
share: { onClick: () => console.log('Share') },
|
124
|
-
// eslint-disable-next-line no-console
|
125
|
-
listen: { onClick: () => console.log('Listen') }
|
132
|
+
positive: { onClick: () => tracking.trackSingleItem(actionEventName, { response: 'Good response' }) },
|
133
|
+
negative: { onClick: () => tracking.trackSingleItem(actionEventName, { response: 'Bad response' }) },
|
134
|
+
copy: { onClick: () => tracking.trackSingleItem(actionEventName, { response: 'Copy' }) },
|
135
|
+
share: { onClick: () => tracking.trackSingleItem(actionEventName, { response: 'Share' }) },
|
136
|
+
listen: { onClick: () => tracking.trackSingleItem(actionEventName, { response: 'Listen' }) }
|
126
137
|
}
|
127
138
|
}
|
128
139
|
];
|
@@ -164,6 +175,7 @@ const initialConversations = {
|
|
164
175
|
]
|
165
176
|
};
|
166
177
|
|
178
|
+
const actionEvent2 = 'ActionEvent2';
|
167
179
|
export const ChatbotDemo: React.FunctionComponent = () => {
|
168
180
|
const [chatbotVisible, setChatbotVisible] = React.useState<boolean>(true);
|
169
181
|
const [displayMode, setDisplayMode] = React.useState<ChatbotDisplayMode>(ChatbotDisplayMode.default);
|
@@ -180,7 +192,7 @@ export const ChatbotDemo: React.FunctionComponent = () => {
|
|
180
192
|
const chatbotRef = React.useRef<HTMLDivElement>(null);
|
181
193
|
const historyRef = React.useRef<HTMLButtonElement>(null);
|
182
194
|
|
183
|
-
//
|
195
|
+
// Auto-scrolls to the latest message
|
184
196
|
React.useEffect(() => {
|
185
197
|
// don't scroll the first load - in this demo, we know we start with two messages
|
186
198
|
if (messages.length > 2) {
|
@@ -193,6 +205,7 @@ export const ChatbotDemo: React.FunctionComponent = () => {
|
|
193
205
|
value: string | number | undefined
|
194
206
|
) => {
|
195
207
|
setSelectedModel(value as string);
|
208
|
+
tracking.trackSingleItem('ModelSelected', { model: value });
|
196
209
|
};
|
197
210
|
|
198
211
|
const onSelectDisplayMode = (
|
@@ -210,6 +223,7 @@ export const ChatbotDemo: React.FunctionComponent = () => {
|
|
210
223
|
|
211
224
|
const handleSend = (message: string) => {
|
212
225
|
setIsSendButtonDisabled(true);
|
226
|
+
tracking.trackSingleItem('UserInputReceived', { text: message });
|
213
227
|
const newMessages: MessageProps[] = [];
|
214
228
|
// We can't use structuredClone since messages contains functions, but we can't mutate
|
215
229
|
// items that are going into state or the UI won't update correctly
|
@@ -255,21 +269,17 @@ export const ChatbotDemo: React.FunctionComponent = () => {
|
|
255
269
|
avatar: patternflyAvatar,
|
256
270
|
timestamp: date.toLocaleString(),
|
257
271
|
actions: {
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
copy: { onClick: () => console.log('Copy') },
|
264
|
-
// eslint-disable-next-line no-console
|
265
|
-
share: { onClick: () => console.log('Share') },
|
266
|
-
// eslint-disable-next-line no-console
|
267
|
-
listen: { onClick: () => console.log('Listen') }
|
272
|
+
positive: { onClick: () => tracking.trackSingleItem(actionEvent2, { response: 'Good response' }) },
|
273
|
+
negative: { onClick: () => tracking.trackSingleItem(actionEvent2, { response: 'Bad response' }) },
|
274
|
+
copy: { onClick: () => tracking.trackSingleItem(actionEvent2, { response: 'Copy' }) },
|
275
|
+
share: { onClick: () => tracking.trackSingleItem(actionEvent2, { response: 'Share' }) },
|
276
|
+
listen: { onClick: () => tracking.trackSingleItem(actionEvent2, { response: 'Listen' }) }
|
268
277
|
}
|
269
278
|
});
|
270
279
|
setMessages(loadedMessages);
|
271
280
|
// make announcement to assistive devices that new message has loaded
|
272
281
|
setAnnouncement(`Message from Bot: API response goes here`);
|
282
|
+
tracking.trackSingleItem('BotResponded', { undefined });
|
273
283
|
setIsSendButtonDisabled(false);
|
274
284
|
}, 5000);
|
275
285
|
};
|
@@ -339,7 +349,10 @@ export const ChatbotDemo: React.FunctionComponent = () => {
|
|
339
349
|
<ChatbotToggle
|
340
350
|
tooltipLabel="Chatbot"
|
341
351
|
isChatbotVisible={chatbotVisible}
|
342
|
-
onToggleChatbot={()
|
352
|
+
onToggleChatbot={function () {
|
353
|
+
setChatbotVisible(!chatbotVisible);
|
354
|
+
tracking.trackSingleItem('Chatbot Visible', { isVisible: !chatbotVisible }); // TODO correct?
|
355
|
+
}}
|
343
356
|
id="chatbot-toggle"
|
344
357
|
ref={toggleRef}
|
345
358
|
/>
|
@@ -441,9 +454,9 @@ export const ChatbotDemo: React.FunctionComponent = () => {
|
|
441
454
|
prompts={welcomePrompts}
|
442
455
|
/>
|
443
456
|
{/* This code block enables scrolling to the top of the last message.
|
444
|
-
You can instead choose to move the div with scrollToBottomRef on it below
|
457
|
+
You can instead choose to move the div with scrollToBottomRef on it below
|
445
458
|
the map of messages, so that users are forced to scroll to the bottom.
|
446
|
-
If you are using streaming, you will want to take a different approach;
|
459
|
+
If you are using streaming, you will want to take a different approach;
|
447
460
|
see: https://github.com/patternfly/chatbot/issues/201#issuecomment-2400725173 */}
|
448
461
|
{messages.map((message, index) => {
|
449
462
|
if (index === messages.length - 1) {
|