diff --git a/apps/web/components/getting-started/steps-views/UserProfile.tsx b/apps/web/components/getting-started/steps-views/UserProfile.tsx index 74de82d55c..cd2abba87b 100644 --- a/apps/web/components/getting-started/steps-views/UserProfile.tsx +++ b/apps/web/components/getting-started/steps-views/UserProfile.tsx @@ -5,6 +5,7 @@ import { FormEvent, useRef, useState } from "react"; import { useForm } from "react-hook-form"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry"; import turndown from "@calcom/lib/turndownService"; import { trpc } from "@calcom/trpc/react"; import { Button, Editor, ImageUploader, Label, showToast } from "@calcom/ui"; @@ -34,6 +35,7 @@ const UserProfile = (props: IUserProfileProps) => { const utils = trpc.useContext(); const router = useRouter(); const createEventType = trpc.viewer.eventTypes.create.useMutation(); + const telemetry = useTelemetry(); const mutation = trpc.viewer.updateProfile.useMutation({ onSuccess: async (_data, context) => { @@ -64,6 +66,8 @@ const UserProfile = (props: IUserProfileProps) => { const onSubmit = handleSubmit((data: { bio: string }) => { const { bio } = data; + telemetry.event(telemetryEventTypes.onboardingFinished); + mutation.mutate({ bio, completedOnboarding: true, diff --git a/apps/web/components/getting-started/steps-views/UserSettings.tsx b/apps/web/components/getting-started/steps-views/UserSettings.tsx index ab4acce211..6a0ab4a5ef 100644 --- a/apps/web/components/getting-started/steps-views/UserSettings.tsx +++ b/apps/web/components/getting-started/steps-views/UserSettings.tsx @@ -1,9 +1,10 @@ import { ArrowRightIcon } from "@heroicons/react/outline"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { useForm } from "react-hook-form"; import dayjs from "@calcom/dayjs"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry"; import { trpc } from "@calcom/trpc/react"; import { Button, TimezoneSelect } from "@calcom/ui"; @@ -20,7 +21,7 @@ const UserSettings = (props: IUserSettingsProps) => { const { user, nextStep } = props; const { t } = useLocale(); const [selectedTimeZone, setSelectedTimeZone] = useState(dayjs.tz.guess()); - + const telemetry = useTelemetry(); const { register, handleSubmit, @@ -31,6 +32,11 @@ const UserSettings = (props: IUserSettingsProps) => { }, reValidateMode: "onChange", }); + + useEffect(() => { + telemetry.event(telemetryEventTypes.onboardingStarted); + }, [telemetry]); + const defaultOptions = { required: true, maxLength: 255 }; const utils = trpc.useContext(); diff --git a/apps/web/pages/auth/login.tsx b/apps/web/pages/auth/login.tsx index 0304b3d3a3..c9876f1800 100644 --- a/apps/web/pages/auth/login.tsx +++ b/apps/web/pages/auth/login.tsx @@ -182,8 +182,6 @@ export default function Login({ StartIcon={FaGoogle} onClick={async (e) => { e.preventDefault(); - // track Google logins. Without personal data/payload - telemetry.event(telemetryEventTypes.googleLogin, collectPageParameters()); await signIn("google"); }}> {t("signin_with_google")} diff --git a/apps/web/pages/signup.tsx b/apps/web/pages/signup.tsx index 7d574e2fa5..0fca86f626 100644 --- a/apps/web/pages/signup.tsx +++ b/apps/web/pages/signup.tsx @@ -56,7 +56,7 @@ export default function Signup({ prepopulateFormValues }: inferSSRProps { - telemetry.event(telemetryEventTypes.login, collectPageParameters()); + telemetry.event(telemetryEventTypes.signup, collectPageParameters()); await signIn<"credentials">("credentials", { ...data, callbackUrl: router.query.callbackUrl diff --git a/packages/features/auth/SAMLLogin.tsx b/packages/features/auth/SAMLLogin.tsx index 28405d0786..5d34f5f2ea 100644 --- a/packages/features/auth/SAMLLogin.tsx +++ b/packages/features/auth/SAMLLogin.tsx @@ -5,7 +5,6 @@ import z from "zod"; import { HOSTED_CAL_FEATURES } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; -import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry"; import { trpc } from "@calcom/trpc/react"; import { Button } from "@calcom/ui"; import { FiLock } from "@calcom/ui/components/icon"; @@ -23,7 +22,6 @@ const schema = z.object({ export function SAMLLogin({ samlTenantID, samlProductID, setErrorMessage }: Props) { const { t } = useLocale(); const methods = useFormContext(); - const telemetry = useTelemetry(); const mutation = trpc.viewer.public.samlTenantProduct.useMutation({ onSuccess: async (data) => { @@ -43,9 +41,6 @@ export function SAMLLogin({ samlTenantID, samlProductID, setErrorMessage }: Prop onClick={async (event) => { event.preventDefault(); - // track Google logins. Without personal data/payload - telemetry.event(telemetryEventTypes.googleLogin, collectPageParameters()); - if (!HOSTED_CAL_FEATURES) { await signIn("saml", {}, { tenant: samlTenantID, product: samlProductID }); return; diff --git a/packages/features/ee/sso/components/OIDCConnection.tsx b/packages/features/ee/sso/components/OIDCConnection.tsx index c31d17150a..9a8a05a057 100644 --- a/packages/features/ee/sso/components/OIDCConnection.tsx +++ b/packages/features/ee/sso/components/OIDCConnection.tsx @@ -3,7 +3,6 @@ import { Controller, useForm } from "react-hook-form"; import type { SSOConnection } from "@calcom/ee/sso/lib/saml"; import { useLocale } from "@calcom/lib/hooks/useLocale"; -import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry"; import { trpc } from "@calcom/trpc/react"; import { Button, DialogFooter, Form, showToast, TextField, Dialog, DialogContent } from "@calcom/ui"; @@ -56,12 +55,10 @@ const CreateConnectionDialog = ({ }) => { const { t } = useLocale(); const utils = trpc.useContext(); - const telemetry = useTelemetry(); const form = useForm(); const mutation = trpc.viewer.saml.updateOIDC.useMutation({ async onSuccess() { - telemetry.event(telemetryEventTypes.samlConfig, collectPageParameters()); showToast( t("sso_connection_created_successfully", { connectionType: "OIDC", diff --git a/packages/features/ee/sso/components/SAMLConnection.tsx b/packages/features/ee/sso/components/SAMLConnection.tsx index 50c26a8bc9..dcfdcf57b1 100644 --- a/packages/features/ee/sso/components/SAMLConnection.tsx +++ b/packages/features/ee/sso/components/SAMLConnection.tsx @@ -3,7 +3,6 @@ import { Controller, useForm } from "react-hook-form"; import type { SSOConnection } from "@calcom/ee/sso/lib/saml"; import { useLocale } from "@calcom/lib/hooks/useLocale"; -import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry"; import { trpc } from "@calcom/trpc/react"; import { Button, DialogFooter, Form, showToast, TextArea, Dialog, DialogContent } from "@calcom/ui"; @@ -54,12 +53,10 @@ const CreateConnectionDialog = ({ }) => { const { t } = useLocale(); const utils = trpc.useContext(); - const telemetry = useTelemetry(); const form = useForm(); const mutation = trpc.viewer.saml.update.useMutation({ async onSuccess() { - telemetry.event(telemetryEventTypes.samlConfig, collectPageParameters()); showToast( t("sso_connection_created_successfully", { connectionType: "SAML", diff --git a/packages/features/ee/teams/components/CreateANewTeamForm.tsx b/packages/features/ee/teams/components/CreateANewTeamForm.tsx index f2e2327cf6..c02c56fb7f 100644 --- a/packages/features/ee/teams/components/CreateANewTeamForm.tsx +++ b/packages/features/ee/teams/components/CreateANewTeamForm.tsx @@ -5,6 +5,7 @@ import { z } from "zod"; import { getSafeRedirectUrl } from "@calcom/lib/getSafeRedirectUrl"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import slugify from "@calcom/lib/slugify"; +import { telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry"; import { trpc } from "@calcom/trpc/react"; import { Avatar, Button, Form, ImageUploader, TextField } from "@calcom/ui"; import { FiArrowRight } from "@calcom/ui/components/icon"; @@ -18,7 +19,7 @@ const querySchema = z.object({ export const CreateANewTeamForm = () => { const { t } = useLocale(); const router = useRouter(); - + const telemetry = useTelemetry(); const returnToParsed = querySchema.safeParse(router.query); const returnToParam = @@ -29,6 +30,7 @@ export const CreateANewTeamForm = () => { const createTeamMutation = trpc.viewer.teams.create.useMutation({ onSuccess: (data) => { + telemetry.event(telemetryEventTypes.team_created); router.push(`/settings/teams/${data.id}/onboard-members`); }, }); diff --git a/packages/lib/telemetry.ts b/packages/lib/telemetry.ts index 6f42de6a9e..a41165c753 100644 --- a/packages/lib/telemetry.ts +++ b/packages/lib/telemetry.ts @@ -12,12 +12,16 @@ export const telemetryEventTypes = { bookingConfirmed: "booking_confirmed", bookingCancelled: "booking_cancelled", importSubmitted: "import_submitted", - googleLogin: "google_login", login: "login", - samlLogin: "saml_login", - samlConfig: "saml_config", embedView: "embed_view", embedBookingConfirmed: "embed_booking_confirmed", + onboardingFinished: "onboarding_finished", + onboardingStarted: "onboarding_started", + signup: "signup", + team_created: "team_created", + website: { + pageView: "website_page_view", + }, }; export function collectPageParameters(