- 
                Notifications
    You must be signed in to change notification settings 
- Fork 35
feat: add analytics tracking to home page elements #1701
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
base: main
Are you sure you want to change the base?
Changes from all commits
48f8aed
              22f7c8b
              3c7a918
              d4b8a91
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -53,6 +53,7 @@ import { isCowAmm, isBalancer, PROJECT_CONFIG } from '@repo/lib/config/getProjec | |
| import { poolTypeLabel } from '../pool.helpers' | ||
| import { AnimatedTag } from '@repo/lib/shared/components/other/AnimatedTag' | ||
| import { PoolMinTvlFilter } from './PoolMinTvlFilter' | ||
| import { AnalyticsEvent, trackEvent } from '@repo/lib/shared/services/fathom/Fathom' | ||
|  | ||
| export function useFilterTagsVisible() { | ||
| const { | ||
|  | @@ -378,12 +379,24 @@ export function FilterTags({ | |
| } | ||
|  | ||
| export const FilterButton = forwardRef<ButtonProps & { totalFilterCount: number }, 'button'>( | ||
| ({ totalFilterCount, ...props }, ref) => { | ||
| ({ totalFilterCount, onClick, ...props }, ref) => { | ||
| const { isMobile } = useBreakpoints() | ||
| const textColor = useColorModeValue('#fff', 'font.dark') | ||
|  | ||
| const handleFilterClick = (e: React.MouseEvent<HTMLButtonElement>) => { | ||
| trackEvent(AnalyticsEvent.ClickPoolListFilter) | ||
| onClick?.(e) | ||
| } | ||
|  | ||
| return ( | ||
| <Button ref={ref} {...props} display="flex" gap="2" variant="tertiary"> | ||
| <Button | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The filters button doesn't seem to be working after this change, the handler function probably just eats the click event. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed here: 22f7c8b There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know why we have to do that (events should propagate unless otherwise stated), but it should do for now. | ||
| ref={ref} | ||
| {...props} | ||
| display="flex" | ||
| gap="2" | ||
| onClick={handleFilterClick} | ||
| variant="tertiary" | ||
| > | ||
| <Icon as={Filter} boxSize={4} /> | ||
| {!isMobile && 'Filters'} | ||
| {totalFilterCount > 0 && ( | ||
|  | @@ -634,6 +647,7 @@ export function PoolListFilters() { | |
| href={poolCreatorUrl} | ||
| isExternal | ||
| ml="ms" | ||
| onClick={() => trackEvent(AnalyticsEvent.ClickPoolListCreatePool)} | ||
| variant="tertiary" | ||
| > | ||
| <Icon as={Plus} boxSize={4} /> | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -21,6 +21,7 @@ import { isBalancer, isCowAmm } from '@repo/lib/config/getProjectConfig' | |
| import { UserFeedback } from '@repo/lib/modules/user/UserFeedback' | ||
| import { ApiOutageAlert } from '../alerts/ApiOutageAlert' | ||
| import { useApiHealth } from '../../hooks/useApiHealth' | ||
| import { AnalyticsEvent, trackEvent } from '../../services/fathom/Fathom' | ||
|  | ||
| type Props = { | ||
| mobileNav?: ReactNode | ||
|  | @@ -61,6 +62,16 @@ function NavLinks({ | |
| }) { | ||
| const { linkColorFor } = useNav() | ||
|  | ||
| const handleLinkClick = (analyticsEvent?: string) => { | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some of the code where we are tracking events is shared with Beets, do we want to track Beets events? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch. We definitely do not want to track events from Beets. I have updated the code to only track on Balancer events here :3c7a918 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is probably better to wrap the  | ||
| if ( | ||
| isBalancer && | ||
| analyticsEvent && | ||
| AnalyticsEvent[analyticsEvent as keyof typeof AnalyticsEvent] | ||
| ) { | ||
| trackEvent(AnalyticsEvent[analyticsEvent as keyof typeof AnalyticsEvent]) | ||
| } | ||
| } | ||
|  | ||
| return ( | ||
| <HStack fontWeight="medium" spacing="lg" {...props}> | ||
| {appLinks.map(link => { | ||
|  | @@ -72,6 +83,7 @@ function NavLinks({ | |
| color={linkColorFor(link.href || '')} | ||
| href={link.href} | ||
| isExternal={link.isExternal} | ||
| onClick={() => handleLinkClick(link.analyticsEvent)} | ||
| prefetch | ||
| variant="nav" | ||
| > | ||
|  | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The track event code does not seem to differentiate between prod and the dev environments. That could probably skew the results a little.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Fathom.tsx on Line 60, it looks like Fathom is only tracking these domains, so I think dev environments are not being tracked, right? If not, I could use some help here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see there is some code before that which mades it only run on prod:
The
zen.balancer.fidoes not point to anything though, we can remove it.