From 82910b7d8ff1d06507f3b873e4217208defec188 Mon Sep 17 00:00:00 2001
From: Stefano Cerelli <stefano.cerelli@holi.team>
Date: Wed, 2 Apr 2025 17:32:01 +0000
Subject: [PATCH] fix: add missing tracking

---
 core/components/RecoSlider.tsx                     |  1 +
 core/layout/DetailsScreen/index.tsx                |  8 ++------
 core/tracking/events.ts                            | 14 ++++++++++++--
 .../useEventDetailsData/useEventDetailsData.ts     |  5 ++++-
 holi-apps/events/screens/EventDetails.tsx          |  4 ++++
 5 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/core/components/RecoSlider.tsx b/core/components/RecoSlider.tsx
index 528503eeeb..1cfb8ab0b9 100644
--- a/core/components/RecoSlider.tsx
+++ b/core/components/RecoSlider.tsx
@@ -64,6 +64,7 @@ const RecoSlider: React.FC<RecoSliderProps> = ({
 
   const handleHeaderTitlePress = () => {
     if (seeAllPath) {
+      if (seeMoreTrackingEvent) track(seeMoreTrackingEvent)
       navigate(seeAllPath)
     }
   }
diff --git a/core/layout/DetailsScreen/index.tsx b/core/layout/DetailsScreen/index.tsx
index b003123c71..00b7c46c0d 100644
--- a/core/layout/DetailsScreen/index.tsx
+++ b/core/layout/DetailsScreen/index.tsx
@@ -18,8 +18,6 @@ import { AuthorBanner, type AuthorBannerProps } from 'holi-bricks/patterns/autho
 import { Spacing } from 'holi-bricks/tokens'
 import { DetailsScreenSkeleton } from '@holi/core/layout/DetailsScreen/skeleton'
 import { HtmlRenderer } from 'holi-bricks/components/html-renderer'
-import { TextLinkTracked } from '@holi/core/components/Trackable'
-import { TrackingEvent } from '@holi/core/tracking'
 import type { ImageSource } from 'holi-bricks/components/image'
 import { Avatar } from 'holi-bricks/components/avatar'
 
@@ -162,7 +160,7 @@ export const DetailsScreen = ({
 
             <Stack direction="column" gap="xxs" shouldRender={!!infoList}>
               {infoList?.map((detail, index) => {
-                const TextComp = detail.onPress ? TextLinkTracked : Text
+                const TextComp = detail.onPress ? TextLink : Text
                 return (
                   <Stack
                     alignItems="flex-start"
@@ -174,9 +172,7 @@ export const DetailsScreen = ({
                   >
                     <HoliIcon size={Spacing.md} icon={detail?.icon} />
                     <Stack flex={1}>
-                      <TextComp size="md" trackingEvent={TrackingEvent.EventDetails.videoCall}>
-                        {detail?.title}
-                      </TextComp>
+                      <TextComp size="md">{detail?.title}</TextComp>
                       {detail?.subtitle && (
                         <Text color="support" size="sm">
                           {detail?.subtitle}
diff --git a/core/tracking/events.ts b/core/tracking/events.ts
index 3f9ee3c5f4..d0cd7d2934 100644
--- a/core/tracking/events.ts
+++ b/core/tracking/events.ts
@@ -132,14 +132,24 @@ export namespace TrackingEvent {
       },
       ...versionOne,
     }),
+    viewed: (eventId: string) => ({
+      name: 'event_details_viewed',
+      properties: {
+        eventId,
+      },
+      ...versionOne,
+    }),
     findMore: {
       name: 'events_findMore_pressed',
       ...versionOne,
     },
-    videoCall: {
+    videoCall: (eventId: string) => ({
       name: 'events_videoCallLink_pressed',
+      properties: {
+        eventId,
+      },
       ...versionOne,
-    },
+    }),
   }
 
   export const Events = {
diff --git a/holi-apps/events/helpers/useEventDetailsData/useEventDetailsData.ts b/holi-apps/events/helpers/useEventDetailsData/useEventDetailsData.ts
index 0008b0d0a5..c384151c38 100644
--- a/holi-apps/events/helpers/useEventDetailsData/useEventDetailsData.ts
+++ b/holi-apps/events/helpers/useEventDetailsData/useEventDetailsData.ts
@@ -84,7 +84,10 @@ export const useEventDetailsData = (eventId?: string): UseEventDetailsData => {
       title: remoteLink,
       icon: VideoChat,
       showExternalIcon: true,
-      onPress: () => Linking.openURL(remoteLink),
+      onPress: () => {
+        track(TrackingEvent.EventDetails.videoCall(event?.id as string))
+        Linking.openURL(remoteLink)
+      },
     })
   }
 
diff --git a/holi-apps/events/screens/EventDetails.tsx b/holi-apps/events/screens/EventDetails.tsx
index 4027b6a84d..67fd506eed 100644
--- a/holi-apps/events/screens/EventDetails.tsx
+++ b/holi-apps/events/screens/EventDetails.tsx
@@ -13,6 +13,7 @@ import { ExternalLink, Share } from '@holi/icons/src/generated'
 import { useTranslation } from 'react-i18next'
 import { HoliIcon } from '@holi/icons/src/HoliIcon'
 import { TrackingEvent } from '@holi/core/tracking'
+import useTrackOnce from '@holi/core/tracking/hooks/useTrackOnce'
 
 export type EventDetailsParams = {
   eventId: string
@@ -24,6 +25,9 @@ export const EventDetailsScreen = () => {
   const [eventId] = useParam('eventId')
   const { data, url: eventUrl, refetch, onShare } = useEventDetailsData(eventId as string)
   const { t } = useTranslation()
+
+  useTrackOnce(TrackingEvent.EventDetails.viewed(eventId as string))
+
   return (
     <Screen
       onRefresh={refetch}
-- 
GitLab