Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat: add analytics to sidebar item

Marc Seitzf66389d6cfc2
diff --git a/components/sidebar/nav-main.tsx b/components/sidebar/nav-main.tsx
index bf537598..d96d5204 100644
--- a/components/sidebar/nav-main.tsx
+++ b/components/sidebar/nav-main.tsx
@@ -2,9 +2,11 @@
import Link from "next/link";
+import { useTeam } from "@/context/team-context";
import { PlanEnum } from "@/ee/stripe/constants";
import { ChevronRight, CrownIcon, type LucideIcon } from "lucide-react";
+import { useAnalytics } from "@/lib/analytics";
import { cn } from "@/lib/utils";
import { Shimmer } from "@/components/ai-elements/shimmer";
@@ -45,6 +47,18 @@ export interface NavItem {
}
export function NavMain({ items }: { items: NavItem[] }) {
+ const analytics = useAnalytics();
+ const teamInfo = useTeam();
+
+ const handleItemClick = (title: string) => {
+ if (title === "2025 Recap") {
+ analytics.capture("YIR: Banner Opened", {
+ source: "sidebar",
+ teamId: teamInfo?.currentTeam?.id,
+ });
+ }
+ };
+
return (
<SidebarGroup>
<SidebarMenu className="space-y-0.5 text-foreground">
@@ -82,7 +96,11 @@ export function NavMain({ items }: { items: NavItem[] }) {
</div>
</UpgradePlanModal>
) : (
- <Link href={item.url} className="p-2">
+ <Link
+ href={item.url}
+ className="p-2"
+ onClick={() => handleItemClick(item.title)}
+ >
<item.icon
className={cn(
item.title === "2025 Recap" &&
diff --git a/components/yearly-recap/yearly-recap-banner.tsx b/components/yearly-recap/yearly-recap-banner.tsx
index 82b34acb..6ad378ad 100644
--- a/components/yearly-recap/yearly-recap-banner.tsx
+++ b/components/yearly-recap/yearly-recap-banner.tsx
@@ -113,6 +113,7 @@ export function YearlyRecapBanner() {
const handleOpenModal = () => {
analytics.capture("YIR: Banner Opened", {
teamId: teamInfo?.currentTeam?.id,
+ source: "banner",
});
setShowModal(true);
};