Skip to content

fix: adjust tapped navigation tab event #11913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/Scenes/ArtworkList/ArtworkList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export const ArtworkListScreen: FC<ArtworkListScreenProps> = (props) => {
<Screen>
<ProvideScreenTrackingWithCohesionSchema
info={screen({
context_screen_owner_type: OwnerType.saves, // artworkList, // TODO: update when cohesion is up
context_screen_owner_type: OwnerType.artworkList,
context_screen_owner_id: props.listID,
})}
>
Expand Down
2 changes: 1 addition & 1 deletion src/app/Scenes/Favorites/Components/FavoritesLearnMore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const SECTIONS = [
]

export const FavoritesLearnMore = () => {
const { activeTab } = FavoritesContextStore.useStoreState((state) => state)
const activeTab = FavoritesContextStore.useStoreState((state) => state.activeTab)
const [showBottomSheet, setShowBottomSheet] = useState(false)
const { bottom } = useSafeAreaInsets()
const { trackTappedInfoBubble } = useFavoritesTracking()
Expand Down
11 changes: 9 additions & 2 deletions src/app/Scenes/Favorites/Favorites.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ContextModule } from "@artsy/cohesion"
import {
BellIcon,
Flex,
Expand All @@ -24,29 +25,34 @@ import { useFavoritesTracking } from "app/Scenes/Favorites/useFavoritesTracking"
import { prefetchQuery } from "app/utils/queryPrefetching"
import { useEffect } from "react"

const Pills: {
export const Pills: {
Icon: React.FC<{ fill: string }>
title: string
key: FavoritesTab
contextModule: ContextModule
}[] = [
{
Icon: HeartIcon,
title: "Saves",
key: "saves",
contextModule: ContextModule.favoritesSaves,
},
{
Icon: MultiplePersonsIcon,
title: "Follows",
key: "follows",
contextModule: ContextModule.favoritesFollows,
},
{
Icon: BellIcon,
title: "Alerts",
key: "alerts",
contextModule: ContextModule.favoritesAlerts,
},
]

const FavoritesHeaderTapBar: React.FC<MaterialTopTabBarProps> = ({ state, navigation }) => {
const activeTab = FavoritesContextStore.useStoreState((state) => state.activeTab)
const setActiveTab = FavoritesContextStore.useStoreActions((actions) => actions.setActiveTab)
const { trackTappedNavigationTab } = useFavoritesTracking()

Expand All @@ -68,6 +74,8 @@ const FavoritesHeaderTapBar: React.FC<MaterialTopTabBarProps> = ({ state, naviga
<Pill
selected={isActive}
onPress={() => {
// Make sure to track the tap before changing the active tab
trackTappedNavigationTab(key, activeTab)
setActiveTab(key)

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

navigation.navigate(key)
trackTappedNavigationTab(key)
}}
Icon={() => (
<Flex mr={0.5} justifyContent="center" bottom="1px">
Expand Down
20 changes: 5 additions & 15 deletions src/app/Scenes/Favorites/useFavoritesTracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
TappedOfferSettings,
} from "@artsy/cohesion/dist/Schema/Events/Favorites"
import { useIsFocused } from "@react-navigation/native"
import { Pills } from "app/Scenes/Favorites/Favorites"
import { FavoritesTab } from "app/Scenes/Favorites/FavoritesContextStore"
import { screen } from "app/utils/track/helpers"
import { useEffect } from "react"
Expand All @@ -23,34 +24,23 @@ import { useTracking } from "react-tracking"
export const useFavoritesTracking = () => {
const { trackEvent } = useTracking()

const trackTappedNavigationTab = (key: FavoritesTab) => {
const trackTappedNavigationTab = (key: FavoritesTab, activeTab: FavoritesTab) => {
const payload = {
action: ActionType.tappedNavigationTab,
context_module: key,
context_module: activeTab,
subject: key,
}

trackEvent(payload)
}

const trackTappedInfoBubble = (activeTab: FavoritesTab) => {
let contextScreen: ContextModule
switch (activeTab) {
case "saves":
contextScreen = ContextModule.favoritesSaves
break
case "follows":
contextScreen = ContextModule.favoritesFollows
break
case "alerts":
contextScreen = ContextModule.favoritesAlerts
break
}
const contextModule = Pills.find((pill) => pill.key === activeTab)?.contextModule

const payload: TappedInfoBubble = {
action: ActionType.tappedInfoBubble,
context_screen_owner_type: OwnerType.favorites,
context_module: contextScreen,
context_module: contextModule as ContextModule,
subject: "favoritesHeader",
}

Expand Down