Skip to content

Commit

Permalink
feat: add click on quest (#1371)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcheee authored Oct 7, 2024
1 parent 71a4ba6 commit 49aae9c
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ import {
InstructionsAccordionLinkBox,
InstructionsAccordionToggle,
} from '.';
import { useUserTracking } from 'src/hooks/userTracking';
import {
TrackingAction,
TrackingCategory,
TrackingEventParameter,
} from 'src/const/trackingKeys';

interface InstructionsAccordionItemProps extends InstructionItemProps {
index: number;
Expand Down Expand Up @@ -53,6 +59,7 @@ export const InstructionsAccordionItem = ({
}: InstructionsAccordionItemProps) => {
const [open, setOpen] = useState(false);
const theme = useTheme();
const { trackEvent } = useUserTracking();
const isTablet = useMediaQuery(theme.breakpoints.up('sm' as Breakpoint));
const handleOpen:
| MouseEventHandler<HTMLDivElement | HTMLButtonElement>
Expand All @@ -69,6 +76,20 @@ export const InstructionsAccordionItem = ({
}
}, []);

const handleClick = (i: number) => {
trackEvent({
category: TrackingCategory.Quests,
action: TrackingAction.ClickMissionCtaSteps,
label: `click-mission-cta-steps`,
data: {
[TrackingEventParameter.MissionCtaStepsTitle]: title || '',
[TrackingEventParameter.MissionCtaStepsLink]: buttonLinks?.[i] || '',
[TrackingEventParameter.MissionCtaStepsCTA]: buttonTitles?.[i] || '',
[TrackingEventParameter.MissionCtaStepsIndex]: index || -1,
},
});
};

return (
<InstructionsAccordionItemContainer
sx={{
Expand Down Expand Up @@ -140,6 +161,7 @@ export const InstructionsAccordionItem = ({
target="_blank"
rel="noreferrer"
style={{ textDecoration: 'none', color: 'inherit' }}
onClick={() => handleClick(i)}
>
<InstructionsAccordionLinkBox>
<Typography
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ import {
PROFILE_CAMPAIGN_FLASHY_APY_COLOR,
PROFILE_CAMPAIGN_LIGHT_COLOR,
} from 'src/const/partnerRewardsTheme';
import { useUserTracking } from 'src/hooks/userTracking';
import {
TrackingAction,
TrackingCategory,
TrackingEventParameter,
} from 'src/const/trackingKeys';

export interface RewardsInterface {
logo: string;
Expand All @@ -50,6 +56,8 @@ interface QuestCardProps {
claimingIds?: string[];
variableWeeklyAPY?: boolean;
rewardRange?: string;
label?: string;
id?: number;
}

export const QuestCardDetailled = ({
Expand All @@ -67,17 +75,34 @@ export const QuestCardDetailled = ({
claimingIds,
variableWeeklyAPY,
rewardRange,
label,
id,
}: QuestCardProps) => {
const theme = useTheme();
const { t } = useTranslation();
const router = useRouter();
const { apy, isLoading, isSuccess } = useMissionsMaxAPY(claimingIds);
const { trackEvent } = useUserTracking();

const handleClick = () => {
trackEvent({
category: TrackingCategory.Quests,
action: TrackingAction.ClickQuestCard,
label: 'click-quest-card',
data: {
[TrackingEventParameter.QuestCardTitle]: title || '',
[TrackingEventParameter.QuestCardLabel]: label || '',
[TrackingEventParameter.QuestCardId]: id || '',
},
});
};

return (
<QuestCardMainBox>
<Link
href={link || `/quests/${slug}`}
style={{ textDecoration: 'inherit' }}
onClick={handleClick}
>
<Box sx={{ display: 'flex', flexDirection: 'row', height: '65%' }}>
{image && (
Expand Down
2 changes: 2 additions & 0 deletions src/components/ProfilePage/QuestCarousel/QuestCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export const QuestCarousel = ({
quest?.attributes.Points > 0 && rewardType === 'weekly'
}
rewardRange={rewardRange}
label={quest?.attributes?.Label}
id={quest?.id}
/>
);
})
Expand Down
5 changes: 5 additions & 0 deletions src/const/trackingKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export enum TrackingAction {
// Quests
ClickQuestCard = 'action_click_quest_card',
ClickMissionCta = 'action_click_mission_cta',
ClickMissionCtaSteps = 'action_click_mission_cta_steps',

// Pagination
ClickPagination = 'action_click_pagination',
Expand Down Expand Up @@ -201,4 +202,8 @@ export enum TrackingEventParameter {
MissionCtaLabel = 'param_mission_cta_label',
MissionCtaPartnerId = 'param_mission_cta_partner_id',
MissionCtaCampaign = 'param_mission_cta_campaign',
MissionCtaStepsTitle = 'param_mission_cta_steps_title',
MissionCtaStepsLink = 'param_mission_cta_steps_link',
MissionCtaStepsCTA = 'param_mission_cta_steps_cta',
MissionCtaStepsIndex = 'param_mission_cta_steps_index',
}

0 comments on commit 49aae9c

Please sign in to comment.