feat: posthog version upgrade and added trackings (#24401)
* posthog version upgrade and calai banner tracking * disable posthog for EU * bunch more posthog tracking * Revert yarn.lock changes * add posthog package yarn changes * fix: add missing posthog import and fix lint warning in MemberInvitationModal Co-Authored-By: [email protected] <[email protected]> * fix: type check * cubic fixes * refactor * remove ui playground --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
42 files changed
+570
-271
No files matched your search
@@ -3,6 +3,7 @@
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect } from "react";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
@@ -23,6 +24,9 @@ function VerifyEmailPage() {
|
||||
|
||||
useEffect(() => {
|
||||
if (data?.isVerified) {
|
||||
posthog.capture("verify_email_already_verified", {
|
||||
onboarding_v3_enabled: flags["onboarding-v3"],
|
||||
});
|
||||
const gettingStartedPath = flags["onboarding-v3"] ? "/onboarding/getting-started" : "/getting-started";
|
||||
router.replace(gettingStartedPath);
|
||||
}
|
||||
@@ -48,6 +52,7 @@ function VerifyEmailPage() {
|
||||
className="underline"
|
||||
loading={mutation.isPending}
|
||||
onClick={() => {
|
||||
posthog.capture("verify_email_resend_clicked");
|
||||
showToast(t("send_email"), "success");
|
||||
mutation.mutate();
|
||||
}}>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { revalidateAvailabilityList } from "app/(use-page-wrapper)/(main-nav)/av
|
||||
import Link from "next/link";
|
||||
import { useRouter, usePathname } from "next/navigation";
|
||||
import { useCallback, useState } from "react";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { BulkEditDefaultForEventsModal } from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal";
|
||||
import type { BulkUpdatParams } from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal";
|
||||
@@ -182,15 +183,18 @@ export function AvailabilityList({ availabilities }: AvailabilityListProps) {
|
||||
}
|
||||
|
||||
type AvailabilityCTAProps = {
|
||||
toggleGroupOptions: {
|
||||
value: string;
|
||||
label: string;
|
||||
}[];
|
||||
canViewTeamAvailability: boolean;
|
||||
};
|
||||
export const AvailabilityCTA = ({ toggleGroupOptions }: AvailabilityCTAProps) => {
|
||||
export const AvailabilityCTA = ({ canViewTeamAvailability }: AvailabilityCTAProps) => {
|
||||
const searchParams = useCompatSearchParams();
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const { t } = useLocale();
|
||||
|
||||
const toggleGroupOptions = [
|
||||
{ value: "mine", label: t("my_availability") },
|
||||
...(canViewTeamAvailability ? [{ value: "team", label: t("team_availability"), onClick: () => { posthog.capture("team_availability_toggle_clicked") } }] : []),
|
||||
]
|
||||
|
||||
// Get a new searchParams string by merging the current
|
||||
// searchParams with a provided key/value pair
|
||||
|
||||
@@ -6,6 +6,7 @@ import { usePathname, useRouter } from "next/navigation";
|
||||
import { Suspense, useTransition } from "react";
|
||||
import { Toaster } from "sonner";
|
||||
import { z } from "zod";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
@@ -40,33 +41,33 @@ const getStepsAndHeadersForUser = (t: TFunction) => {
|
||||
subtitle: string[];
|
||||
skipText?: string;
|
||||
}[] = [
|
||||
{
|
||||
title: t("welcome_to_cal_header", { appName: APP_NAME }),
|
||||
subtitle: [t("we_just_need_basic_info")],
|
||||
},
|
||||
{
|
||||
title: t("connect_your_calendar"),
|
||||
subtitle: [t("connect_your_calendar_instructions")],
|
||||
skipText: t("connect_calendar_later"),
|
||||
},
|
||||
{
|
||||
title: t("connect_your_video_app"),
|
||||
subtitle: [t("connect_your_video_app_instructions")],
|
||||
skipText: t("set_up_later"),
|
||||
},
|
||||
{
|
||||
title: t("set_availability"),
|
||||
subtitle: [
|
||||
`${t("set_availability_getting_started_subtitle_1")} ${t(
|
||||
"set_availability_getting_started_subtitle_2"
|
||||
)}`,
|
||||
],
|
||||
},
|
||||
{
|
||||
title: t("nearly_there"),
|
||||
subtitle: [t("nearly_there_instructions")],
|
||||
},
|
||||
];
|
||||
{
|
||||
title: t("welcome_to_cal_header", { appName: APP_NAME }),
|
||||
subtitle: [t("we_just_need_basic_info")],
|
||||
},
|
||||
{
|
||||
title: t("connect_your_calendar"),
|
||||
subtitle: [t("connect_your_calendar_instructions")],
|
||||
skipText: t("connect_calendar_later"),
|
||||
},
|
||||
{
|
||||
title: t("connect_your_video_app"),
|
||||
subtitle: [t("connect_your_video_app_instructions")],
|
||||
skipText: t("set_up_later"),
|
||||
},
|
||||
{
|
||||
title: t("set_availability"),
|
||||
subtitle: [
|
||||
`${t("set_availability_getting_started_subtitle_1")} ${t(
|
||||
"set_availability_getting_started_subtitle_2"
|
||||
)}`,
|
||||
],
|
||||
},
|
||||
{
|
||||
title: t("nearly_there"),
|
||||
subtitle: [t("nearly_there_instructions")],
|
||||
},
|
||||
];
|
||||
|
||||
return {
|
||||
steps: [...BASE_STEPS],
|
||||
@@ -132,7 +133,13 @@ const OnboardingPage = (props: PageProps) => {
|
||||
});
|
||||
};
|
||||
|
||||
const goToNextStep = () => {
|
||||
const goToNextStep = (wasSkipped: boolean = false) => {
|
||||
posthog.capture("onboarding_step_completed", {
|
||||
step: currentStep,
|
||||
step_index: currentStepIndex,
|
||||
from: from,
|
||||
was_skipped: wasSkipped,
|
||||
});
|
||||
const nextIndex = currentStepIndex + 1;
|
||||
const newStep = steps[nextIndex];
|
||||
startTransition(() => {
|
||||
@@ -195,7 +202,7 @@ const OnboardingPage = (props: PageProps) => {
|
||||
data-testid="skip-step"
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
goToNextStep();
|
||||
goToNextStep(true);
|
||||
}}
|
||||
className="mt-8 cursor-pointer px-4 py-2 font-sans text-sm font-medium">
|
||||
{headers[currentStepIndex]?.skipText}
|
||||
@@ -207,7 +214,13 @@ const OnboardingPage = (props: PageProps) => {
|
||||
<Button
|
||||
color="minimal"
|
||||
data-testid="sign-out"
|
||||
onClick={() => signOut({ callbackUrl: "/auth/logout" })}
|
||||
onClick={() => {
|
||||
posthog.capture("onboarding_sign_out_clicked", {
|
||||
step: currentStep,
|
||||
step_index: currentStepIndex,
|
||||
});
|
||||
signOut({ callbackUrl: "/auth/logout" });
|
||||
}}
|
||||
className="mt-8 cursor-pointer px-4 py-2 font-sans text-sm font-medium">
|
||||
{t("sign_out")}
|
||||
</Button>
|
||||
|
||||
@@ -12,6 +12,7 @@ import type { SubmitHandler } from "react-hook-form";
|
||||
import { useForm, useFormContext } from "react-hook-form";
|
||||
import { Toaster } from "sonner";
|
||||
import { z } from "zod";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import getStripe from "@calcom/app-store/stripepayment/lib/client";
|
||||
import { getPremiumPlanPriceValue } from "@calcom/app-store/stripepayment/lib/utils";
|
||||
@@ -241,6 +242,15 @@ export default function Signup({
|
||||
|
||||
const signUp: SubmitHandler<FormValues> = async (_data) => {
|
||||
const { cfToken, ...data } = _data;
|
||||
|
||||
posthog.capture("signup_form_submitted", {
|
||||
has_token: !!token,
|
||||
is_org_invite: isOrgInviteByLink,
|
||||
org_slug: orgSlug,
|
||||
is_premium_username: premiumUsername,
|
||||
username_taken: usernameTaken,
|
||||
});
|
||||
|
||||
await fetch("/api/auth/signup", {
|
||||
body: JSON.stringify({
|
||||
...data,
|
||||
@@ -296,6 +306,13 @@ export default function Signup({
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
posthog.capture("signup_form_submit_error", {
|
||||
has_token: !!token,
|
||||
is_org_invite: isOrgInviteByLink,
|
||||
org_slug: orgSlug,
|
||||
is_premium_username: premiumUsername,
|
||||
error_message: err.message,
|
||||
});
|
||||
formMethods.setError("apiError", { message: err.message });
|
||||
});
|
||||
};
|
||||
@@ -310,7 +327,7 @@ export default function Signup({
|
||||
id="gtm-init-script"
|
||||
// It is strictly not necessary to disable, but in a future update of react/no-danger this will error.
|
||||
// And we don't want it to error here anyways
|
||||
|
||||
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `(function (w, d, s, l, i) {
|
||||
w[l] = w[l] || []; w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });
|
||||
@@ -320,7 +337,7 @@ export default function Signup({
|
||||
}}
|
||||
/>
|
||||
<noscript
|
||||
|
||||
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `<iframe src="https://www.googletagmanager.com/ns.html?id=${process.env.NEXT_PUBLIC_GTM_ID}" height="0" width="0" style="display:none;visibility:hidden"></iframe>`,
|
||||
}}
|
||||
@@ -409,14 +426,14 @@ export default function Signup({
|
||||
addOnLeading={
|
||||
orgSlug
|
||||
? truncateDomain(
|
||||
`${getOrgFullOrigin(orgSlug, { protocol: true }).replace(
|
||||
URL_PROTOCOL_REGEX,
|
||||
""
|
||||
)}/`
|
||||
)
|
||||
`${getOrgFullOrigin(orgSlug, { protocol: true }).replace(
|
||||
URL_PROTOCOL_REGEX,
|
||||
""
|
||||
)}/`
|
||||
)
|
||||
: truncateDomain(
|
||||
`${process.env.NEXT_PUBLIC_WEBSITE_URL.replace(URL_PROTOCOL_REGEX, "")}/`
|
||||
)
|
||||
`${process.env.NEXT_PUBLIC_WEBSITE_URL.replace(URL_PROTOCOL_REGEX, "")}/`
|
||||
)
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
@@ -485,6 +502,13 @@ export default function Signup({
|
||||
showToast("error", t("username_required"));
|
||||
return;
|
||||
}
|
||||
|
||||
posthog.capture("signup_saml_submit_button_clicked", {
|
||||
has_token: !!token,
|
||||
is_org_invite: isOrgInviteByLink,
|
||||
org_slug: orgSlug,
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @calcom/eslint/avoid-web-storage
|
||||
localStorage.setItem("username", username);
|
||||
const sp = new URLSearchParams();
|
||||
@@ -538,15 +562,24 @@ export default function Signup({
|
||||
color="primary"
|
||||
loading={isGoogleLoading}
|
||||
CustomStartIcon={
|
||||
<img
|
||||
className={classNames("text-subtle mr-2 h-4 w-4", premiumUsername && "opacity-50")}
|
||||
src="/google-icon-colored.svg"
|
||||
alt="Continue with Google Icon"
|
||||
/>
|
||||
<>
|
||||
{/* eslint-disable @next/next/no-img-element */}
|
||||
<img
|
||||
className={classNames("text-subtle mr-2 h-4 w-4", premiumUsername && "opacity-50")}
|
||||
src="/google-icon-colored.svg"
|
||||
alt="Continue with Google Icon"
|
||||
/>
|
||||
</>
|
||||
}
|
||||
className={classNames("w-full justify-center rounded-md text-center")}
|
||||
data-testid="continue-with-google-button"
|
||||
onClick={async () => {
|
||||
posthog.capture("signup_google_button_clicked", {
|
||||
has_token: !!token,
|
||||
is_org_invite: isOrgInviteByLink,
|
||||
org_slug: orgSlug,
|
||||
has_prepopulated_username: !!prepopulateFormValues?.username,
|
||||
});
|
||||
setIsSamlSignup(false);
|
||||
setIsGoogleLoading(true);
|
||||
const baseUrl = process.env.NEXT_PUBLIC_WEBAPP_URL;
|
||||
@@ -591,6 +624,11 @@ export default function Signup({
|
||||
disabled={isGoogleLoading}
|
||||
className={classNames("w-full justify-center rounded-md text-center")}
|
||||
onClick={() => {
|
||||
posthog.capture("signup_email_button_clicked", {
|
||||
has_token: !!token,
|
||||
is_org_invite: isOrgInviteByLink,
|
||||
org_slug: orgSlug,
|
||||
});
|
||||
setDisplayEmailForm(true);
|
||||
setIsSamlSignup(false);
|
||||
}}
|
||||
@@ -604,6 +642,11 @@ export default function Signup({
|
||||
disabled={isGoogleLoading}
|
||||
className={classNames("w-full justify-center rounded-md text-center")}
|
||||
onClick={() => {
|
||||
posthog.capture("signup_saml_button_clicked", {
|
||||
has_token: !!token,
|
||||
is_org_invite: isOrgInviteByLink,
|
||||
org_slug: orgSlug,
|
||||
});
|
||||
setDisplayEmailForm(true);
|
||||
setIsSamlSignup(true);
|
||||
}}>
|
||||
@@ -653,6 +696,7 @@ export default function Signup({
|
||||
<>
|
||||
<div className="-mt-4 mb-6 mr-12 grid w-full grid-cols-3 gap-5 pr-4 sm:gap-3 lg:grid-cols-4">
|
||||
<div>
|
||||
{/* eslint-disable @next/next/no-img-element */}
|
||||
<img
|
||||
src="/product-cards/product-of-the-day.svg"
|
||||
className="h-[34px] w-full dark:invert"
|
||||
@@ -660,6 +704,7 @@ export default function Signup({
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
{/* eslint-disable @next/next/no-img-element */}
|
||||
<img
|
||||
src="/product-cards/product-of-the-week.svg"
|
||||
className="h-[34px] w-full dark:invert"
|
||||
@@ -667,6 +712,7 @@ export default function Signup({
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
{/* eslint-disable @next/next/no-img-element */}
|
||||
<img
|
||||
src="/product-cards/product-of-the-month.svg"
|
||||
className="h-[34px] w-full dark:invert"
|
||||
@@ -676,6 +722,7 @@ export default function Signup({
|
||||
</div>
|
||||
<div className="mb-6 mr-12 grid w-full grid-cols-3 gap-5 pr-4 sm:gap-3 lg:grid-cols-4">
|
||||
<div>
|
||||
{/* eslint-disable @next/next/no-img-element */}
|
||||
<img
|
||||
src="/product-cards/producthunt.svg"
|
||||
className="h-[54px] w-full"
|
||||
@@ -683,6 +730,7 @@ export default function Signup({
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
{/* eslint-disable @next/next/no-img-element */}
|
||||
<img
|
||||
src="/product-cards/google-reviews.svg"
|
||||
className="h-[54px] w-full"
|
||||
@@ -690,6 +738,7 @@ export default function Signup({
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
{/* eslint-disable @next/next/no-img-element */}
|
||||
<img
|
||||
src="/product-cards/g2.svg"
|
||||
className="h-[54px] w-full"
|
||||
@@ -701,6 +750,7 @@ export default function Signup({
|
||||
)}
|
||||
<div className="border-default hidden rounded-bl-2xl rounded-br-none rounded-tl-2xl border border-r-0 border-dashed bg-black/3 dark:bg-white/5 lg:block lg:py-[6px] lg:pl-[6px]">
|
||||
<img className="block dark:hidden" src="/mock-event-type-list.svg" alt="Cal.com Booking Page" />
|
||||
{/* eslint-disable @next/next/no-img-element */}
|
||||
<img
|
||||
className="hidden dark:block"
|
||||
src="/mock-event-type-list-dark.svg"
|
||||
|
||||
Reference in new issue
Block a user