Skip to content

Commit

Permalink
Merge pull request #176 from daodaoedu/dev
Browse files Browse the repository at this point in the history
Merge to prod
  • Loading branch information
vincentxuu authored Dec 16, 2024
2 parents ba75e45 + 7acba99 commit 9473b7e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pages/learning-marathon/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Faq from '@/components/Marathon/Faq';
import { useAuth, useAuthDispatch } from '@/contexts/Auth';
import { cn } from '@/utils/cn';
import Banner from '@/components/Banner';
import { logEvent } from '@/utils/analytics';

const StyledBannerButton = styled(Button)`
&.MuiButton-root {
Expand Down Expand Up @@ -299,6 +300,10 @@ const LearningMarathon = () => {
);

const handleClickSignupButton = () => {
logEvent('Learning Marathon', 'Signup Button Clicked', {
user_logged_in: isLoggedIn,
user_temporary: isTemporary
});
if (isLoggedIn || isTemporary) {
router.push('/learning-marathon/signup');
} else {
Expand Down
14 changes: 12 additions & 2 deletions utils/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@ export const logPageView = () => {
ReactGA.pageview(window.location.pathname);
};

export const logEvent = (category = "", action = "") => {
export const logEvent = (category = "", action = "", label = "", value = null) => {
if (category && action) {
ReactGA.event({ category, action });
const eventParams = {
category,
action,
label
};

if (value !== null) {
eventParams.value = value;
}

ReactGA.event(eventParams);
}
};

Expand Down

0 comments on commit 9473b7e

Please sign in to comment.