Skip to content

Commit

Permalink
feat(ONYX-1458): add tracking (#11331)
Browse files Browse the repository at this point in the history
* feat: add tracking

* fix: add missing tracking

* fix: fix test
  • Loading branch information
dariakoko authored Jan 2, 2025
1 parent 9ebd373 commit bb6db0e
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 6 deletions.
35 changes: 33 additions & 2 deletions src/app/Scenes/ArtworkLists/SavesTabHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ActionType, ContextModule, OwnerType } from "@artsy/cohesion"
import {
AddIcon,
Box,
Expand All @@ -21,13 +22,15 @@ import { ProgressiveOnboardingSignalInterest } from "app/Components/ProgressiveO
import { navigate } from "app/system/navigation/navigate"
import { useFeatureFlag } from "app/utils/hooks/useFeatureFlag"
import { useState } from "react"
import { useTracking } from "react-tracking"

const PARTNER_OFFER_HELP_ARTICLE_URL = "https://support.artsy.net/s/article/Offers-on-saved-works"

export const SavesTabHeader = () => {
const [modalVisible, setModalVisible] = useState(false)
const { dispatch } = useArtworkListsContext()
const isArtworkListOfferabilityEnabled = useFeatureFlag("AREnableArtworkListOfferability")
const tracking = useTracking()

const handleCreateList = () => {
dispatch({
Expand All @@ -48,7 +51,14 @@ export const SavesTabHeader = () => {
<ProgressiveOnboardingSignalInterest>
<Text variant="xs" color="black60">
Curate your own lists of the works you love and{" "}
<LinkText variant="xs" color="black60" onPress={() => setModalVisible(true)}>
<LinkText
variant="xs"
color="black60"
onPress={() => {
tracking.trackEvent(tracks.tapFollowsInfo())
setModalVisible(true)
}}
>
signal your interest to galleries
</LinkText>
.
Expand Down Expand Up @@ -100,7 +110,12 @@ export const SavesTabHeader = () => {
<Text variant="sm-display">
Signal your interest to galleries and you could receiving an offer on your saved
artwork from a gallery.{" "}
<LinkText onPress={() => navigate(PARTNER_OFFER_HELP_ARTICLE_URL)}>
<LinkText
onPress={() => {
tracking.trackEvent(tracks.tapReadMore())
navigate(PARTNER_OFFER_HELP_ARTICLE_URL)
}}
>
Read more
</LinkText>
.
Expand Down Expand Up @@ -133,3 +148,19 @@ export const SavesTabHeaderPlaceholder = () => {
</Skeleton>
)
}

const tracks = {
tapFollowsInfo: () => ({
action: ActionType.tappedLink,
context_module: ContextModule.saves,
context_screen_owner_type: OwnerType.saves,
type: "link",
subject: "signalYourInterestToGalleries",
}),
tapReadMore: () => ({
action: ActionType.tappedLink,
context_module: ContextModule.saves,
context_screen_owner_type: OwnerType.savesInfoModal,
type: "link",
}),
}
15 changes: 14 additions & 1 deletion src/app/Scenes/Favorites/Favorites.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ActionType, ContextModule, OwnerType, TappedInfoBubble } from "@artsy/cohesion"
import {
BellIcon,
Flex,
Expand Down Expand Up @@ -75,6 +76,9 @@ export const Favorites: React.FC = () => {
BelowTitleHeaderComponent={() => (
<Flex px={2}>
<InfoButton
trackEvent={() => {
tracking.trackEvent(tracks.tapFollowsInfo())
}}
titleElement={
<Text variant="lg-display" mr={1}>
Follows
Expand Down Expand Up @@ -104,7 +108,7 @@ export const Favorites: React.FC = () => {
<BellIcon mr={0.5} />
<Flex flex={1}>
<Text variant="sm-display">
Never miss out by exploring your Activity and receiving timely email updates
Never miss out by exploring your Activity and receiving timely email
updates.
</Text>
</Flex>
Expand Down Expand Up @@ -136,3 +140,12 @@ export const Favorites: React.FC = () => {
</ProvideScreenTracking>
)
}

const tracks = {
tapFollowsInfo: (): TappedInfoBubble => ({
action: ActionType.tappedInfoBubble,
context_module: ContextModule.follows,
context_screen_owner_type: OwnerType.follows,
subject: "followsHeader",
}),
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ describe(makeCareerHighlightMap, () => {

it("Prepares the eventDigest and creates a map of each year to the highlight kind", () => {
const result = makeCareerHighlightMap(
"2016 Group Show @ MOCA Los Angeles; 2015 Reviewed Solo Show @ The Guardian; 2015 Reviewed Solo Show @ Art in America"
"2017 Group Show @ MOCA Los Angeles; 2015 Reviewed Solo Show @ The Guardian; 2015 Reviewed Solo Show @ Art in America"
)

expect(result).toEqual({
2016: { "Group Show": ["MOCA Los Angeles"] },
2017: { "Group Show": ["MOCA Los Angeles"] },
})
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OwnerType } from "@artsy/cohesion"
import { ActionType, ContextModule, OwnerType, TappedInfoBubble } from "@artsy/cohesion"
import {
BellIcon,
FilterIcon,
Expand Down Expand Up @@ -30,6 +30,7 @@ import { RefreshEvents, SAVED_ALERT_REFRESH_KEY } from "app/utils/refreshHelpers
import { ProvideScreenTracking, Schema } from "app/utils/track"
import React, { useEffect, useRef, useState } from "react"
import { RelayPaginationProp, createPaginationContainer, graphql } from "react-relay"
import { useTracking } from "react-tracking"
import usePrevious from "react-use/lib/usePrevious"
import { EmptyMessage } from "./EmptyMessage"
import { SavedSearchAlertsListPlaceholder } from "./SavedSearchAlertsListPlaceholder"
Expand Down Expand Up @@ -159,6 +160,7 @@ export const SavedSearchesListWrapper: React.FC<SavedSearchListWrapperProps> = (
const prevSelectedSortValue = usePrevious(selectedSortValue)
const [fetchingMore, setFetchingMore] = useState(false)
const [refreshMode, setRefreshMode] = useState<RefreshType | null>(null)
const tracking = useTracking()

const handleCloseModal = () => {
setModalVisible(false)
Expand Down Expand Up @@ -240,6 +242,8 @@ export const SavedSearchesListWrapper: React.FC<SavedSearchListWrapperProps> = (
const infoButtonRef = useRef<{ closeModal: () => void } | null>(null)

const handleNavigate = () => {
tracking.trackEvent(tracks.tapActivityLink())

infoButtonRef.current?.closeModal()

requestAnimationFrame(() => {
Expand All @@ -264,6 +268,9 @@ export const SavedSearchesListWrapper: React.FC<SavedSearchListWrapperProps> = (
<Flex px={2}>
<InfoButton
ref={infoButtonRef}
trackEvent={() => {
tracking.trackEvent(tracks.tapAlertsInfo())
}}
titleElement={
<Text variant="lg-display" mr={1}>
Alerts
Expand Down Expand Up @@ -391,3 +398,18 @@ export const SavedSearchesListPaginationContainer = createPaginationContainer(
`,
}
)

const tracks = {
tapAlertsInfo: (): TappedInfoBubble => ({
action: ActionType.tappedInfoBubble,
context_module: ContextModule.alertsList,
context_screen_owner_type: OwnerType.alerts,
subject: "alertsHeader",
}),
tapActivityLink: () => ({
action: ActionType.tappedLink,
context_module: ContextModule.alertsList,
context_screen_owner_type: OwnerType.alertsInfoModal,
type: "link",
}),
}

0 comments on commit bb6db0e

Please sign in to comment.