Skip to content

Commit

Permalink
feat(tracker): add the event tracker for clicking collection tab in u…
Browse files Browse the repository at this point in the history
…ser profile page
  • Loading branch information
zeckli committed Nov 5, 2024
1 parent 7a466ea commit 0edf4cc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/common/utils/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export interface ClickButtonProp {
| 'newest'
| 'campaign_detail_link'
| `campaign_detail_tab_${string}`
| `user_profile_tab_${string}`
pageType?: PageType
pageComponent?: PageComponent
}
Expand Down
7 changes: 6 additions & 1 deletion src/components/Tabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ const Tab: React.FC<React.PropsWithChildren<TabProps>> = ({

if (href) {
return (
<li role="tab" aria-selected={selected} className={classes}>
<li
role="tab"
aria-selected={selected}
className={classes}
onClick={onClick}
>
<Link href={href || ''} legacyBehavior>
<a>
{children}
Expand Down
8 changes: 7 additions & 1 deletion src/views/User/UserTabs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useContext } from 'react'
import { FormattedMessage } from 'react-intl'

import { toPath } from '~/common/utils'
import { analytics, toPath } from '~/common/utils'
import { Tabs, useRoute, ViewerContext } from '~/components'
import { TabsUserFragment } from '~/gql/graphql'

Expand Down Expand Up @@ -53,6 +53,12 @@ const UserTabs = ({
{...userCollectionsPath}
selected={isInPath('USER_COLLECTIONS')}
count={collectionCount > 0 ? collectionCount : undefined}
onClick={() => {
analytics.trackEvent('click_button', {
type: `user_profile_tab_collection` as `user_profile_tab_${string}`,
pageType: 'user_profile',
})
}}
>
<FormattedMessage defaultMessage="Collections" id="ulh3kf" />
</Tabs.Tab>
Expand Down

0 comments on commit 0edf4cc

Please sign in to comment.