Skip to content

Commit a46cb7f

Browse files
committed
fix: refactor, adjust the trackTappedNavigationTab event
1 parent d154829 commit a46cb7f

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

src/app/Scenes/Favorites/Components/FavoritesLearnMore.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
import { BottomSheetScrollView } from "@gorhom/bottom-sheet"
1717
import { AutomountedBottomSheetModal } from "app/Components/BottomSheet/AutomountedBottomSheetModal"
1818
import { CallapseWithTitle } from "app/Scenes/Favorites/Components/CollapseWithTitle"
19-
import { FavoritesContextStore } from "app/Scenes/Favorites/FavoritesContextStore"
2019
import { useFavoritesTracking } from "app/Scenes/Favorites/useFavoritesTracking"
2120
import React, { useState } from "react"
2221
import { Dimensions } from "react-native"
@@ -100,7 +99,6 @@ const SECTIONS = [
10099
]
101100

102101
export const FavoritesLearnMore = () => {
103-
const { activeTab } = FavoritesContextStore.useStoreState((state) => state)
104102
const [showBottomSheet, setShowBottomSheet] = useState(false)
105103
const { bottom } = useSafeAreaInsets()
106104
const { trackTappedInfoBubble } = useFavoritesTracking()
@@ -113,7 +111,7 @@ export const FavoritesLearnMore = () => {
113111
<Touchable
114112
onPress={() => {
115113
setShowBottomSheet(true)
116-
trackTappedInfoBubble(activeTab)
114+
trackTappedInfoBubble()
117115
}}
118116
>
119117
<QuestionCircleIcon height={ICON_SIZE} width={ICON_SIZE} hitSlop={DEFAULT_HIT_SLOP} />

src/app/Scenes/Favorites/Favorites.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ const FavoritesHeaderTapBar: React.FC<MaterialTopTabBarProps> = ({ state, naviga
6868
<Pill
6969
selected={isActive}
7070
onPress={() => {
71+
// Make sure to track the tap before changing the active tab
72+
trackTappedNavigationTab(key)
7173
setActiveTab(key)
7274

7375
// We are manually emitting the tabPress event here because
@@ -80,7 +82,6 @@ const FavoritesHeaderTapBar: React.FC<MaterialTopTabBarProps> = ({ state, naviga
8082
})
8183

8284
navigation.navigate(key)
83-
trackTappedNavigationTab(key)
8485
}}
8586
Icon={() => (
8687
<Flex mr={0.5} justifyContent="center" bottom="1px">

src/app/Scenes/Favorites/useFavoritesTracking.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,44 @@ import {
1515
TappedOfferSettings,
1616
} from "@artsy/cohesion/dist/Schema/Events/Favorites"
1717
import { useIsFocused } from "@react-navigation/native"
18-
import { FavoritesTab } from "app/Scenes/Favorites/FavoritesContextStore"
18+
import { FavoritesContextStore, FavoritesTab } from "app/Scenes/Favorites/FavoritesContextStore"
1919
import { screen } from "app/utils/track/helpers"
2020
import { useEffect } from "react"
2121
import { useTracking } from "react-tracking"
2222

2323
export const useFavoritesTracking = () => {
24+
const activeTab = FavoritesContextStore.useStoreState((state) => state.activeTab)
25+
2426
const { trackEvent } = useTracking()
2527

2628
const trackTappedNavigationTab = (key: FavoritesTab) => {
2729
const payload = {
2830
action: ActionType.tappedNavigationTab,
29-
context_module: key,
31+
context_module: activeTab,
3032
subject: key,
3133
}
3234

3335
trackEvent(payload)
3436
}
3537

36-
const trackTappedInfoBubble = (activeTab: FavoritesTab) => {
37-
let contextScreen: ContextModule
38+
const trackTappedInfoBubble = () => {
39+
let contextModule: ContextModule
3840
switch (activeTab) {
3941
case "saves":
40-
contextScreen = ContextModule.favoritesSaves
42+
contextModule = ContextModule.favoritesSaves
4143
break
4244
case "follows":
43-
contextScreen = ContextModule.favoritesFollows
45+
contextModule = ContextModule.favoritesFollows
4446
break
4547
case "alerts":
46-
contextScreen = ContextModule.favoritesAlerts
48+
contextModule = ContextModule.favoritesAlerts
4749
break
4850
}
4951

5052
const payload: TappedInfoBubble = {
5153
action: ActionType.tappedInfoBubble,
5254
context_screen_owner_type: OwnerType.favorites,
53-
context_module: contextScreen,
55+
context_module: contextModule,
5456
subject: "favoritesHeader",
5557
}
5658

0 commit comments

Comments
 (0)