🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
refactor(web): Cleanup `ActionButton` component (#15390)
Ben Bachema1bafa4e88be
diff --git a/web/src/components/ActionButton.stories.tsx b/web/src/components/ActionButton.stories.tsxnew file mode 100644index 0000000000..187a15aac3--- /dev/null+++ b/web/src/components/ActionButton.stories.tsx@@ -0,0 +1,63 @@+import { PlusIcon } from "lucide-react";+import { fn } from "storybook/test";++import preview from "../../.storybook/preview";+import { ActionButton } from "./ActionButton";++const meta = preview.meta({+ component: ActionButton,+});++export const Default = meta.story({+ args: {+ children: "Create item",+ onClick: fn(),+ },+});++export const WithIcon = meta.story({+ args: {+ children: "Create item",+ icon: <PlusIcon className="h-4 w-4" aria-hidden="true" />,+ onClick: fn(),+ },+});++export const Link = meta.story({+ args: {+ children: "View details",+ href: "/",+ variant: "secondary",+ },+});++export const Loading = meta.story({+ args: {+ children: "Create item",+ loading: true,+ },+});++export const NoAccess = meta.story({+ args: {+ children: "Create item",+ hasAccess: false,+ },+});++export const NoEntitlement = meta.story({+ args: {+ children: "Create item",+ hasEntitlement: false,+ },+});++export const LimitReached = meta.story({+ args: {+ children: "Create item",+ usageLimit: {+ current: 3,+ max: 3,+ },+ },+});diff --git a/web/src/components/ActionButton.tsx b/web/src/components/ActionButton.tsxindex 665aed22af..1d40b7a5a9 100644--- a/web/src/components/ActionButton.tsx+++ b/web/src/components/ActionButton.tsx@@ -1,4 +1,4 @@-import React from "react";+import React, { useMemo } from "react";import { Lock, AlertCircle, Sparkle } from "lucide-react";import { Button, type ButtonProps } from "@/src/components/ui/button";import {@@ -10,27 +10,32 @@ import {import Link from "next/link";import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";-const BUTTON_STATE_MESSAGES = {- limitReached: (current: number, max: number) =>- `You have reached the limit (${current}/${max}) for this resource at your current plan. Upgrade your plan to increase the limit.`,- noAccess:- "You do not have access to this resource, please ask your admin to grant you access.",- entitlement: "This feature is not available in your current plan.",-} as const;--interface ActionButtonProps extends ButtonProps {+type ActionButtonProps = Pick<+ ButtonProps,+ "disabled" | "onClick" | "size" | "title" | "type" | "variant"+> & {icon?: React.ReactNode;loading?: boolean;hasAccess?: boolean;hasEntitlement?: boolean;- limitValue?: number;- limit?: number | false;+ usageLimit?: {+ current: number | undefined;+ max: number;+ };children: React.ReactNode;- className?: string;href?: string;- trackingEventName?: Parameters<ReturnType<typeof usePostHogClientCapture>>[0];- trackingProps?: Record<string, unknown>;-}+} & (+ | {+ trackingEventName?: never;+ trackingProps?: never;+ }+ | {+ trackingEventName: Parameters<+ ReturnType<typeof usePostHogClientCapture>+ >[0];+ trackingProps?: Record<string, unknown>;+ }+ );export const ActionButton = React.forwardRef<HTMLButtonElement,@@ -40,12 +45,10 @@ export const ActionButton = React.forwardRef<loading = false,hasAccess = true,hasEntitlement = true,- limitValue,- limit = false,+ usageLimit,disabled = false,children,icon,- className,href,trackingEventName,trackingProps,@@ -54,33 +57,42 @@ export const ActionButton = React.forwardRef<ref,) {const capture = usePostHogClientCapture();+const hasReachedLimit =- typeof limit === "number" &&- limitValue !== undefined &&- limitValue >= limit;+ usageLimit?.current !== undefined && usageLimit.current >= usageLimit.max;+const isDisabled =disabled || !hasAccess || !hasEntitlement || hasReachedLimit;- const getMessage = () => {- if (!hasAccess) return BUTTON_STATE_MESSAGES.noAccess;- if (!hasEntitlement) return BUTTON_STATE_MESSAGES.entitlement;- if (- hasReachedLimit &&- typeof limit === "number" &&- limitValue !== undefined- ) {- return BUTTON_STATE_MESSAGES.limitReached(limitValue, limit);+ const usageLimitCurrent = usageLimit?.current ?? 0;+ const usageLimitMax = usageLimit?.max ?? 0;++ const disabledReason = useMemo(() => {+ if (!hasAccess) {+ return "You do not have access to this resource, please ask your admin to grant you access.";+ }+ if (!hasEntitlement) {+ return "This feature is not available in your current plan.";+ }+ if (hasReachedLimit) {+ return `You have reached the limit (${usageLimitCurrent}/${usageLimitMax}) for this resource at your current plan. Upgrade your plan to increase the limit.`;}- return null;- };- const message = getMessage();+ return null;+ }, [+ hasAccess,+ hasEntitlement,+ hasReachedLimit,+ usageLimitCurrent,+ usageLimitMax,+ ]);- // Handle click tracking for external links- const handleLinkClick = () => {- if (trackingEventName && href && isExternalUrl(href)) {+ const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {+ if (trackingEventName) {capture(trackingEventName, trackingProps ?? null);}++ buttonProps.onClick?.(event);};const btnContent = (@@ -92,16 +104,15 @@ export const ActionButton = React.forwardRef<hasAccess={hasAccess}hasEntitlement={hasEntitlement}hasReachedLimit={hasReachedLimit}- className={className}- buttonProps={buttonProps}href={href}- onLinkClick={handleLinkClick}+ {...buttonProps}+ onClick={handleClick}>{children}</ButtonContent>);- if (isDisabled && message) {+ if (isDisabled && disabledReason) {return (<HoverCard openDelay={200}><HoverCardTrigger asChild>@@ -109,7 +120,7 @@ export const ActionButton = React.forwardRef<</HoverCardTrigger><HoverCardPortal><HoverCardContent className="w-80 text-sm">- {message}+ {disabledReason}</HoverCardContent></HoverCardPortal></HoverCard>@@ -129,18 +140,15 @@ const isExternalUrl = (url: string) => {const ButtonContent = React.forwardRef<HTMLButtonElement,- {+ Pick<ButtonProps, "onClick" | "size" | "title" | "type" | "variant"> & {icon?: React.ReactNode;isDisabled: boolean;loading: boolean;hasAccess: boolean;hasEntitlement: boolean;hasReachedLimit: boolean;- className?: string;- buttonProps: Omit<ButtonProps, "disabled" | "loading" | "className">;children: React.ReactNode;href?: string;- onLinkClick?: () => void;}>(function ButtonContent({@@ -150,11 +158,9 @@ const ButtonContent = React.forwardRef<hasAccess,hasEntitlement,hasReachedLimit,- className,- buttonProps,children,href,- onLinkClick,+ ...buttonProps},ref,) {@@ -181,7 +187,6 @@ const ButtonContent = React.forwardRef<ref={ref}disabled={isDisabled}loading={loading}- className={className}{...buttonProps}asChild={renderLink ? true : undefined}>@@ -190,7 +195,6 @@ const ButtonContent = React.forwardRef<href={href}target={isExternal ? "_blank" : undefined}rel={isExternal ? "noopener noreferrer" : undefined}- onClick={onLinkClick}>{content}</Link>diff --git a/web/src/components/table/use-cases/models.tsx b/web/src/components/table/use-cases/models.tsxindex a276d71c16..2daf262a74 100644--- a/web/src/components/table/use-cases/models.tsx+++ b/web/src/components/table/use-cases/models.tsx@@ -29,7 +29,6 @@ import { usePriceUnitMultiplier } from "@/src/features/models/hooks/usePriceUnitimport { UpsertModelFormDialog } from "@/src/features/models/components/UpsertModelFormDialog";import { TestModelMatchButton } from "@/src/features/models/components/test-match/TestModelMatchButton";import { ActionButton } from "@/src/components/ActionButton";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { SettingsTableCard } from "@/src/components/layouts/settings-table-card";@@ -63,7 +62,6 @@ const modelConfigDescriptions = {export default function ModelTable({ projectId }: { projectId: string }) {const router = useRouter();- const capture = usePostHogClientCapture();const [paginationState, setPaginationState] = usePaginationState(0, 50, {page: "pageIndex",limit: "pageSize",@@ -323,7 +321,7 @@ export default function ModelTable({ projectId }: { projectId: string }) {variant="secondary"icon={<PlusIcon className="h-4 w-4" />}hasAccess={hasWriteAccess}- onClick={() => capture("models:new_form_open")}+ trackingEventName="models:new_form_open">Add Model Definition</ActionButton>diff --git a/web/src/ee/features/billing/components/BillingSwitchPlanDialog.tsx b/web/src/ee/features/billing/components/BillingSwitchPlanDialog.tsxindex b04466b1ba..a189ce7fef 100644--- a/web/src/ee/features/billing/components/BillingSwitchPlanDialog.tsx+++ b/web/src/ee/features/billing/components/BillingSwitchPlanDialog.tsx@@ -256,43 +256,47 @@ export const BillingSwitchPlanDialog = ({) : (// The default behavior when the user is not on a paid plan.<div className="mt-2 flex gap-1">- <ActionButton- onClick={() => {- if (organization) {- setProcessingPlanId(product.stripeProductId);+ <div className="grid w-full">+ <ActionButton+ onClick={() => {+ if (organization) {+ setProcessingPlanId(product.stripeProductId);- // idempotency key for mutation operations with the stripe api- let opId = _opId;- if (!opId) {- opId = nanoid();- setOpId(opId);- }+ // idempotency key for mutation operations with the stripe api+ let opId = _opId;+ if (!opId) {+ opId = nanoid();+ setOpId(opId);+ }- mutCreateCheckoutSession.mutate({- orgId: organization.id,- stripeProductId: product.stripeProductId,- opId: opId,- });+ mutCreateCheckoutSession.mutate({+ orgId: organization.id,+ stripeProductId: product.stripeProductId,+ opId: opId,+ });+ }+ }}+ disabled={+ organization?.cloudConfig?.stripe+ ?.activeProductId === product.stripeProductId+ }+ loading={+ processingPlanId === product.stripeProductId}- }}- disabled={- organization?.cloudConfig?.stripe- ?.activeProductId === product.stripeProductId- }- className="w-full"- loading={processingPlanId === product.stripeProductId}- >- {product.checkout?.cta ? "Select" : "Select plan"}- </ActionButton>- {/* Optional checkout CTA button for non-paid plan users */}- {product.checkout?.cta && (- <ActionButton- variant="secondary"- href={product.checkout.cta.href}- className="w-full">- {product.checkout.cta.label}+ {product.checkout?.cta ? "Select" : "Select plan"}</ActionButton>+ </div>+ {/* Optional checkout CTA button for non-paid plan users */}+ {product.checkout?.cta && (+ <div className="grid w-full">+ <ActionButton+ variant="secondary"+ href={product.checkout.cta.href}+ >+ {product.checkout.cta.label}+ </ActionButton>+ </div>)}</div>)}diff --git a/web/src/ee/features/billing/components/StripeSwitchPlanButton.tsx b/web/src/ee/features/billing/components/StripeSwitchPlanButton.tsxindex 100f72cc20..bcc2fbb603 100644--- a/web/src/ee/features/billing/components/StripeSwitchPlanButton.tsx+++ b/web/src/ee/features/billing/components/StripeSwitchPlanButton.tsx@@ -17,7 +17,6 @@ import { toast } from "sonner";import { nanoid } from "nanoid";export const StripeSwitchPlanButton = ({- className,orgId,currentPlan,newPlanTitle,@@ -35,7 +34,6 @@ export const StripeSwitchPlanButton = ({stripeProductId: string;onProcessing: (id: string | null) => void;processing: boolean;- className?: string;}) => {const [_opId, setOpId] = useState<string | null>(null);@@ -135,7 +133,6 @@ export const StripeSwitchPlanButton = ({mutChangePlan.mutate({ orgId, stripeProductId, opId });}}loading={processing}- className={className}>Confirm</ActionButton>diff --git a/web/src/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsx b/web/src/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsxindex 7beb5e6223..a136e6cfd0 100644--- a/web/src/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsx+++ b/web/src/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsx@@ -240,7 +240,6 @@ export const CreateOrEditAnnotationQueueButton = ({<ActionButtonvariant={variant}onClick={() => setIsOpen(true)}- className="justify-start"icon={queueId ? (<Edit className="h-4 w-4" aria-hidden="true" />@@ -249,8 +248,11 @@ export const CreateOrEditAnnotationQueueButton = ({)}hasAccess={hasQueueAccess}- limitValue={queueCountData.data}- limit={queueLimit}+ usageLimit={+ typeof queueLimit === "number"+ ? { current: queueCountData.data, max: queueLimit }+ : undefined+ }size={size}><span className="ml-1 text-sm font-normal">diff --git a/web/src/features/automations/components/AutomationButton.tsx b/web/src/features/automations/components/AutomationButton.tsxindex 087bf350d6..91adfc660d 100644--- a/web/src/features/automations/components/AutomationButton.tsx+++ b/web/src/features/automations/components/AutomationButton.tsx@@ -1,16 +1,14 @@import { ActionButton } from "@/src/components/ActionButton";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { Zap } from "lucide-react";-import { type ButtonProps } from "@/src/components/ui/button";import { api } from "@/src/utils/api";import Spinner from "@/src/components/design-system/Spinner/Spinner";-export const AutomationButton = ({- projectId,- ...buttonProps-}: {+type AutomationButtonProps = {projectId: string;-} & ButtonProps) => {+};++export const AutomationButton = ({ projectId }: AutomationButtonProps) => {const hasAccess = useHasProjectAccess({projectId,scope: "automations:read",@@ -37,7 +35,6 @@ export const AutomationButton = ({hasAccess={hasAccess}title="Automations"variant="outline"- {...buttonProps}><span className="hidden md:ml-1 md:inline">Automationsdiff --git a/web/src/features/datasets/components/NewDatasetItemButton.tsx b/web/src/features/datasets/components/NewDatasetItemButton.tsxindex 29d6cb86ff..cd14b1292c 100644--- a/web/src/features/datasets/components/NewDatasetItemButton.tsx+++ b/web/src/features/datasets/components/NewDatasetItemButton.tsx@@ -9,28 +9,24 @@ import { useState } from "react";import { NewDatasetItemForm } from "@/src/features/datasets/components/NewDatasetItemForm";import { DialogTrigger } from "@radix-ui/react-dialog";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { ActionButton } from "@/src/components/ActionButton";export const NewDatasetItemButton = (props: {projectId: string;datasetId?: string;- className?: string;}) => {const [open, setOpen] = useState(false);const hasAccess = useHasProjectAccess({projectId: props.projectId,scope: "datasets:CUD",});- const capture = usePostHogClientCapture();return (<Dialog open={hasAccess && open} onOpenChange={setOpen}><DialogTrigger asChild><ActionButtonvariant="outline"- className={props.className}hasAccess={hasAccess}- onClick={() => capture("dataset_item:new_form_open")}+ trackingEventName="dataset_item:new_form_open"icon={<PlusIcon className="h-4 w-4" aria-hidden="true" />}>New itemdiff --git a/web/src/features/datasets/components/UploadDatasetCsvButton.tsx b/web/src/features/datasets/components/UploadDatasetCsvButton.tsxindex 48a45890c8..c3dd42138b 100644--- a/web/src/features/datasets/components/UploadDatasetCsvButton.tsx+++ b/web/src/features/datasets/components/UploadDatasetCsvButton.tsx@@ -2,21 +2,18 @@ import { UploadIcon } from "lucide-react";import { DialogTrigger } from "@radix-ui/react-dialog";import { useState } from "react";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { ActionButton } from "@/src/components/ActionButton";import { CsvUploadDialog } from "@/src/features/datasets/components/CsvUploadDialog";export const UploadDatasetCsvButton = (props: {projectId: string;datasetId: string;- className?: string;}) => {const [open, setOpen] = useState(false);const hasAccess = useHasProjectAccess({projectId: props.projectId,scope: "datasets:CUD",});- const capture = usePostHogClientCapture();return (<CsvUploadDialog@@ -28,10 +25,9 @@ export const UploadDatasetCsvButton = (props: {<DialogTrigger asChild className="hidden md:flex"><ActionButtonvariant="outline"- className={props.className}disabled={!hasAccess}hasAccess={hasAccess}- onClick={() => capture("dataset_item:upload_csv_button_click")}+ trackingEventName="dataset_item:upload_csv_button_click"icon={<UploadIcon className="h-4 w-4" aria-hidden="true" />}>Upload CSVdiff --git a/web/src/features/evals/components/eval-templates-table.tsx b/web/src/features/evals/components/eval-templates-table.tsxindex c2eb3f1092..6884a49d6b 100644--- a/web/src/features/evals/components/eval-templates-table.tsx+++ b/web/src/features/evals/components/eval-templates-table.tsx@@ -475,8 +475,14 @@ export default function EvalsTemplateTable({: undefined}hasAccess={hasAccess}- limitValue={countsQuery.data?.configActiveCount ?? 0}- limit={evaluatorLimit}+ usageLimit={+ typeof evaluatorLimit === "number"+ ? {+ current: countsQuery.data?.configActiveCount ?? 0,+ max: evaluatorLimit,+ }+ : undefined+ }onClick={(e) => {e.stopPropagation();if (id) {diff --git a/web/src/features/evals/pages/evaluators.tsx b/web/src/features/evals/pages/evaluators.tsxindex d7789962f6..6228548b85 100644--- a/web/src/features/evals/pages/evaluators.tsx+++ b/web/src/features/evals/pages/evaluators.tsx@@ -3,7 +3,6 @@ import { useRouter } from "next/router";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { Plus } from "lucide-react";import EvaluatorTable from "@/src/features/evals/components/evaluator-table";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {getEvalsTabs,EVALS_TABS,@@ -19,7 +18,6 @@ import { V4MigrationModal } from "@/src/features/v4-migration/V4MigrationModal";export default function EvaluatorsPage() {const router = useRouter();const projectId = router.query.projectId as string;- const capture = usePostHogClientCapture();const evaluatorLimit = useEntitlementLimit("model-based-evaluations-count-evaluators",@@ -95,14 +93,18 @@ export default function EvaluatorsPage() {<ManageDefaultEvalModel projectId={projectId} /><ActionButtonhasAccess={hasWriteAccess}+ href={`/project/${projectId}/evals/new`}icon={<Plus className="h-4 w-4" />}+ trackingEventName="eval_config:new_form_open"variant="default"- onClick={() => {- capture("eval_config:new_form_open");- router.push(`/project/${projectId}/evals/new`);- }}- limitValue={countsQuery.data?.configActiveCount ?? 0}- limit={evaluatorLimit}+ usageLimit={+ typeof evaluatorLimit === "number"+ ? {+ current: countsQuery.data?.configActiveCount ?? 0,+ max: evaluatorLimit,+ }+ : undefined+ }>Set up evaluator</ActionButton>diff --git a/web/src/features/monitors/pages/ListMonitorsPage.tsx b/web/src/features/monitors/pages/ListMonitorsPage.tsxindex f04e4136c8..e964bc808e 100644--- a/web/src/features/monitors/pages/ListMonitorsPage.tsx+++ b/web/src/features/monitors/pages/ListMonitorsPage.tsx@@ -102,8 +102,14 @@ const MainPage = ({ projectId }: { projectId: string }) => {<ActionButtonicon={<PlusIcon className="h-4 w-4" aria-hidden="true" />}hasAccess={hasCUDAccess}- limit={monitorEntitlementLimit}- limitValue={monitorCountQuery.data?.count}+ usageLimit={+ typeof monitorEntitlementLimit === "number"+ ? {+ current: monitorCountQuery.data?.count,+ max: monitorEntitlementLimit,+ }+ : undefined+ }href={`/project/${projectId}/monitors/new`}variant="default">diff --git a/web/src/features/notifications/SuccessNotification.tsx b/web/src/features/notifications/SuccessNotification.tsxindex 51587c9765..41617db858 100644--- a/web/src/features/notifications/SuccessNotification.tsx+++ b/web/src/features/notifications/SuccessNotification.tsx@@ -32,14 +32,11 @@ export const SuccessNotification: React.FC<SuccessNotificationProps> = ({</div>)}{link && (- <ActionButton- href={link.href}- size="sm"- variant="secondary"- className="self-start"- >- {link.text}- </ActionButton>+ <div className="self-start">+ <ActionButton href={link.href} size="sm" variant="secondary">+ {link.text}+ </ActionButton>+ </div>)}</div><buttondiff --git a/web/src/features/projects/components/ConfigureRetention.tsx b/web/src/features/projects/components/ConfigureRetention.tsxindex 845fe889fd..93b0ff5861 100644--- a/web/src/features/projects/components/ConfigureRetention.tsx+++ b/web/src/features/projects/components/ConfigureRetention.tsx@@ -129,17 +129,18 @@ export default function ConfigureRetention() {</FormItem>)}/>- <ActionButton- variant="secondary"- hasAccess={hasAccess}- hasEntitlement={hasEntitlement}- loading={setRetention.isPending}- disabled={form.getValues().retention === null}- className="mt-4"- type="submit"- >- Save- </ActionButton>+ <div className="mt-4">+ <ActionButton+ variant="secondary"+ hasAccess={hasAccess}+ hasEntitlement={hasEntitlement}+ loading={setRetention.isPending}+ disabled={form.getValues().retention === null}+ type="submit"+ >+ Save+ </ActionButton>+ </div></form></Form></Card>diff --git a/web/src/features/prompts/components/duplicate-prompt.tsx b/web/src/features/prompts/components/duplicate-prompt.tsxindex 833e4fce4c..d9144c320b 100644--- a/web/src/features/prompts/components/duplicate-prompt.tsx+++ b/web/src/features/prompts/components/duplicate-prompt.tsx@@ -187,7 +187,6 @@ export const DuplicatePromptButton: React.FC<{scope: "prompts:CUD",});const promptLimit = useEntitlementLimit("prompt-management-count-prompts");- const capture = usePostHogClientCapture();const allPromptNames = api.prompts.allNames.useQuery({@@ -207,13 +206,17 @@ export const DuplicatePromptButton: React.FC<{<ActionButtonicon={<Copy className="h-4 w-4" aria-hidden="true" />}hasAccess={hasAccess}+ trackingEventName="prompt_detail:duplicate_button_click"variant="outline"- limit={promptLimit}title="Duplicate prompt"- limitValue={allPromptNames.data?.length ?? undefined}- onClick={() => {- capture("prompt_detail:duplicate_button_click");- }}+ usageLimit={+ typeof promptLimit === "number"+ ? {+ current: allPromptNames.data?.length ?? undefined,+ max: promptLimit,+ }+ : undefined+ }><span className="hidden md:ml-1 md:inline">Duplicate</span></ActionButton>diff --git a/web/src/features/rbac/components/CreateProjectMemberButton.tsx b/web/src/features/rbac/components/CreateProjectMemberButton.tsxindex 87d0ffee50..4e0112ae3a 100644--- a/web/src/features/rbac/components/CreateProjectMemberButton.tsx+++ b/web/src/features/rbac/components/CreateProjectMemberButton.tsx@@ -142,8 +142,14 @@ export function CreateProjectMemberButton(props: {variant="secondary"loading={mutCreateProjectMember.isPending}hasAccess={hasOrgAccess || hasOnlySingleProjectAccess}- limit={orgMemberLimit}- limitValue={(orgMemberCount ?? 0) + (inviteCount ?? 0)}+ usageLimit={+ typeof orgMemberLimit === "number"+ ? {+ current: (orgMemberCount ?? 0) + (inviteCount ?? 0),+ max: orgMemberLimit,+ }+ : undefined+ }icon={<PlusIcon className="h-5 w-5" aria-hidden="true" />}>{hasOnlySingleProjectAccessdiff --git a/web/src/pages/project/[projectId]/dashboards/index.tsx b/web/src/pages/project/[projectId]/dashboards/index.tsxindex 15a1827719..0fb277d87f 100644--- a/web/src/pages/project/[projectId]/dashboards/index.tsx+++ b/web/src/pages/project/[projectId]/dashboards/index.tsx@@ -4,7 +4,6 @@ import { DashboardTable } from "@/src/features/dashboard/components/DashboardTabimport { ActionButton } from "@/src/components/ActionButton";import { PlusIcon } from "lucide-react";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {getDashboardTabs,DASHBOARD_TABS,@@ -13,7 +12,6 @@ import {export default function Dashboards() {const router = useRouter();const { projectId } = router.query as { projectId: string };- const capture = usePostHogClientCapture();const hasCUDAccess = useHasProjectAccess({projectId,scope: "dashboards:CUD",@@ -36,10 +34,8 @@ export default function Dashboards() {icon={<PlusIcon className="h-4 w-4" aria-hidden="true" />}hasAccess={hasCUDAccess}href={`/project/${projectId}/dashboards/new`}+ trackingEventName="dashboard:new_dashboard_form_open"variant="default"- onClick={() => {- capture("dashboard:new_dashboard_form_open");- }}>New dashboard</ActionButton>diff --git a/web/src/pages/project/[projectId]/prompts/[[...folder]].tsx b/web/src/pages/project/[projectId]/prompts/[[...folder]].tsxindex ec26487b20..f09b06f678 100644--- a/web/src/pages/project/[projectId]/prompts/[[...folder]].tsx+++ b/web/src/pages/project/[projectId]/prompts/[[...folder]].tsx@@ -1,7 +1,6 @@import { useRouter } from "next/router";import { ActionButton } from "@/src/components/ActionButton";import Page from "@/src/components/layouts/page";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { PromptTable } from "@/src/features/prompts/components/prompts-table";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { PlusIcon } from "lucide-react";@@ -37,7 +36,6 @@ export default function PromptsWithFolder() {: segmentsArray.join("/"): "";- const capture = usePostHogClientCapture();const hasCUDAccess = useHasProjectAccess({projectId,scope: "prompts:CUD",@@ -95,12 +93,16 @@ export default function PromptsWithFolder() {icon={<PlusIcon className="h-4 w-4" aria-hidden="true" />}hasAccess={hasCUDAccess}href={`/project/${projectId}/prompts/new${folderQueryParam ? `?folder=${encodeURIComponent(folderQueryParam)}` : ""}`}+ trackingEventName="prompts:new_form_open"variant="default"- limit={promptLimit}- limitValue={Number(count?.totalCount ?? 0)}- onClick={() => {- capture("prompts:new_form_open");- }}+ usageLimit={+ typeof promptLimit === "number"+ ? {+ current: Number(count?.totalCount ?? 0),+ max: promptLimit,+ }+ : undefined+ }>New prompt</ActionButton>diff --git a/web/src/pages/project/[projectId]/widgets/index.tsx b/web/src/pages/project/[projectId]/widgets/index.tsxindex cd5cd163dc..a7c222d954 100644--- a/web/src/pages/project/[projectId]/widgets/index.tsx+++ b/web/src/pages/project/[projectId]/widgets/index.tsx@@ -1,5 +1,4 @@import { useRouter } from "next/router";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import Page from "@/src/components/layouts/page";import { ActionButton } from "@/src/components/ActionButton";@@ -13,7 +12,6 @@ import {export default function Widgets() {const router = useRouter();const { projectId } = router.query as { projectId: string };- const capture = usePostHogClientCapture();const hasCUDAccess = useHasProjectAccess({projectId,scope: "prompts:CUD",@@ -36,10 +34,8 @@ export default function Widgets() {icon={<PlusIcon className="h-4 w-4" aria-hidden="true" />}hasAccess={hasCUDAccess}href={`/project/${projectId}/widgets/new`}+ trackingEventName="dashboard:new_widget_form_open"variant="default"- onClick={() => {- capture("dashboard:new_widget_form_open");- }}>New widget</ActionButton>