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,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",
|
||||
|
||||
Reference in new issue
Block a user