Skip to content

Commit

Permalink
refactor(analytic): rename trackPageView to trackPageview
Browse files Browse the repository at this point in the history
  • Loading branch information
wzulfikar committed Mar 30, 2021
1 parent 1f61d61 commit 29629df
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/lib/analytic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function init() {
}
}

export function trackPageView() {
export function trackPageview() {
if (process.env.NODE_ENV === 'production') {
// You can replace this code with your preferred analytic
Fathom.trackPageview();
Expand All @@ -36,4 +36,4 @@ export function trackGoal({ event, centValue = 0 }: Event) {
Fathom.trackGoal(event, centValue);
}

export default { init, trackPageView, trackGoal };
export default { init, trackPageview, trackGoal };
3 changes: 2 additions & 1 deletion src/lib/analytic/nextjs-hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ export default function useAnalytic() {
const router = useRouter();
useEffect(() => {
analytic.init();
analytic.trackPageview(); // Track initial page

function onRouteChangeComplete() {
analytic.trackPageView();
analytic.trackPageview();
}

router.events.on('routeChangeComplete', onRouteChangeComplete);
Expand Down

1 comment on commit 29629df

@vercel
Copy link

@vercel vercel bot commented on 29629df Mar 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.