react-native-chatbot-ai 0.1.63 → 0.1.65
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/chat/ChatEmpty.js +7 -1
- package/lib/module/components/chat/ChatEmpty.js.map +1 -1
- package/lib/module/components/chat/ChatHeader.js +4 -1
- package/lib/module/components/chat/ChatHeader.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/product/Card.js +28 -1
- package/lib/module/components/product/Card.js.map +1 -1
- package/lib/module/components/product/CardHorizontal.js +28 -1
- 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/chat/ChatEmpty.d.ts.map +1 -1
- package/lib/typescript/src/components/chat/ChatHeader.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/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/chat/ChatEmpty.tsx +16 -1
- package/src/components/chat/ChatHeader.tsx +8 -1
- package/src/components/chat/footer/SuggestionsBar.tsx +24 -0
- package/src/components/chat/index.tsx +10 -0
- package/src/components/product/Card.tsx +47 -1
- package/src/components/product/CardHorizontal.tsx +41 -1
- 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,7 +13,7 @@ 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';
|
|
@@ -217,6 +217,19 @@ const ProductHorizontalCard = memo(
|
|
|
217
217
|
tab_name: getRouteKey(tabIndex),
|
|
218
218
|
type: 'horizontal',
|
|
219
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
|
+
);
|
|
220
233
|
}, [onNavigateToProduct, logGA, item, index, messageId, tabIndex]);
|
|
221
234
|
|
|
222
235
|
const onPressAddToCart = useCallback(() => {
|
|
@@ -231,6 +244,20 @@ const ProductHorizontalCard = memo(
|
|
|
231
244
|
tab_name: getRouteKey(tabIndex),
|
|
232
245
|
type: 'horizontal',
|
|
233
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
|
+
);
|
|
234
261
|
}, [onAddToCart, logGA, item, messageId, index, tabIndex]);
|
|
235
262
|
|
|
236
263
|
const onPressBuyNow = useCallback(() => {
|
|
@@ -245,6 +272,19 @@ const ProductHorizontalCard = memo(
|
|
|
245
272
|
tab_name: getRouteKey(tabIndex),
|
|
246
273
|
type: 'horizontal',
|
|
247
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
|
+
);
|
|
248
288
|
}, [onBuyNow, logGA, item, messageId, tabIndex]);
|
|
249
289
|
|
|
250
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;
|