Skip to content

Commit ba1d1d1

Browse files
feat: add analytics to experiements (#1131)
2 parents bd44ad9 + 6f29611 commit ba1d1d1

File tree

4 files changed

+40
-23
lines changed

4 files changed

+40
-23
lines changed

apps/web/src/components/Plans/Selector.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ export const Selector: React.FC<{
6868
<PlansPanel period={period} setPeriod={setPeriod} />
6969

7070
<div className="flex flex-wrap items-stretch md:flex-row justify-items-center justify-center gap-4 lg:gap-6">
71-
<TrialSessionCard />
71+
<TrialSessionCard
72+
onClick={() => track("browse_tutors_from_pricing", "info")}
73+
/>
7274
{sortedPlans.map((plan, idx) => {
7375
const index =
7476
idx < description.current.length

apps/web/src/lib/analytics/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ export type Category =
99
| "plans"
1010
| "checkout"
1111
| "lessons"
12-
| "tutors";
12+
| "tutors"
13+
| "info";
1314

1415
export type Action =
1516
| "book_lesson"
@@ -47,7 +48,9 @@ export type Action =
4748
| "play_tutor_video"
4849
| "complete_student_tour"
4950
| "skip_student_tour"
50-
| "remind_me";
51+
| "remind_me"
52+
| "browse_tutors_from_pricing"
53+
| "view_web_faq";
5154

5255
export type Params = {
5356
category: Category;

apps/web/src/pages/StudentDashboard.tsx

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import React, { useMemo, useState } from "react";
1616
import { Link } from "react-router-dom";
1717
import { useTutors } from "@litespace/headless/tutor";
1818
import { Tabs } from "@litespace/ui/Tabs";
19+
import { track } from "@/lib/analytics";
1920

2021
const StudentDashboard: React.FC = () => {
2122
const mq = useMediaQuery();
@@ -230,28 +231,39 @@ const Benefits = () => {
230231
const LearningApproachMobile = () => {
231232
const intl = useFormatMessage();
232233

233-
const methodologyContent = intl("questions.methodology.mobile-content");
234-
const studentTipsContent = intl("questions.benefits.mobile-content");
234+
const questions = useMemo(
235+
() => [
236+
{
237+
title: intl("questions.methodology.mobile-title"),
238+
content: intl("questions.methodology.mobile-content"),
239+
},
240+
{
241+
title: intl("questions.benefits.mobile-title"),
242+
content: intl("questions.benefits.mobile-content"),
243+
},
244+
],
245+
[intl]
246+
);
235247

236-
const questions = [
237-
{
238-
title: intl("questions.methodology.mobile-title"),
239-
content: methodologyContent,
240-
},
241-
{
242-
title: intl("questions.benefits.mobile-title"),
243-
content: studentTipsContent,
244-
},
245-
];
248+
const items = useMemo(
249+
() =>
250+
questions.map(({ title, content }, i) => ({
251+
id: i.toString(),
252+
title,
253+
content,
254+
})),
255+
[questions]
256+
);
246257

247258
return (
248259
<div className="block md:hidden">
249260
<Accordion
250-
items={questions.map(({ title, content }, i) => ({
251-
id: i.toString(),
252-
title,
253-
content,
254-
}))}
261+
onValueChange={(value) => {
262+
const item = items.find((item) => item.id === value);
263+
if (!item) return;
264+
track("view_web_faq", "student_dashboard", item.title);
265+
}}
266+
items={items}
255267
/>
256268
</div>
257269
);

packages/ui/src/components/Card/TrialSessionCard/TrialSessionCard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { Button } from "@/components/Button";
22
import { Typography } from "@/components/Typography";
33
import CheckMark from "@litespace/assets/CheckMark";
4-
import { ILesson } from "@litespace/types";
4+
import { ILesson, Void } from "@litespace/types";
55
import { useFormatMessage } from "@litespace/ui/hooks/intl";
66
import { price, TOTAL_LESSON_HOURLY_RATE } from "@litespace/utils";
77
import cn from "classnames";
88
import React from "react";
99
import { Link } from "react-router-dom";
1010
import { Web } from "@litespace/utils/routes";
1111

12-
export const TrialSessionCard: React.FC = () => {
12+
export const TrialSessionCard: React.FC<{ onClick: Void }> = ({ onClick }) => {
1313
const intl = useFormatMessage();
1414

1515
return (
@@ -68,7 +68,7 @@ export const TrialSessionCard: React.FC = () => {
6868
</Typography>
6969
</div>
7070
</div>
71-
<Link to={Web.Tutors} tabIndex={-1} className="w-full">
71+
<Link onClick={onClick} to={Web.Tutors} tabIndex={-1} className="w-full">
7272
<Button
7373
size="large"
7474
className="mt-6 w-full justify-center py-2 bg-primary-500 font-cairo hover:bg-brand-700"

0 commit comments

Comments
 (0)