Skip to content

Commit

Permalink
Merge pull request #4934 from thematters/feat/tracker
Browse files Browse the repository at this point in the history
feat(tracker): add the event tracker for clicking collection tab in user profile
  • Loading branch information
zeckli authored Nov 5, 2024
2 parents e571a5e + 7862b07 commit 18096d7
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 18096d7

Please sign in to comment.