Skip to content
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

feat(tracker): add the event tracker for clicking collection tab in user profile #4934

Merged
merged 2 commits into from
Nov 5, 2024
Merged
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
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
Loading