react-native-chatbot-ai 0.1.62 → 0.1.64
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/lib/module/components/Drawer/DrawerContent.js +4 -1
- package/lib/module/components/Drawer/DrawerContent.js.map +1 -1
- package/lib/module/components/PaginatedList/PaginatedFlatList.js +132 -0
- package/lib/module/components/PaginatedList/PaginatedFlatList.js.map +1 -0
- package/lib/module/components/PaginatedList/index.js +4 -0
- package/lib/module/components/PaginatedList/index.js.map +1 -0
- package/lib/module/components/chat/ChatEmpty.js +10 -2
- package/lib/module/components/chat/ChatEmpty.js.map +1 -1
- package/lib/module/components/chat/ChatMessageList.js +10 -9
- package/lib/module/components/chat/ChatMessageList.js.map +1 -1
- package/lib/module/components/chat/footer/SuggestionsBar.js +14 -1
- package/lib/module/components/chat/footer/SuggestionsBar.js.map +1 -1
- package/lib/module/components/chat/index.js +6 -0
- package/lib/module/components/chat/index.js.map +1 -1
- package/lib/module/components/chat/item/ChatAIAnswerMessageItem.js +3 -1
- package/lib/module/components/chat/item/ChatAIAnswerMessageItem.js.map +1 -1
- package/lib/module/components/product/Card.js +28 -1
- package/lib/module/components/product/Card.js.map +1 -1
- package/lib/module/components/product/CardHorizontal.js +73 -3
- package/lib/module/components/product/CardHorizontal.js.map +1 -1
- package/lib/module/hooks/message/useSendMessage.js +6 -1
- package/lib/module/hooks/message/useSendMessage.js.map +1 -1
- package/lib/module/hooks/message/useStreamMessage.js +11 -1
- package/lib/module/hooks/message/useStreamMessage.js.map +1 -1
- package/lib/module/hooks/messageActions/useFeedback.js +7 -0
- package/lib/module/hooks/messageActions/useFeedback.js.map +1 -1
- package/lib/module/types/chat.js +5 -0
- package/lib/module/types/chat.js.map +1 -1
- package/lib/typescript/src/components/Drawer/DrawerContent.d.ts.map +1 -1
- package/lib/typescript/src/components/PaginatedList/PaginatedFlatList.d.ts +12 -0
- package/lib/typescript/src/components/PaginatedList/PaginatedFlatList.d.ts.map +1 -0
- package/lib/typescript/src/components/PaginatedList/index.d.ts +2 -0
- package/lib/typescript/src/components/PaginatedList/index.d.ts.map +1 -0
- package/lib/typescript/src/components/chat/ChatEmpty.d.ts +5 -2
- package/lib/typescript/src/components/chat/ChatEmpty.d.ts.map +1 -1
- package/lib/typescript/src/components/chat/ChatMessageList.d.ts.map +1 -1
- package/lib/typescript/src/components/chat/footer/SuggestionsBar.d.ts.map +1 -1
- package/lib/typescript/src/components/chat/index.d.ts.map +1 -1
- package/lib/typescript/src/components/chat/item/ChatAIAnswerMessageItem.d.ts.map +1 -1
- package/lib/typescript/src/components/product/Card.d.ts.map +1 -1
- package/lib/typescript/src/components/product/CardHorizontal.d.ts.map +1 -1
- package/lib/typescript/src/hooks/message/useSendMessage.d.ts.map +1 -1
- package/lib/typescript/src/hooks/message/useStreamMessage.d.ts.map +1 -1
- package/lib/typescript/src/hooks/messageActions/useFeedback.d.ts.map +1 -1
- package/lib/typescript/src/types/chat.d.ts +6 -1
- package/lib/typescript/src/types/chat.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Drawer/DrawerContent.tsx +8 -1
- package/src/components/PaginatedList/PaginatedFlatList.tsx +149 -0
- package/src/components/PaginatedList/index.tsx +1 -0
- package/src/components/chat/ChatEmpty.tsx +20 -2
- package/src/components/chat/ChatMessageList.tsx +8 -14
- package/src/components/chat/footer/SuggestionsBar.tsx +24 -0
- package/src/components/chat/index.tsx +10 -0
- package/src/components/chat/item/ChatAIAnswerMessageItem.tsx +3 -1
- package/src/components/product/Card.tsx +47 -1
- package/src/components/product/CardHorizontal.tsx +91 -4
- package/src/hooks/message/useSendMessage.ts +12 -0
- package/src/hooks/message/useStreamMessage.ts +20 -0
- package/src/hooks/messageActions/useFeedback.ts +12 -0
- package/src/types/chat.ts +11 -1
|
@@ -13,13 +13,14 @@ import {
|
|
|
13
13
|
import { PTManager } from '../../utils/prototype';
|
|
14
14
|
import { memo, useCallback, useMemo } from 'react';
|
|
15
15
|
import { StyleSheet } from 'react-native';
|
|
16
|
-
import { IProductItem, PRODUCT_STATUSES } from '../../types';
|
|
16
|
+
import { EventProvider, IProductItem, PRODUCT_STATUSES } from '../../types';
|
|
17
17
|
import { useChatContext } from '../../context/ChatContext';
|
|
18
18
|
// import SkeletonPlaceholder from 'react-native-skeleton-placeholder';
|
|
19
19
|
import { GAEvents } from '../../constants/events';
|
|
20
20
|
import useSessionStore from '../../store/session';
|
|
21
21
|
import { getRouteKey } from '../../constants';
|
|
22
22
|
import { useSearchProduct } from '../../hooks/product/useSearchProduct';
|
|
23
|
+
import SkeletonPlaceholder from 'react-native-skeleton-placeholder';
|
|
23
24
|
|
|
24
25
|
interface IProductHorizontalCardProps {
|
|
25
26
|
productId?: string;
|
|
@@ -31,15 +32,61 @@ interface IProductHorizontalCardProps {
|
|
|
31
32
|
const ProductHorizontalCardWrapper = memo(
|
|
32
33
|
(props: IProductHorizontalCardProps) => {
|
|
33
34
|
const { productId } = props;
|
|
34
|
-
const {
|
|
35
|
+
const {
|
|
36
|
+
data: product,
|
|
37
|
+
isLoading,
|
|
38
|
+
error,
|
|
39
|
+
} = useSearchProduct({
|
|
35
40
|
productIds: productId ? [productId] : [],
|
|
36
41
|
});
|
|
37
42
|
const item = product?.[0];
|
|
38
43
|
|
|
39
|
-
if (!item) {
|
|
44
|
+
if (error || (!isLoading && !item)) {
|
|
40
45
|
return null;
|
|
41
46
|
}
|
|
42
47
|
|
|
48
|
+
if (isLoading) {
|
|
49
|
+
return (
|
|
50
|
+
<KContainer.View style={styles.container}>
|
|
51
|
+
<SkeletonPlaceholder borderRadius={4} speed={2000} direction="right">
|
|
52
|
+
<SkeletonPlaceholder.Item flexDirection="row" gap={12}>
|
|
53
|
+
<SkeletonPlaceholder.Item
|
|
54
|
+
width={72}
|
|
55
|
+
height={72}
|
|
56
|
+
borderRadius={12}
|
|
57
|
+
/>
|
|
58
|
+
<SkeletonPlaceholder.Item
|
|
59
|
+
gap={12}
|
|
60
|
+
width={KDims.width - 160}
|
|
61
|
+
justifyContent="space-between"
|
|
62
|
+
>
|
|
63
|
+
<SkeletonPlaceholder.Item
|
|
64
|
+
height={16}
|
|
65
|
+
width={KDims.width / 2}
|
|
66
|
+
borderRadius={4}
|
|
67
|
+
/>
|
|
68
|
+
<SkeletonPlaceholder.Item
|
|
69
|
+
height={16}
|
|
70
|
+
width={160}
|
|
71
|
+
borderRadius={4}
|
|
72
|
+
/>
|
|
73
|
+
<SkeletonPlaceholder.Item
|
|
74
|
+
height={16}
|
|
75
|
+
width={80}
|
|
76
|
+
borderRadius={4}
|
|
77
|
+
/>
|
|
78
|
+
<SkeletonPlaceholder.Item
|
|
79
|
+
height={16}
|
|
80
|
+
width={80}
|
|
81
|
+
borderRadius={4}
|
|
82
|
+
/>
|
|
83
|
+
</SkeletonPlaceholder.Item>
|
|
84
|
+
</SkeletonPlaceholder.Item>
|
|
85
|
+
</SkeletonPlaceholder>
|
|
86
|
+
</KContainer.View>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
43
90
|
return <ProductHorizontalCard item={item} {...props} />;
|
|
44
91
|
}
|
|
45
92
|
);
|
|
@@ -51,7 +98,7 @@ const ProductHorizontalCard = memo(
|
|
|
51
98
|
messageId,
|
|
52
99
|
index,
|
|
53
100
|
showFavorite = false,
|
|
54
|
-
}: IProductHorizontalCardProps & { item
|
|
101
|
+
}: IProductHorizontalCardProps & { item?: IProductItem }) => {
|
|
55
102
|
const onAddToCart = useChatContext()?.onAddToCart;
|
|
56
103
|
const onBuyNow = useChatContext()?.onBuyNow;
|
|
57
104
|
const onNavigateToProduct = useChatContext()?.onNavigateToProduct;
|
|
@@ -170,6 +217,19 @@ const ProductHorizontalCard = memo(
|
|
|
170
217
|
tab_name: getRouteKey(tabIndex),
|
|
171
218
|
type: 'horizontal',
|
|
172
219
|
});
|
|
220
|
+
|
|
221
|
+
logGA(
|
|
222
|
+
GAEvents.chatDetailProductCardTap,
|
|
223
|
+
{
|
|
224
|
+
conversation_id: useSessionStore.getState().sessionId,
|
|
225
|
+
message_chat_id: messageId,
|
|
226
|
+
product_id: item.id,
|
|
227
|
+
position_in_list: index,
|
|
228
|
+
tab_name: getRouteKey(tabIndex),
|
|
229
|
+
type: 'horizontal',
|
|
230
|
+
},
|
|
231
|
+
EventProvider.netcore
|
|
232
|
+
);
|
|
173
233
|
}, [onNavigateToProduct, logGA, item, index, messageId, tabIndex]);
|
|
174
234
|
|
|
175
235
|
const onPressAddToCart = useCallback(() => {
|
|
@@ -184,6 +244,20 @@ const ProductHorizontalCard = memo(
|
|
|
184
244
|
tab_name: getRouteKey(tabIndex),
|
|
185
245
|
type: 'horizontal',
|
|
186
246
|
});
|
|
247
|
+
|
|
248
|
+
logGA(
|
|
249
|
+
GAEvents.chatDetailAddToCartBtnTap,
|
|
250
|
+
{
|
|
251
|
+
conversation_id: useSessionStore.getState().sessionId,
|
|
252
|
+
product_id: item.id,
|
|
253
|
+
position_in_list: index,
|
|
254
|
+
pdp_id: item.pdpId,
|
|
255
|
+
message_chat_id: messageId,
|
|
256
|
+
tab_name: getRouteKey(tabIndex),
|
|
257
|
+
type: 'horizontal',
|
|
258
|
+
},
|
|
259
|
+
EventProvider.netcore
|
|
260
|
+
);
|
|
187
261
|
}, [onAddToCart, logGA, item, messageId, index, tabIndex]);
|
|
188
262
|
|
|
189
263
|
const onPressBuyNow = useCallback(() => {
|
|
@@ -198,6 +272,19 @@ const ProductHorizontalCard = memo(
|
|
|
198
272
|
tab_name: getRouteKey(tabIndex),
|
|
199
273
|
type: 'horizontal',
|
|
200
274
|
});
|
|
275
|
+
logGA(
|
|
276
|
+
GAEvents.chatDetailBuyNowBtnTap,
|
|
277
|
+
{
|
|
278
|
+
conversation_id: useSessionStore.getState().sessionId,
|
|
279
|
+
product_id: item.id,
|
|
280
|
+
position_in_list: -1, //TODO: fix
|
|
281
|
+
pdp_id: item.pdpId,
|
|
282
|
+
message_chat_id: messageId,
|
|
283
|
+
tab_name: getRouteKey(tabIndex),
|
|
284
|
+
type: 'horizontal',
|
|
285
|
+
},
|
|
286
|
+
EventProvider.netcore
|
|
287
|
+
);
|
|
201
288
|
}, [onBuyNow, logGA, item, messageId, tabIndex]);
|
|
202
289
|
|
|
203
290
|
return (
|
|
@@ -6,6 +6,7 @@ import { useStreamMessage } from './useStreamMessage';
|
|
|
6
6
|
import { events, GAEvents } from '../../constants/events';
|
|
7
7
|
import { DeviceEventEmitter } from 'react-native';
|
|
8
8
|
import {
|
|
9
|
+
EventProvider,
|
|
9
10
|
IAttachment,
|
|
10
11
|
IMessageItem,
|
|
11
12
|
MessageType,
|
|
@@ -80,6 +81,17 @@ export const useSendMessage = () => {
|
|
|
80
81
|
action_type: actionType,
|
|
81
82
|
});
|
|
82
83
|
|
|
84
|
+
logGA(
|
|
85
|
+
GAEvents.chatDetailSendBtnTap,
|
|
86
|
+
{
|
|
87
|
+
chat_type: useSessionStore.getState().sessionLogType,
|
|
88
|
+
conversation_id:
|
|
89
|
+
latestSessionId || useSessionStore.getState().sessionId,
|
|
90
|
+
action_type: actionType,
|
|
91
|
+
},
|
|
92
|
+
EventProvider.netcore
|
|
93
|
+
);
|
|
94
|
+
|
|
83
95
|
if (attachments?.length && attachments.length > 0) {
|
|
84
96
|
const totalFileCount = attachments.filter(
|
|
85
97
|
(i) => i.type === 'file'
|
|
@@ -2,6 +2,7 @@ import { useEffect, useRef, useCallback } from 'react';
|
|
|
2
2
|
import { useChatContext } from '../../context/ChatContext';
|
|
3
3
|
import { ENDPOINTS } from '../../services/endpoints';
|
|
4
4
|
import {
|
|
5
|
+
EventProvider,
|
|
5
6
|
SendActionLogType,
|
|
6
7
|
type IMessageItem,
|
|
7
8
|
type StreamMessageRequest,
|
|
@@ -108,6 +109,16 @@ export const useStreamMessage = () => {
|
|
|
108
109
|
message_chat_id: m?.id,
|
|
109
110
|
group_id: m?.group_suggestion_id,
|
|
110
111
|
});
|
|
112
|
+
|
|
113
|
+
logGA?.(
|
|
114
|
+
GAEvents.chatDetailInConvPrmSuggReturn,
|
|
115
|
+
{
|
|
116
|
+
conversation_id: sessionId,
|
|
117
|
+
message_chat_id: m?.id,
|
|
118
|
+
group_id: m?.group_suggestion_id,
|
|
119
|
+
},
|
|
120
|
+
EventProvider.netcore
|
|
121
|
+
);
|
|
111
122
|
}
|
|
112
123
|
});
|
|
113
124
|
}
|
|
@@ -203,6 +214,15 @@ export const useStreamMessage = () => {
|
|
|
203
214
|
conversation_id: sessionId,
|
|
204
215
|
action_type: SendActionLogType.retry,
|
|
205
216
|
});
|
|
217
|
+
logGA(
|
|
218
|
+
GAEvents.chatDetailSendBtnTap,
|
|
219
|
+
{
|
|
220
|
+
chat_type: useSessionStore.getState().sessionLogType,
|
|
221
|
+
conversation_id: sessionId,
|
|
222
|
+
action_type: SendActionLogType.retry,
|
|
223
|
+
},
|
|
224
|
+
EventProvider.netcore
|
|
225
|
+
);
|
|
206
226
|
|
|
207
227
|
startStream(
|
|
208
228
|
{
|
|
@@ -12,6 +12,7 @@ import type { IMessageItem } from '../../types/dto';
|
|
|
12
12
|
import useSessionStore from '../../store/session';
|
|
13
13
|
import { useChatContext } from '../../context/ChatContext';
|
|
14
14
|
import { GAEvents } from '../../constants/events';
|
|
15
|
+
import { EventProvider } from '../../types';
|
|
15
16
|
|
|
16
17
|
export const useFeedback = (messageId: string, message?: IMessageItem) => {
|
|
17
18
|
const { logGA, notifyError } = useChatContext();
|
|
@@ -96,6 +97,17 @@ export const useFeedback = (messageId: string, message?: IMessageItem) => {
|
|
|
96
97
|
message_chat_id: messageId,
|
|
97
98
|
});
|
|
98
99
|
|
|
100
|
+
logGA(
|
|
101
|
+
GAEvents.chatDetailLikeDislikeBtnTap,
|
|
102
|
+
{
|
|
103
|
+
fb_type: type,
|
|
104
|
+
message_chat_id: messageId,
|
|
105
|
+
},
|
|
106
|
+
EventProvider.netcore
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
// Updat
|
|
110
|
+
|
|
99
111
|
// Update local state AFTER successful API call
|
|
100
112
|
setFeedback(messageId, type, reason);
|
|
101
113
|
|
package/src/types/chat.ts
CHANGED
|
@@ -2,6 +2,12 @@ import { JSX } from 'react';
|
|
|
2
2
|
import { IMessageItem } from './dto';
|
|
3
3
|
import EventSource from 'react-native-sse';
|
|
4
4
|
|
|
5
|
+
export const EventProvider = {
|
|
6
|
+
ga: 'ga',
|
|
7
|
+
appsflyer: 'appsflyer',
|
|
8
|
+
netcore: 'netcore',
|
|
9
|
+
} as const;
|
|
10
|
+
|
|
5
11
|
export interface ChatContextType {
|
|
6
12
|
apiAddress: string;
|
|
7
13
|
userId: string;
|
|
@@ -15,7 +21,11 @@ export interface ChatContextType {
|
|
|
15
21
|
openDrawer: () => void;
|
|
16
22
|
closeDrawer: () => void;
|
|
17
23
|
chatbotUrl: string;
|
|
18
|
-
logGA: (
|
|
24
|
+
logGA: (
|
|
25
|
+
event: string,
|
|
26
|
+
params?: any,
|
|
27
|
+
provider?: `${keyof typeof EventProvider}`
|
|
28
|
+
) => void;
|
|
19
29
|
notifyError?: ErrorLogger;
|
|
20
30
|
tabIndex: number;
|
|
21
31
|
setTabIndex: (tabIndex: number) => void;
|