vdb-ai-chat 1.0.19 → 1.0.20

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.
@@ -13,10 +13,12 @@ import {
13
13
  getUserCurrencySymbol,
14
14
  formatPriceValue,
15
15
  roundUpPrices,
16
+ AnalyticsEventNames,
16
17
  } from "./utils";
17
18
  import { useTheme } from "styled-components/native";
18
19
  import { DefaultTheme } from "styled-components/native";
19
20
  import styled from "styled-components/native";
21
+ import { useUserAnalytics } from "../hooks/useAnalytics";
20
22
 
21
23
  let ImageComponent: typeof Image = Image;
22
24
  if (Platform.OS !== "web") {
@@ -291,6 +293,7 @@ const ProductsListViewComponent: React.FC<ProductsListViewProps> = ({
291
293
  const theme = useTheme();
292
294
  const [userCurrency, setUserCurrency] = useState<string | null>(null);
293
295
  const [shouldRound, setShouldRound] = useState<boolean>(false);
296
+ const { trackEvent } = useUserAnalytics();
294
297
  const isTablet = theme.isTablet;
295
298
  const DIAMOND_TOKENS = isTablet
296
299
  ? DIAMOND_TOKENS_TABLET
@@ -309,6 +312,16 @@ const ProductsListViewComponent: React.FC<ProductsListViewProps> = ({
309
312
  getRoundOffPrices();
310
313
  }, []);
311
314
 
315
+ const handleItemPress = (dataItem: any) => {
316
+ onItemPress?.(dataItem);
317
+ trackEvent?.(AnalyticsEventNames.PRODUCT_PREVIEW_CLICKED, {});
318
+ };
319
+
320
+ const handleViewAllPress = (item: any) => {
321
+ onViewAll?.(item);
322
+ trackEvent?.(AnalyticsEventNames.SHOW_ALL_RESULTS_CLICKED, {});
323
+ };
324
+
312
325
  return (
313
326
  <Wrapper theme={theme}>
314
327
  <ScrollView
@@ -316,7 +329,7 @@ const ProductsListViewComponent: React.FC<ProductsListViewProps> = ({
316
329
  contentContainerStyle={styles.listContent}
317
330
  >
318
331
  {data.map((dataItem: any, index: number) => (
319
- <Pressable key={dataItem.id} onPress={() => onItemPress?.(dataItem)}>
332
+ <Pressable key={dataItem.id} onPress={() => handleItemPress(dataItem)}>
320
333
  {(state) => (
321
334
  // @ts-ignore
322
335
  <ListItemParent theme={theme} hovered={state.hovered}>
@@ -342,7 +355,7 @@ const ProductsListViewComponent: React.FC<ProductsListViewProps> = ({
342
355
  ))}
343
356
  </ScrollView>
344
357
 
345
- <ButtonView activeOpacity={0.8} onPress={() => onViewAll(item)}>
358
+ <ButtonView activeOpacity={0.8} onPress={() => handleViewAllPress(item)}>
346
359
  <ButtonText>{`View All ${totalResults} diamonds`}</ButtonText>
347
360
  <ImageComponent
348
361
  source={{
@@ -166,6 +166,8 @@ export enum AnalyticsEventNames {
166
166
  WIDGET_OPENED = "ai_chat_widget_opened",
167
167
  WIDGET_CLOSED = "ai_chat_widget_closed",
168
168
  CHAT_CLEARED = "ai_chat_cleared",
169
+ PRODUCT_PREVIEW_CLICKED = "ai_product_preview_clicked",
170
+ SHOW_ALL_RESULTS_CLICKED = "ai_show_all_results_clicked",
169
171
  }
170
172
 
171
173
  export const isIpad = () => {