Skip to content

Commit 64767ce

Browse files
chore: add onboarding events in posthog (calcom#25981)
* add onboarding events in posthog * Update apps/web/modules/onboarding/organization/teams/organization-teams-view.tsx Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
1 parent e84550b commit 64767ce

7 files changed

Lines changed: 77 additions & 9 deletions

File tree

apps/web/modules/onboarding/getting-started/onboarding-view.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { AnimatePresence } from "framer-motion";
44
import { useRouter } from "next/navigation";
5+
import posthog from "posthog-js";
56
import { useEffect, useRef, useTransition } from "react";
67

78
import { useTeamInvites } from "@calcom/features/billing/hooks/useHasPaidPlan";
@@ -69,6 +70,11 @@ export const OnboardingView = ({ userEmail }: OnboardingViewProps) => {
6970
}, [selectedPlan]);
7071

7172
const handleContinue = () => {
73+
if (selectedPlan) {
74+
posthog.capture("onboarding_plan_continue_clicked", {
75+
plan_type: selectedPlan,
76+
});
77+
}
7278
startTransition(() => {
7379
if (selectedPlan === "organization") {
7480
router.push("/onboarding/organization/details");
@@ -157,7 +163,13 @@ export const OnboardingView = ({ userEmail }: OnboardingViewProps) => {
157163
{/* Plan options */}
158164
<RadioAreaGroup.Group
159165
value={selectedPlan ?? undefined}
160-
onValueChange={(value) => setSelectedPlan(value as PlanType)}
166+
onValueChange={(value) => {
167+
const planType = value as PlanType;
168+
setSelectedPlan(planType);
169+
posthog.capture("onboarding_plan_selected", {
170+
plan_type: planType,
171+
});
172+
}}
161173
className="flex w-full flex-col gap-1 rounded-[10px]">
162174
{plans.map((plan) => {
163175
const isSelected = selectedPlan === plan.id;

apps/web/modules/onboarding/organization/brand/organization-brand-view.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { useRouter } from "next/navigation";
4+
import posthog from "posthog-js";
45
import { useEffect, useRef, useState } from "react";
56

67
import { useLocale } from "@calcom/lib/hooks/useLocale";
@@ -72,6 +73,11 @@ export const OrganizationBrandView = ({ userEmail }: OrganizationBrandViewProps)
7273
};
7374

7475
const handleContinue = () => {
76+
posthog.capture("onboarding_organization_brand_continue_clicked", {
77+
has_logo: !!logoPreview,
78+
has_banner: !!bannerPreview,
79+
has_custom_color: brandColor !== "#000000",
80+
});
7581
// Save to store (already saved on change, but ensure it's persisted)
7682
setOrganizationBrand({
7783
logo: logoPreview,
@@ -82,6 +88,7 @@ export const OrganizationBrandView = ({ userEmail }: OrganizationBrandViewProps)
8288
};
8389

8490
const handleSkip = () => {
91+
posthog.capture("onboarding_organization_brand_skip_clicked");
8592
// Skip brand customization and go to teams
8693
router.push("/onboarding/organization/teams");
8794
};
@@ -97,7 +104,10 @@ export const OrganizationBrandView = ({ userEmail }: OrganizationBrandViewProps)
97104
<Button
98105
color="minimal"
99106
className="rounded-[10px]"
100-
onClick={() => router.push("/onboarding/organization/details")}>
107+
onClick={() => {
108+
posthog.capture("onboarding_organization_brand_back_clicked");
109+
router.push("/onboarding/organization/details");
110+
}}>
101111
{t("back")}
102112
</Button>
103113
<div className="flex items-center gap-2">

apps/web/modules/onboarding/organization/details/organization-details-view.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { useRouter } from "next/navigation";
4+
import posthog from "posthog-js";
45
import { useEffect, useState } from "react";
56

67
import { useLocale } from "@calcom/lib/hooks/useLocale";
@@ -67,6 +68,10 @@ export const OrganizationDetailsView = ({ userEmail }: OrganizationDetailsViewPr
6768
return;
6869
}
6970

71+
posthog.capture("onboarding_organization_details_continue_clicked", {
72+
has_bio: !!organizationBio,
73+
});
74+
7075
// Save to store
7176
setOrganizationDetails({
7277
name: organizationName,
@@ -87,7 +92,10 @@ export const OrganizationDetailsView = ({ userEmail }: OrganizationDetailsViewPr
8792
<Button
8893
color="minimal"
8994
className="rounded-[10px]"
90-
onClick={() => router.push("/onboarding/getting-started")}>
95+
onClick={() => {
96+
posthog.capture("onboarding_organization_details_back_clicked");
97+
router.push("/onboarding/getting-started");
98+
}}>
9199
{t("back")}
92100
</Button>
93101
<Button

apps/web/modules/onboarding/organization/invite/organization-invite-view.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { useRouter } from "next/navigation";
4+
import posthog from "posthog-js";
45
import React from "react";
56

67
import { useFlags } from "@calcom/features/flags/hooks";
@@ -48,6 +49,7 @@ export const OrganizationInviteView = ({ userEmail }: OrganizationInviteViewProp
4849
};
4950

5051
const handleSkip = async () => {
52+
posthog.capture("onboarding_organization_invite_skip_clicked");
5153
setInvites([]);
5254
await submitOnboarding(store, userEmail, []);
5355
};
@@ -67,7 +69,10 @@ export const OrganizationInviteView = ({ userEmail }: OrganizationInviteViewProp
6769
<Button
6870
color="minimal"
6971
className="rounded-[10px]"
70-
onClick={() => router.push("/onboarding/organization/teams")}
72+
onClick={() => {
73+
posthog.capture("onboarding_organization_invite_back_clicked");
74+
router.push("/onboarding/organization/teams");
75+
}}
7176
disabled={isSubmitting}>
7277
{t("back")}
7378
</Button>

apps/web/modules/onboarding/organization/teams/organization-teams-view.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { zodResolver } from "@hookform/resolvers/zod";
44
import { useRouter } from "next/navigation";
5+
import posthog from "posthog-js";
56
import { useForm, useFieldArray } from "react-hook-form";
67
import { z } from "zod";
78

@@ -49,12 +50,17 @@ export const OrganizationTeamsView = ({ userEmail }: OrganizationTeamsViewProps)
4950
});
5051

5152
const handleContinue = (data: FormValues) => {
53+
const validTeams = data.teams.filter((team) => team.name.trim().length > 0);
54+
posthog.capture("onboarding_organization_teams_continue_clicked", {
55+
team_count: validTeams.length,
56+
});
5257
// Save teams to store
5358
setTeams(data.teams);
5459
router.push("/onboarding/organization/invite/email");
5560
};
5661

5762
const handleSkip = () => {
63+
posthog.capture("onboarding_organization_teams_skip_clicked");
5864
// Skip teams and go to invite
5965
router.push("/onboarding/organization/invite/email");
6066
};
@@ -76,7 +82,10 @@ export const OrganizationTeamsView = ({ userEmail }: OrganizationTeamsViewProps)
7682
type="button"
7783
color="minimal"
7884
className="rounded-[10px]"
79-
onClick={() => router.push("/onboarding/organization/brand")}>
85+
onClick={() => {
86+
posthog.capture("onboarding_organization_teams_back_clicked");
87+
router.push("/onboarding/organization/brand");
88+
}}>
8089
{t("back")}
8190
</Button>
8291
<div className="flex items-center gap-2">
@@ -121,7 +130,12 @@ export const OrganizationTeamsView = ({ userEmail }: OrganizationTeamsViewProps)
121130
size="sm"
122131
className="h-7 w-7"
123132
disabled={fields.length === 1}
124-
onClick={() => remove(index)}>
133+
onClick={() => {
134+
posthog.capture("onboarding_organization_teams_remove_clicked", {
135+
team_count: fields.length,
136+
});
137+
remove(index);
138+
}}>
125139
<Icon name="x" className="h-4 w-4" />
126140
</Button>
127141
</div>
@@ -135,7 +149,12 @@ export const OrganizationTeamsView = ({ userEmail }: OrganizationTeamsViewProps)
135149
size="sm"
136150
StartIcon="plus"
137151
className="w-fit"
138-
onClick={() => append({ name: "" })}>
152+
onClick={() => {
153+
posthog.capture("onboarding_organization_teams_add_clicked", {
154+
team_count: fields.length,
155+
});
156+
append({ name: "" });
157+
}}>
139158
{t("add")}
140159
</Button>
141160
</div>

apps/web/modules/onboarding/teams/details/team-details-view.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { useRouter } from "next/navigation";
4+
import posthog from "posthog-js";
45
import { useEffect, useRef, useState, type FormEvent } from "react";
56

67
import { useLocale } from "@calcom/lib/hooks/useLocale";
@@ -72,6 +73,11 @@ export const TeamDetailsView = ({ userEmail }: TeamDetailsViewProps) => {
7273
return;
7374
}
7475

76+
posthog.capture("onboarding_team_details_continue_clicked", {
77+
has_logo: !!teamLogo,
78+
has_bio: !!teamBio,
79+
});
80+
7581
setTeamDetails({
7682
name: teamName,
7783
slug: teamSlug,
@@ -102,7 +108,10 @@ export const TeamDetailsView = ({ userEmail }: TeamDetailsViewProps) => {
102108
type="button"
103109
color="minimal"
104110
className="rounded-[10px]"
105-
onClick={() => router.push("/onboarding/getting-started")}>
111+
onClick={() => {
112+
posthog.capture("onboarding_team_details_back_clicked");
113+
router.push("/onboarding/getting-started");
114+
}}>
106115
{t("back")}
107116
</Button>
108117
<Button

apps/web/modules/onboarding/teams/invite/team-invite-view.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { useRouter, useSearchParams } from "next/navigation";
4+
import posthog from "posthog-js";
45
import React, { useEffect } from "react";
56

67
import { useFlags } from "@calcom/features/flags/hooks";
@@ -62,6 +63,7 @@ export const TeamInviteView = ({ userEmail }: TeamInviteViewProps) => {
6263
};
6364

6465
const handleSkip = async () => {
66+
posthog.capture("onboarding_team_invite_skip_clicked");
6567
setTeamInvites([]);
6668
// Create the team without invites (will handle checkout redirect if needed)
6769
await createTeam(store);
@@ -80,7 +82,10 @@ export const TeamInviteView = ({ userEmail }: TeamInviteViewProps) => {
8082
<Button
8183
color="minimal"
8284
className="rounded-[10px]"
83-
onClick={() => router.push("/onboarding/teams/details")}
85+
onClick={() => {
86+
posthog.capture("onboarding_team_invite_back_clicked");
87+
router.push("/onboarding/teams/details");
88+
}}
8489
disabled={isSubmitting}>
8590
{t("back")}
8691
</Button>

0 commit comments

Comments
 (0)