Skip to content

Commit

Permalink
frontend: update github campaign page event tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
634750802 committed Sep 29, 2024
1 parent 341fb44 commit 801ef93
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion web/src/pages/open-source-heroes/_components/ClaimForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { giftClientWithoutCache } from '@site/src/api/client';
import { TiDBCloudButton } from '@site/src/pages/open-source-heroes/_components/TiDBCloudButton';
import { useResponsiveAuth0 } from '@site/src/theme/NavbarItem/useResponsiveAuth0';
import { getErrorMessage } from '@site/src/utils/error';
import { useGtag } from '@site/src/utils/ga';
import { twitterLink } from '@site/src/utils/share';
import React, { type ReactNode, useEffect, useState } from 'react';
import { XIcon } from 'react-share';
Expand All @@ -24,6 +25,7 @@ type Tenant = {
export function ClaimForm () {
const [claimedThisSession, setClaimedThisSession] = useState(false);
const { getAccessTokenSilently } = useResponsiveAuth0();
const { gtagEvent } = useGtag();

const { data: check, mutate } = useSWR('/api/v1/serverless-credits-campaign/credits/check', async url => await giftClientWithoutCache.get<any, Check>(url, {
withCredentials: true,
Expand All @@ -41,9 +43,10 @@ export function ClaimForm () {
headers: {
Authorization: `Bearer ${await getAccessTokenSilently({ connection: 'github' })}`,
},
}), { revalidateOnFocus: false });
}));

const handleClaim = async (id: string) => {
gtagEvent('github_campaign_claim', {});
await giftClientWithoutCache.post('/api/v1/serverless-credits-campaign/credits/claim', {
selectedTenantId: id,
}, {
Expand Down
1 change: 0 additions & 1 deletion web/src/pages/open-source-heroes/_sections/0-heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export function HeadingSection () {
return <PrimaryHeading
loading={isLoading}
onClickAction={() => {
console.log('github_campaign_action');
gtagEvent('github_campaign_action', {});
if (isGithubSub(user?.sub)) {
setClaiming(true);
Expand Down
1 change: 1 addition & 0 deletions web/src/utils/ga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type CustomEventMap = {
trigger_login: GaEvent<'trigger_login_by'>;

github_campaign_action: GaEvent<never>;
github_campaign_claim: GaEvent<never>;
};

interface GtagEventApi {
Expand Down

0 comments on commit 801ef93

Please sign in to comment.