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
@@ -1,5 +1,6 @@
|
||||
import { useAutoAnimate } from "@formkit/auto-animate/react";
|
||||
import Link from "next/link";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { useAppContextWithSchema } from "@calcom/app-store/EventTypeAppContext";
|
||||
import { useIsPlatform } from "@calcom/atoms/hooks/useIsPlatform";
|
||||
@@ -15,7 +16,6 @@ import OmniInstallAppButton from "./OmniInstallAppButton";
|
||||
|
||||
export default function AppCard({
|
||||
app,
|
||||
description,
|
||||
switchOnClick,
|
||||
switchChecked,
|
||||
children,
|
||||
@@ -97,6 +97,10 @@ export default function AppCard({
|
||||
size="sm"
|
||||
disabled={!app.enabled || managedDisabled || disableSwitch}
|
||||
onCheckedChange={(enabled) => {
|
||||
posthog.capture("event_type_app_switch_toggled", {
|
||||
app_slug: app.slug,
|
||||
enabled: enabled,
|
||||
});
|
||||
if (switchOnClick) {
|
||||
switchOnClick(enabled);
|
||||
}
|
||||
@@ -123,27 +127,27 @@ export default function AppCard({
|
||||
{hideAppCardOptions
|
||||
? null
|
||||
: app?.isInstalled &&
|
||||
switchChecked && (
|
||||
<div ref={animationRef}>
|
||||
{app.isSetupAlready === undefined || app.isSetupAlready ? (
|
||||
<div className="relative text-sm [&_input]:mb-0 [&_input]:leading-4">
|
||||
{!hideSettingsIcon && !isPlatform && (
|
||||
<Link href={`/apps/${app.slug}/setup`} className="absolute right-4 top-4">
|
||||
<Icon name="settings" className="text-default h-4 w-4" aria-hidden="true" />
|
||||
</Link>
|
||||
)}
|
||||
{children}
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex h-64 w-full flex-col items-center justify-center gap-4 ">
|
||||
<p>{t("this_app_is_not_setup_already")}</p>
|
||||
<Link href={`/apps/${app.slug}/setup`}>
|
||||
<Button StartIcon="settings">{t("setup")}</Button>
|
||||
switchChecked && (
|
||||
<div ref={animationRef}>
|
||||
{app.isSetupAlready === undefined || app.isSetupAlready ? (
|
||||
<div className="relative text-sm [&_input]:mb-0 [&_input]:leading-4">
|
||||
{!hideSettingsIcon && !isPlatform && (
|
||||
<Link href={`/apps/${app.slug}/setup`} className="absolute right-4 top-4">
|
||||
<Icon name="settings" className="text-default h-4 w-4" aria-hidden="true" />
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
)}
|
||||
{children}
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex h-64 w-full flex-col items-center justify-center gap-4 ">
|
||||
<p>{t("this_app_is_not_setup_already")}</p>
|
||||
<Link href={`/apps/${app.slug}/setup`}>
|
||||
<Button StartIcon="settings">{t("setup")}</Button>
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</Section>
|
||||
);
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
} from "./testUtils";
|
||||
|
||||
function todo(title: string) {
|
||||
// eslint-disable-next-line playwright/no-skipped-test, @typescript-eslint/no-empty-function
|
||||
// eslint-disable-next-line playwright/no-skipped-test
|
||||
test.skip(title, () => {});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { InstallAppButton } from "@calcom/app-store/InstallAppButton";
|
||||
import { isRedirectApp } from "@calcom/app-store/_utils/redirectApps";
|
||||
@@ -58,6 +59,13 @@ export function AppCard({ app, credentials, searchText, userAdminTeams }: AppCar
|
||||
}, [app.name, searchText]);
|
||||
|
||||
const handleAppInstall = () => {
|
||||
posthog.capture("app_install_button_clicked", {
|
||||
slug: app.slug,
|
||||
app_type: app.type,
|
||||
is_redirect: isRedirectApp(app.slug),
|
||||
is_conferencing: isConferencing(app.categories || []),
|
||||
});
|
||||
|
||||
if (isRedirectApp(app.slug)) {
|
||||
// For redirect apps, open the external URL directly
|
||||
if (app.url) window.open(app.url, "_blank", "noopener,noreferrer");
|
||||
@@ -135,58 +143,87 @@ export function AppCard({ app, credentials, searchText, userAdminTeams }: AppCar
|
||||
color="secondary"
|
||||
className="flex w-32 grow justify-center"
|
||||
href={`/apps/${app.slug}`}
|
||||
onClick={() => { posthog.capture("app_card_details_clicked", { slug: app.slug }) }}
|
||||
data-testid={`app-store-app-card-${app.slug}`}>
|
||||
{t("details")}
|
||||
</Button>
|
||||
{app.isGlobal ||
|
||||
(credentials && credentials.length > 0 && allowedMultipleInstalls) ||
|
||||
(credentials && credentials.length > 0 && isRedirectApp(app.slug))
|
||||
(credentials && credentials.length > 0 && allowedMultipleInstalls) ||
|
||||
(credentials && credentials.length > 0 && isRedirectApp(app.slug))
|
||||
? !app.isGlobal && (
|
||||
<InstallAppButton
|
||||
type={app.type}
|
||||
teamsPlanRequired={app.teamsPlanRequired}
|
||||
disableInstall={!!app.dependencies && !app.dependencyData?.some((data) => !data.installed)}
|
||||
wrapperClassName="[@media(max-width:260px)]:w-full"
|
||||
render={({ useDefaultComponent, ...props }) => {
|
||||
if (useDefaultComponent) {
|
||||
props = {
|
||||
...props,
|
||||
onClick: () => {
|
||||
handleAppInstall();
|
||||
},
|
||||
loading: mutation.isPending,
|
||||
};
|
||||
}
|
||||
return (
|
||||
<InstallAppButtonChild paid={app.paid} isRedirect={isRedirectApp(app.slug)} {...props} />
|
||||
);
|
||||
}}
|
||||
/>
|
||||
)
|
||||
<InstallAppButton
|
||||
type={app.type}
|
||||
teamsPlanRequired={app.teamsPlanRequired}
|
||||
disableInstall={!!app.dependencies && !app.dependencyData?.some((data) => !data.installed)}
|
||||
wrapperClassName="[@media(max-width:260px)]:w-full"
|
||||
render={({ useDefaultComponent, ...props }) => {
|
||||
if (useDefaultComponent) {
|
||||
props = {
|
||||
...props,
|
||||
onClick: () => {
|
||||
handleAppInstall();
|
||||
},
|
||||
loading: mutation.isPending,
|
||||
};
|
||||
} else {
|
||||
const originalOnClick = props.onClick;
|
||||
props = {
|
||||
...props,
|
||||
onClick: (e) => {
|
||||
posthog.capture("app_install_button_clicked", {
|
||||
slug: app.slug,
|
||||
app_type: app.type,
|
||||
is_redirect: isRedirectApp(app.slug),
|
||||
is_conferencing: isConferencing(app.categories || []),
|
||||
});
|
||||
originalOnClick?.(e);
|
||||
},
|
||||
};
|
||||
}
|
||||
return (
|
||||
<InstallAppButtonChild paid={app.paid} isRedirect={isRedirectApp(app.slug)} {...props} />
|
||||
);
|
||||
}}
|
||||
/>
|
||||
)
|
||||
: credentials &&
|
||||
!appInstalled && (
|
||||
<InstallAppButton
|
||||
type={app.type}
|
||||
wrapperClassName="[@media(max-width:260px)]:w-full"
|
||||
disableInstall={!!app.dependencies && app.dependencyData?.some((data) => !data.installed)}
|
||||
teamsPlanRequired={app.teamsPlanRequired}
|
||||
render={({ useDefaultComponent, ...props }) => {
|
||||
if (useDefaultComponent) {
|
||||
props = {
|
||||
...props,
|
||||
disabled: !!props.disabled,
|
||||
onClick: () => {
|
||||
handleAppInstall();
|
||||
},
|
||||
loading: mutation.isPending,
|
||||
};
|
||||
}
|
||||
return (
|
||||
<InstallAppButtonChild paid={app.paid} isRedirect={isRedirectApp(app.slug)} {...props} />
|
||||
);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
!appInstalled && (
|
||||
<InstallAppButton
|
||||
type={app.type}
|
||||
wrapperClassName="[@media(max-width:260px)]:w-full"
|
||||
disableInstall={!!app.dependencies && app.dependencyData?.some((data) => !data.installed)}
|
||||
teamsPlanRequired={app.teamsPlanRequired}
|
||||
render={({ useDefaultComponent, ...props }) => {
|
||||
if (useDefaultComponent) {
|
||||
props = {
|
||||
...props,
|
||||
disabled: !!props.disabled,
|
||||
onClick: () => {
|
||||
handleAppInstall();
|
||||
},
|
||||
loading: mutation.isPending,
|
||||
};
|
||||
} else {
|
||||
const originalOnClick = props.onClick;
|
||||
props = {
|
||||
...props,
|
||||
onClick: (e) => {
|
||||
posthog.capture("app_install_button_clicked", {
|
||||
slug: app.slug,
|
||||
app_type: app.type,
|
||||
is_redirect: isRedirectApp(app.slug),
|
||||
is_conferencing: isConferencing(app.categories || []),
|
||||
});
|
||||
originalOnClick?.(e);
|
||||
},
|
||||
};
|
||||
}
|
||||
return (
|
||||
<InstallAppButtonChild paid={app.paid} isRedirect={isRedirectApp(app.slug)} {...props} />
|
||||
);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className="max-w-44 absolute right-0 mr-4 flex flex-wrap justify-end gap-1">
|
||||
{appAdded > 0 && !isRedirectApp(app.slug) ? (
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
@@ -171,6 +172,7 @@ export function SaveFilterSegmentButton() {
|
||||
<Button
|
||||
StartIcon="bookmark"
|
||||
color="secondary"
|
||||
onClick={() => posthog.capture("insights_routing_save_filter_clicked")}
|
||||
disabled={!canSaveSegment}
|
||||
data-testid="save-filter-segment-button">
|
||||
{t("save")}
|
||||
|
||||
@@ -4,29 +4,35 @@ import posthog from "posthog-js";
|
||||
import { PostHogProvider } from "posthog-js/react";
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
import { useGeo } from "@calcom/web/app/GeoContext";
|
||||
|
||||
function Provider({ children }: { children: React.ReactNode }) {
|
||||
const initializeOnce = useRef(false);
|
||||
const { country } = useGeo();
|
||||
|
||||
useEffect(() => {
|
||||
if (!process.env.NEXT_PUBLIC_POSTHOG_KEY || initializeOnce.current) return;
|
||||
|
||||
initializeOnce.current = true;
|
||||
|
||||
const isUS = country === "US";
|
||||
|
||||
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
|
||||
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST || "https://us.i.posthog.com",
|
||||
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST || "https://eu.i.posthog.com",
|
||||
persistence: isUS ? "localStorage+cookie" : "memory",
|
||||
autocapture: false,
|
||||
person_profiles: "never",
|
||||
persistence: "memory",
|
||||
request_batching: true,
|
||||
capture_pageview: false,
|
||||
capture_pageleave: false,
|
||||
cookieless_mode: isUS ? undefined : "always",
|
||||
disable_session_recording: true,
|
||||
advanced_disable_decide: true,
|
||||
advanced_disable_flags: true,
|
||||
loaded: (posthog) => {
|
||||
if (process.env.NODE_ENV === "development") posthog.debug();
|
||||
},
|
||||
});
|
||||
}, []);
|
||||
}, [country]);
|
||||
|
||||
return <PostHogProvider client={posthog}>{children}</PostHogProvider>;
|
||||
}
|
||||
|
||||
@@ -4,11 +4,25 @@ import { usePathname, useSearchParams } from "next/navigation";
|
||||
import { usePostHog } from "posthog-js/react";
|
||||
import { useEffect } from "react";
|
||||
|
||||
const TRACKED_ROUTES = [
|
||||
"/signup",
|
||||
"/auth/verify-email",
|
||||
"/getting-started",
|
||||
"/onboarding/getting-started",
|
||||
"/settings/teams/new",
|
||||
"/settings/teams",
|
||||
];
|
||||
|
||||
export default function PostHogPageView() {
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
const posthog = usePostHog();
|
||||
|
||||
useEffect(() => {
|
||||
const shouldTrack = TRACKED_ROUTES.some(route => pathname?.startsWith(route));
|
||||
|
||||
if (!shouldTrack) return;
|
||||
|
||||
// Track pageviews
|
||||
if (pathname && posthog) {
|
||||
let url = window.origin + pathname;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import dynamic from "next/dynamic";
|
||||
|
||||
const DynamicPostHogPageView = dynamic(() => import("./PostHogPageView"), {
|
||||
ssr: false,
|
||||
});
|
||||
|
||||
export default DynamicPostHogPageView;
|
||||
@@ -4,6 +4,7 @@ import { keepPreviousData } from "@tanstack/react-query";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState, useMemo } from "react";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
|
||||
import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
|
||||
@@ -160,6 +161,11 @@ export const AddNewTeamMembersForm = ({ teamId, isOrg }: { teamId: number; isOrg
|
||||
className="w-full justify-center"
|
||||
disabled={publishTeamMutation.isPending}
|
||||
onClick={() => {
|
||||
posthog.capture("onboard_members_continue_clicked", {
|
||||
team_id: teamId,
|
||||
is_org: isOrg,
|
||||
members_count: totalFetched,
|
||||
});
|
||||
let uri = `/settings/teams/${teamId}/event-type`;
|
||||
if (isOrg) {
|
||||
uri = `/settings/organizations/${teamId}/add-teams`;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import slugify from "@calcom/lib/slugify";
|
||||
@@ -85,6 +86,10 @@ export const CreateANewTeamForm = (props: CreateANewTeamFormProps) => {
|
||||
form={newTeamFormMethods}
|
||||
handleSubmit={(v) => {
|
||||
if (!createTeamMutation.isPending) {
|
||||
posthog.capture("create_team_checkout_clicked", {
|
||||
team_name: v.name,
|
||||
team_slug: v.slug,
|
||||
});
|
||||
setServerErrorMessage(null);
|
||||
createTeamMutation.mutate(v);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useSession } from "next-auth/react";
|
||||
import type { FormEvent } from "react";
|
||||
import { useMemo, useRef, useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import TeamInviteFromOrg from "@calcom/ee/organizations/components/TeamInviteFromOrg";
|
||||
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
|
||||
@@ -90,7 +91,7 @@ export default function MemberInvitationModal(props: MemberInvitationModalProps)
|
||||
);
|
||||
|
||||
const createInviteMutation = trpc.viewer.teams.createInvite.useMutation({
|
||||
async onSuccess({ inviteLink }) {
|
||||
async onSuccess() {
|
||||
trpcContext.viewer.teams.get.invalidate();
|
||||
trpcContext.viewer.teams.list.invalidate();
|
||||
revalidateTeamsList();
|
||||
@@ -235,8 +236,8 @@ export default function MemberInvitationModal(props: MemberInvitationModalProps)
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Form form={newMemberFormMethods} handleSubmit={(values) => props.onSubmit(values, resetFields)}>
|
||||
<div className="mb-10 mt-6 stack-y-6">
|
||||
<Form form={newMemberFormMethods} handleSubmit={(values) => { props.onSubmit(values, resetFields); posthog.capture("teams_modal_invite_members_button_clicked") }}>
|
||||
<div className="mb-10 mt-6 space-y-6">
|
||||
{/* Individual Invite */}
|
||||
{modalImportMode === "INDIVIDUAL" && (
|
||||
<Controller
|
||||
@@ -388,7 +389,9 @@ export default function MemberInvitationModal(props: MemberInvitationModalProps)
|
||||
color="minimal"
|
||||
className="me-2 ms-2"
|
||||
onClick={() => {
|
||||
props.onSettingsOpen && props.onSettingsOpen();
|
||||
if (props.onSettingsOpen) {
|
||||
props.onSettingsOpen();
|
||||
}
|
||||
newMemberFormMethods.reset();
|
||||
}}
|
||||
data-testid="edit-invite-link-button">
|
||||
@@ -410,6 +413,7 @@ export default function MemberInvitationModal(props: MemberInvitationModalProps)
|
||||
// Credits to https://wolfgangrittner.dev/how-to-use-clipboard-api-in-firefox/
|
||||
if (typeof ClipboardItem !== "undefined") {
|
||||
const inviteLinkClipbardItem = new ClipboardItem({
|
||||
//eslint-disable-next-line no-async-promise-executor
|
||||
"text/plain": new Promise(async (resolve) => {
|
||||
// Instead of doing async work and then writing to clipboard, do async work in clipboard API itself
|
||||
const { inviteLink } = await createInviteMutation.mutateAsync({
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
} from "@tanstack/react-table";
|
||||
import classNames from "classnames";
|
||||
import { useSession } from "next-auth/react";
|
||||
import posthog from "posthog-js";
|
||||
import { signIn } from "next-auth/react";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useQueryState, parseAsBoolean } from "nuqs";
|
||||
@@ -726,7 +727,7 @@ function MemberListContent(props: Props) {
|
||||
type="button"
|
||||
color="primary"
|
||||
StartIcon="plus"
|
||||
onClick={() => props.setShowMemberInvitationModal(true)}
|
||||
onClick={() => { props.setShowMemberInvitationModal(true); posthog.capture("teams_add_new_members_button_clicked") }}
|
||||
data-testid="new-member-button">
|
||||
{t("add")}
|
||||
</DataTableToolbar.CTA>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { HttpError } from "@calcom/lib/http-error";
|
||||
@@ -182,6 +183,7 @@ export function useWorkflowCreation() {
|
||||
const openDialog = (teamId?: number) => {
|
||||
setPendingTeamId(teamId);
|
||||
setShowDialog(true);
|
||||
posthog.capture("create_new_workflow_button_clicked", { teamId });
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
+4
@@ -1,3 +1,5 @@
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { CAL_AI_PHONE_NUMBER_MONTHLY_PRICE } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
@@ -26,6 +28,7 @@ export function BuyNumberDialog({ open, onOpenChange, agentId, workflowId, teamI
|
||||
window.location.href = data.checkoutUrl;
|
||||
} else if (data.phoneNumber) {
|
||||
showToast(t("phone_number_purchased_successfully"), "success");
|
||||
posthog.capture("calai_phone_number_purchased");
|
||||
await utils.viewer.me.get.invalidate();
|
||||
onOpenChange(false);
|
||||
if (agentId) {
|
||||
@@ -116,6 +119,7 @@ export function BuyNumberDialog({ open, onOpenChange, agentId, workflowId, teamI
|
||||
if (!agentId || !workflowId) {
|
||||
return;
|
||||
}
|
||||
posthog.capture("calai_buy_number_button_clicked", { agentId, workflowId, teamId });
|
||||
buyNumberMutation.mutate({
|
||||
agentId: agentId,
|
||||
workflowId: workflowId,
|
||||
|
||||
+2
@@ -1,3 +1,4 @@
|
||||
import posthog from "posthog-js";
|
||||
import { useState } from "react";
|
||||
import type { UseFormReturn } from "react-hook-form";
|
||||
|
||||
@@ -286,6 +287,7 @@ export function PhoneNumberTab({
|
||||
<Button
|
||||
onClick={() => {
|
||||
if (readOnly) return;
|
||||
posthog.capture("calai_buy_number_modal_opened");
|
||||
setIsBuyDialogOpen(true);
|
||||
}}
|
||||
StartIcon="external-link"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import type { TFunction } from "i18next";
|
||||
import { useQueryState } from "nuqs";
|
||||
import { type ReactNode, useMemo, useRef, useState } from "react";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { DataTableSkeleton } from "@calcom/features/data-table";
|
||||
import { downloadAsCsv } from "@calcom/lib/csvUtils";
|
||||
@@ -43,6 +44,7 @@ function DownloadButton({ selectedPeriod, searchQuery }: DownloadButtonProps) {
|
||||
e.preventDefault(); // Prevent default form submission
|
||||
|
||||
try {
|
||||
posthog.capture("insights_routing_download_clicked", { teamId: routingParams.selectedTeamId });
|
||||
const result = await utils.viewer.insights.routedToPerPeriodCsv.fetch({
|
||||
...routingParams,
|
||||
period: selectedPeriod,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useState } from "react";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { downloadAsCsv } from "@calcom/lib/csvUtils";
|
||||
@@ -45,13 +46,14 @@ const Download = () => {
|
||||
return result as PaginatedResponse;
|
||||
}
|
||||
return null;
|
||||
} catch (error) {
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const handleDownloadClick = async () => {
|
||||
try {
|
||||
posthog.capture("insights_bookings_download_clicked", { teamId: insightsBookingParams.selectedTeamId });
|
||||
setIsDownloading(true);
|
||||
showProgressToast(0);
|
||||
let allData: RawData[] = [];
|
||||
@@ -82,7 +84,7 @@ const Download = () => {
|
||||
)}.csv`;
|
||||
downloadAsCsv(allData as Record<string, unknown>[], filename);
|
||||
}
|
||||
} catch (error) {
|
||||
} catch {
|
||||
showToast(t("unexpected_error_try_again"), "error");
|
||||
} finally {
|
||||
setIsDownloading(false);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import Link from "next/link";
|
||||
import { usePathname, useSearchParams } from "next/navigation";
|
||||
import React, { Fragment, useState, useEffect, useRef } from "react";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import useMediaQuery from "@calcom/lib/hooks/useMediaQuery";
|
||||
@@ -55,6 +56,13 @@ const useBuildHref = () => {
|
||||
return buildHref;
|
||||
};
|
||||
|
||||
const trackNavigationClick = (itemName: string, parentItemName?: string) => {
|
||||
posthog.capture("navigation_item_clicked", {
|
||||
item_name: itemName,
|
||||
parent_name: parentItemName,
|
||||
});
|
||||
};
|
||||
|
||||
export type NavigationItemType = {
|
||||
name: string;
|
||||
href: string;
|
||||
@@ -133,7 +141,10 @@ export const NavigationItem: React.FC<{
|
||||
key={childItem.name}
|
||||
href={buildHref(childItem)}
|
||||
aria-current={childIsCurrent ? "page" : undefined}
|
||||
onClick={() => setIsTooltipOpen(false)}
|
||||
onClick={() => {
|
||||
setIsTooltipOpen(false);
|
||||
trackNavigationClick(childItem.name, item.name);
|
||||
}}
|
||||
className={classNames(
|
||||
"group relative block rounded-md px-3 py-1 text-sm font-medium",
|
||||
childIsCurrent
|
||||
@@ -199,6 +210,7 @@ export const NavigationItem: React.FC<{
|
||||
<Tooltip side="right" content={t(item.name)} className="lg:hidden">
|
||||
<Link
|
||||
data-test-id={item.name}
|
||||
onClick={() => trackNavigationClick(item.name)}
|
||||
href={isChild ? buildHref(item) : item.href}
|
||||
aria-label={t(item.name)}
|
||||
target={item.target}
|
||||
@@ -208,9 +220,8 @@ export const NavigationItem: React.FC<{
|
||||
? `aria-[aria-current='page']:bg-transparent!`
|
||||
: `[&[aria-current='page']]:bg-emphasis`,
|
||||
isChild
|
||||
? `[&[aria-current='page']]:text-emphasis [&[aria-current='page']]:bg-emphasis hidden h-8 pl-16 lg:flex lg:pl-11 ${
|
||||
props.index === 0 ? "mt-0" : "mt-px"
|
||||
}`
|
||||
? `[&[aria-current='page']]:text-emphasis [&[aria-current='page']]:bg-emphasis hidden h-8 pl-16 lg:flex lg:pl-11 ${props.index === 0 ? "mt-0" : "mt-px"
|
||||
}`
|
||||
: "[&[aria-current='page']]:text-emphasis mt-0.5 text-sm",
|
||||
isLocaleReady
|
||||
? "hover:bg-subtle todesktop:[&[aria-current='page']]:bg-emphasis todesktop:hover:bg-transparent hover:text-emphasis"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { User as UserAuth } from "next-auth";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { useHasActiveTeamPlanAsOwner } from "@calcom/features/billing/hooks/useHasPaidPlan";
|
||||
import { IS_DUB_REFERRALS_ENABLED } from "@calcom/lib/constants";
|
||||
@@ -37,15 +38,15 @@ export function useBottomNavItems({
|
||||
// Render above to prevent layout shift as much as possible
|
||||
isTrial
|
||||
? {
|
||||
name: "skip_trial",
|
||||
href: "",
|
||||
isLoading: skipTeamTrialsMutation.isPending,
|
||||
icon: "clock",
|
||||
onClick: (e: { preventDefault: () => void }) => {
|
||||
e.preventDefault();
|
||||
skipTeamTrialsMutation.mutate({});
|
||||
},
|
||||
}
|
||||
name: "skip_trial",
|
||||
href: "",
|
||||
isLoading: skipTeamTrialsMutation.isPending,
|
||||
icon: "clock",
|
||||
onClick: (e: { preventDefault: () => void }) => {
|
||||
e.preventDefault();
|
||||
skipTeamTrialsMutation.mutate({});
|
||||
},
|
||||
}
|
||||
: null,
|
||||
{
|
||||
name: "view_public_page",
|
||||
@@ -65,18 +66,21 @@ export function useBottomNavItems({
|
||||
},
|
||||
IS_DUB_REFERRALS_ENABLED
|
||||
? {
|
||||
name: "referral_text",
|
||||
href: "/refer",
|
||||
icon: "gift",
|
||||
name: "referral_text",
|
||||
href: "/refer",
|
||||
icon: "gift",
|
||||
onClick: () => {
|
||||
posthog.capture("refer_and_earn_clicked")
|
||||
}
|
||||
}
|
||||
: null,
|
||||
|
||||
isAdmin
|
||||
? {
|
||||
name: "impersonation",
|
||||
href: "/settings/admin/impersonation",
|
||||
icon: "lock",
|
||||
}
|
||||
name: "impersonation",
|
||||
href: "/settings/admin/impersonation",
|
||||
icon: "lock",
|
||||
}
|
||||
: null,
|
||||
{
|
||||
name: "settings",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
|
||||
import shuffle from "lodash/shuffle";
|
||||
import { useState, memo } from "react";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { localStorage } from "@calcom/lib/webstorage";
|
||||
@@ -226,6 +227,13 @@ function Tips() {
|
||||
thumbnailUrl={tip.thumbnailUrl}
|
||||
coverPhoto={tip.coverPhoto}
|
||||
mediaLink={isTopTip ? tip.mediaLink : undefined}
|
||||
mediaLinkOnClick={
|
||||
isTopTip
|
||||
? () => {
|
||||
posthog.capture("tip_video_clicked", tip);
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
title={t(tip.title)}
|
||||
description={t(tip.description)}
|
||||
learnMore={
|
||||
@@ -233,11 +241,22 @@ function Tips() {
|
||||
? {
|
||||
href: tip.href,
|
||||
text: t("learn_more"),
|
||||
onClick: () => {
|
||||
posthog.capture("tip_learn_more_clicked", tip);
|
||||
},
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
actionButton={
|
||||
isTopTip ? { onClick: () => handleRemoveItem(tip.id), child: t("dismiss") } : undefined
|
||||
isTopTip
|
||||
? {
|
||||
onClick: () => {
|
||||
posthog.capture("tip_dismiss_clicked", tip);
|
||||
handleRemoveItem(tip.id);
|
||||
},
|
||||
child: t("dismiss"),
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
containerProps={{
|
||||
tabIndex: isTopTip ? undefined : -1,
|
||||
|
||||
@@ -7,6 +7,7 @@ import { usePathname } from "next/navigation";
|
||||
import { useQueryState, parseAsBoolean } from "nuqs";
|
||||
import { useMemo, useReducer, useState } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
|
||||
import {
|
||||
@@ -202,10 +203,10 @@ function UserListTableContent({
|
||||
const filterType = isNumber
|
||||
? ColumnFilterType.NUMBER
|
||||
: isText
|
||||
? ColumnFilterType.TEXT
|
||||
: isSingleSelect
|
||||
? ColumnFilterType.SINGLE_SELECT
|
||||
: ColumnFilterType.MULTI_SELECT;
|
||||
? ColumnFilterType.TEXT
|
||||
: isSingleSelect
|
||||
? ColumnFilterType.SINGLE_SELECT
|
||||
: ColumnFilterType.MULTI_SELECT;
|
||||
|
||||
return {
|
||||
id: attribute.id,
|
||||
@@ -685,14 +686,15 @@ function UserListTableContent({
|
||||
type="button"
|
||||
color="primary"
|
||||
StartIcon="plus"
|
||||
onClick={() =>
|
||||
onClick={() => {
|
||||
dispatch({
|
||||
type: "INVITE_MEMBER",
|
||||
payload: {
|
||||
showModal: true,
|
||||
},
|
||||
})
|
||||
}
|
||||
});
|
||||
posthog.capture("add_organization_member_clicked")
|
||||
}}
|
||||
data-testid="new-organization-member-button">
|
||||
{t("add")}
|
||||
</DataTableToolbar.CTA>
|
||||
|
||||
@@ -135,8 +135,10 @@ export interface BaseCardProps extends CVACardType {
|
||||
learnMore?: {
|
||||
href: string;
|
||||
text: string;
|
||||
onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void;
|
||||
};
|
||||
mediaLink?: string;
|
||||
mediaLinkOnClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void;
|
||||
thumbnailUrl?: string;
|
||||
structure?: string;
|
||||
coverPhoto?: string;
|
||||
@@ -157,6 +159,7 @@ export function Card({
|
||||
learnMore,
|
||||
coverPhoto,
|
||||
buttonClassName,
|
||||
mediaLinkOnClick,
|
||||
}: BaseCardProps) {
|
||||
const LinkComponent = learnMore && learnMore.href.startsWith("https") ? "a" : Link;
|
||||
return (
|
||||
@@ -200,7 +203,7 @@ export function Card({
|
||||
</div>
|
||||
{variant === "SidebarCard" && mediaLink && (
|
||||
<a
|
||||
onClick={actionButton?.onClick}
|
||||
onClick={mediaLinkOnClick}
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
href={mediaLink}
|
||||
@@ -253,6 +256,7 @@ export function Card({
|
||||
href={learnMore.href}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
onClick={learnMore.onClick}
|
||||
className={classNames("text-default text-xs font-medium", buttonClassName)}>
|
||||
{learnMore.text}
|
||||
</LinkComponent>
|
||||
|
||||
@@ -13,6 +13,7 @@ interface ToggleGroupProps extends Omit<RadixToggleGroup.ToggleGroupSingleProps,
|
||||
tooltip?: string;
|
||||
iconLeft?: ReactNode;
|
||||
dataTestId?: string;
|
||||
onClick?: VoidFunction;
|
||||
}[];
|
||||
isFullWidth?: boolean;
|
||||
orientation?: "horizontal" | "vertical";
|
||||
@@ -67,6 +68,7 @@ export const ToggleGroup = ({
|
||||
<OptionalTooltipWrapper key={option.value} tooltipText={option.tooltip}>
|
||||
<RadixToggleGroup.Item
|
||||
disabled={option.disabled}
|
||||
onClick={option?.onClick}
|
||||
value={option.value}
|
||||
data-testid={option.dataTestId ?? `toggle-group-item-${option.value}`}
|
||||
className={classNames(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Link from "next/link";
|
||||
import { Fragment } from "react";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { useUrlMatchesCurrentUrl } from "@calcom/lib/hooks/useUrlMatchesCurrentUrl";
|
||||
@@ -29,6 +30,8 @@ export type VerticalTabItemProps = {
|
||||
isActive?: boolean;
|
||||
isBadged?: boolean;
|
||||
"data-testid"?: string;
|
||||
//eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
trackingMetadata?: Record<string, any>;
|
||||
};
|
||||
|
||||
const VerticalTabItem = ({
|
||||
@@ -50,6 +53,9 @@ const VerticalTabItem = ({
|
||||
<>
|
||||
<Link
|
||||
onClick={(e) => {
|
||||
if (props.trackingMetadata) {
|
||||
posthog.capture("settings_sidebar_button_clicked", props.trackingMetadata);
|
||||
}
|
||||
if (props.onClick) {
|
||||
e.preventDefault();
|
||||
props.onClick(name);
|
||||
|
||||
Reference in new issue
Block a user