From 76dee7cbcc4eb8db52e8226536e58b2c39bf81ff Mon Sep 17 00:00:00 2001 From: Prateek Shourya Date: Wed, 30 Jul 2025 17:46:22 +0530 Subject: [PATCH] [WEB-4604] feat: add missing posthog events for project grouping, trial and upgrade. (#3783) --- .../(workspace)/project-states/page.tsx | 15 ++++++++- .../components/license/modal/trial-button.tsx | 23 +++++++++++-- .../license/modal/upgrade-modal.tsx | 17 +++++++++- .../comparison/subscription-button.tsx | 3 +- .../billing/comparison/trial-detail.tsx | 2 ++ .../ee/components/workspace/billing/root.tsx | 32 ++++++++++++++++++- .../constants/src/event-tracker/extended.ts | 16 ++++++++++ 7 files changed, 101 insertions(+), 7 deletions(-) diff --git a/apps/web/app/(all)/[workspaceSlug]/(settings)/settings/(workspace)/project-states/page.tsx b/apps/web/app/(all)/[workspaceSlug]/(settings)/settings/(workspace)/project-states/page.tsx index 42cf79cf33..d624c3d624 100644 --- a/apps/web/app/(all)/[workspaceSlug]/(settings)/settings/(workspace)/project-states/page.tsx +++ b/apps/web/app/(all)/[workspaceSlug]/(settings)/settings/(workspace)/project-states/page.tsx @@ -4,6 +4,7 @@ import React from "react"; import { observer } from "mobx-react"; import { useParams } from "next/navigation"; // plane imports +import { PROJECT_GROUPING_TRACKER_EVENTS } from "@plane/constants"; import { useTranslation } from "@plane/i18n"; import { EUserWorkspaceRoles } from "@plane/types"; import { ToggleSwitch } from "@plane/ui"; @@ -12,6 +13,7 @@ import { NotAuthorizedView } from "@/components/auth-screens"; import { PageHead } from "@/components/core"; // store hooks import { SettingsContentWrapper, SettingsHeading } from "@/components/settings"; +import { captureError, captureSuccess } from "@/helpers/event-tracker.helper"; import { useUserPermissions, useWorkspace } from "@/hooks/store"; // plane web components import { WithFeatureFlagHOC } from "@/plane-web/components/feature-flags"; @@ -44,13 +46,24 @@ const WorklogsPage = observer(() => { if (!isAdmin) return ; const toggleProjectGroupingFeature = async () => { + const willEnableProjectGrouping = !isProjectGroupingEnabled; try { const payload = { - [EWorkspaceFeatures.IS_PROJECT_GROUPING_ENABLED]: !isProjectGroupingEnabled, + [EWorkspaceFeatures.IS_PROJECT_GROUPING_ENABLED]: willEnableProjectGrouping, }; await updateWorkspaceFeature(workspaceSlug.toString(), payload); + captureSuccess({ + eventName: willEnableProjectGrouping + ? PROJECT_GROUPING_TRACKER_EVENTS.ENABLE + : PROJECT_GROUPING_TRACKER_EVENTS.DISABLE, + }); } catch (error) { console.error(error); + captureError({ + eventName: willEnableProjectGrouping + ? PROJECT_GROUPING_TRACKER_EVENTS.DISABLE + : PROJECT_GROUPING_TRACKER_EVENTS.ENABLE, + }); } }; diff --git a/apps/web/ee/components/license/modal/trial-button.tsx b/apps/web/ee/components/license/modal/trial-button.tsx index 1a71c2f3c2..6b61d45a19 100644 --- a/apps/web/ee/components/license/modal/trial-button.tsx +++ b/apps/web/ee/components/license/modal/trial-button.tsx @@ -4,19 +4,23 @@ import { useState } from "react"; import { useParams } from "next/navigation"; // plane imports import { Loader } from "lucide-react"; +import { LICENSE_TRACKER_ELEMENTS, LICENSE_TRACKER_EVENTS } from "@plane/constants"; +import { EProductSubscriptionEnum } from "@plane/types"; import { setToast, TOAST_TYPE } from "@plane/ui"; import { cn } from "@plane/utils"; // plane web imports +import { captureError, captureSuccess } from "@/helpers/event-tracker.helper"; import { useWorkspaceSubscription } from "@/plane-web/hooks/store"; export type TTrialButtonProps = { - productId: string | undefined; - priceId: string | undefined; handleClose: () => void; + priceId: string | undefined; + productId: string | undefined; + variant: EProductSubscriptionEnum; }; export const TrialButton: React.FC = (props: TTrialButtonProps) => { - const { productId, priceId, handleClose } = props; + const { handleClose, productId, priceId, variant } = props; // router const { workspaceSlug } = useParams(); // states @@ -39,6 +43,12 @@ export const TrialButton: React.FC = (props: TTrialButtonProp await freeTrialSubscription(workspaceSlug.toString(), { product_id: productId, price_id: priceId }); handleClose(); handleSuccessModalToggle(true); + captureSuccess({ + eventName: LICENSE_TRACKER_EVENTS.trial_started, + payload: { + plan: variant, + }, + }); } catch (error) { const currentError = error as unknown as { error: string; detail: string }; console.error("Error in freeTrialSubscription", error); @@ -47,6 +57,12 @@ export const TrialButton: React.FC = (props: TTrialButtonProp title: "Error!", message: currentError?.detail ?? currentError?.error ?? "Something went wrong. Please try again.", }); + captureError({ + eventName: LICENSE_TRACKER_EVENTS.trial_started, + payload: { + plan: variant, + }, + }); } finally { setTrialLoader(false); } @@ -54,6 +70,7 @@ export const TrialButton: React.FC = (props: TTrialButtonProp return (