Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat: add book a call notification first 7 days (#11689)

Lotte Verheyden169d6c8c9d15
diff --git a/web/src/components/layouts/routes.tsx b/web/src/components/layouts/routes.tsx
index 5a8f623845..5fd99f683b 100644
--- a/web/src/components/layouts/routes.tsx
+++ b/web/src/components/layouts/routes.tsx
@@ -24,6 +24,7 @@ import { type Entitlement } from "@/src/features/entitlements/constants/entitlem
import { type User } from "next-auth";
import { type OrganizationScope } from "@/src/features/rbac/constants/organizationAccessRights";
import { SupportButton } from "@/src/components/nav/support-button";
+import { BookACallButton } from "@/src/components/nav/book-a-call-button";
import { V4BetaSidebarToggle } from "@/src/features/events/components/V4BetaSidebarToggle";
import { SidebarMenuButton } from "@/src/components/ui/sidebar";
import { useCommandMenu } from "@/src/features/command-k-menu/CommandMenuProvider";
@@ -212,6 +213,12 @@ export const ROUTES: Route[] = [
icon: Settings,
section: RouteSection.Secondary,
},
+ {
+ title: "Book a call",
+ section: RouteSection.Secondary,
+ pathname: "",
+ menuNode: <BookACallButton />,
+ },
{
title: "Support",
icon: LifeBuoy,
diff --git a/web/src/components/nav/book-a-call-button.tsx b/web/src/components/nav/book-a-call-button.tsx
new file mode 100644
index 0000000000..aa6335e53e
--- /dev/null
+++ b/web/src/components/nav/book-a-call-button.tsx
@@ -0,0 +1,45 @@
+import { CalendarDays } from "lucide-react";
+import { SidebarMenuButton } from "@/src/components/ui/sidebar";
+import useLocalStorage from "@/src/components/useLocalStorage";
+import Link from "next/link";
+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
+
+const SEVEN_DAYS_MS = 7 * 24 * 60 * 60 * 1000;
+const FIRST_SEEN_KEY = "book-a-call-first-seen";
+
+export const BookACallButton = () => {
+ const capture = usePostHogClientCapture();
+ const [firstSeen, setFirstSeen] = useLocalStorage<number | null>(
+ FIRST_SEEN_KEY,
+ null,
+ );
+
+ // Set first seen timestamp if not already set
+ if (firstSeen === null) {
+ setFirstSeen(Date.now());
+ }
+
+ // Hide button after 7 days from first seen
+ const isExpired =
+ firstSeen !== null && Date.now() > firstSeen + SEVEN_DAYS_MS;
+
+ if (isExpired) {
+ return null;
+ }
+
+ return (
+ <SidebarMenuButton asChild>
+ <Link
+ href="https://cal.com/team/langfuse/welcome-to-langfuse"
+ target="_blank"
+ rel="noopener noreferrer"
+ onClick={() => {
+ capture("sidebar:book_a_call_clicked");
+ }}
+ >
+ <CalendarDays className="h-4 w-4" />
+ Book a call
+ </Link>
+ </SidebarMenuButton>
+ );
+};
diff --git a/web/src/components/nav/sidebar-notifications.tsx b/web/src/components/nav/sidebar-notifications.tsx
index 7be19ce030..0fe69d9c5f 100644
--- a/web/src/components/nav/sidebar-notifications.tsx
+++ b/web/src/components/nav/sidebar-notifications.tsx
@@ -6,13 +6,12 @@ import {
CardHeader,
CardTitle,
} from "@/src/components/ui/card";
-import { useEffect, useState } from "react";
import { X } from "lucide-react";
import useLocalStorage from "../useLocalStorage";
import Link from "next/link";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
-const NOTIFICATION_TTL_MS = 14 * 24 * 60 * 60 * 1000; // two weeks
+const TWO_WEEKS_MS = 14 * 24 * 60 * 60 * 1000;
type SidebarNotification = {
id: string; // Add unique ID for each notification
@@ -23,6 +22,8 @@ type SidebarNotification = {
// defaults to "Learn more" if no linkContent and no linkTitle
linkTitle?: string;
linkContent?: React.ReactNode;
+ // Time-to-live in milliseconds from createdAt. Defaults to TWO_WEEKS_MS.
+ ttlMs?: number;
};
const notifications: SidebarNotification[] = [
@@ -46,9 +47,6 @@ const STORAGE_KEY = "dismissed-sidebar-notifications";
export function SidebarNotifications() {
const capture = usePostHogClientCapture();
- const [currentNotificationIndex, setCurrentNotificationIndex] = useState<
- number | null
- >(null);
const [dismissedNotifications, setDismissedNotifications] = useLocalStorage<
string[]
@@ -57,83 +55,86 @@ export function SidebarNotifications() {
const isExpired = (notif: SidebarNotification) => {
if (!notif.createdAt) return false;
const created = new Date(notif.createdAt).getTime();
- return Date.now() > created + NOTIFICATION_TTL_MS;
+ const ttl = notif.ttlMs ?? TWO_WEEKS_MS;
+ return Date.now() > created + ttl;
};
- // Find the oldest non-dismissed notification on mount or when dismissed list changes
- useEffect(() => {
- const firstAvailableIndex = notifications.findIndex(
- (notif) =>
- !dismissedNotifications.includes(notif.id) && !isExpired(notif),
- );
-
- setCurrentNotificationIndex(
- firstAvailableIndex === -1 ? null : firstAvailableIndex,
- );
- }, [dismissedNotifications]);
-
const dismissNotification = (id: string) => {
setDismissedNotifications([...dismissedNotifications, id]);
};
- if (currentNotificationIndex === null) {
+ const activeNotifications = notifications.filter(
+ (notif) => !dismissedNotifications.includes(notif.id) && !isExpired(notif),
+ );
+
+ if (activeNotifications.length === 0) {
return null;
}
- const currentNotification = notifications[currentNotificationIndex];
-
return (
- <Card className="relative max-h-60 overflow-hidden rounded-md bg-opacity-50 shadow-none group-data-[collapsible=icon]:hidden">
- <Button
- variant="ghost"
- size="sm"
- className="absolute right-1.5 top-2.5 h-5 w-5 p-0"
- onClick={() => {
- capture("notification:dismiss_notification", {
- notification_id: currentNotification.id,
- });
- dismissNotification(currentNotification.id);
- }}
- title="Dismiss"
- >
- <X className="h-3.5 w-3.5" />
- </Button>
- <CardHeader className="px-3 pb-0 pr-6 pt-2.5">
- <CardTitle className="text-sm">{currentNotification.title}</CardTitle>
- <CardDescription className="mt-1">
- {currentNotification.description}
- </CardDescription>
- </CardHeader>
- <CardContent className="px-3 pb-2.5 pt-1.5">
- {currentNotification.link &&
- (currentNotification.linkContent ? (
- <Link
- href={currentNotification.link}
- target="_blank"
- onClick={() => {
- capture("notification:click_link", {
- notification_id: currentNotification.id,
- });
- }}
- >
- {currentNotification.linkContent}
- </Link>
- ) : (
- <Button variant="secondary" size="sm" className="w-full" asChild>
- <Link
- href={currentNotification.link}
- target="_blank"
- onClick={() => {
- capture("notification:click_link", {
- notification_id: currentNotification.id,
- });
- }}
- >
- {currentNotification.linkTitle ?? "Learn more"} &rarr;
- </Link>
- </Button>
- ))}
- </CardContent>
- </Card>
+ <div className="flex flex-col gap-2 group-data-[collapsible=icon]:hidden">
+ {activeNotifications.map((notification) => (
+ <Card
+ key={notification.id}
+ className="relative max-h-60 overflow-hidden rounded-md bg-opacity-50 shadow-none"
+ >
+ <Button
+ variant="ghost"
+ size="sm"
+ className="absolute right-1.5 top-2.5 h-5 w-5 p-0"
+ onClick={() => {
+ capture("notification:dismiss_notification", {
+ notification_id: notification.id,
+ });
+ dismissNotification(notification.id);
+ }}
+ title="Dismiss"
+ >
+ <X className="h-3.5 w-3.5" />
+ </Button>
+ <CardHeader className="px-3 pb-0 pr-6 pt-2.5">
+ <CardTitle className="text-sm">{notification.title}</CardTitle>
+ <CardDescription className="mt-1">
+ {notification.description}
+ </CardDescription>
+ </CardHeader>
+ <CardContent className="px-3 pb-2.5 pt-1.5">
+ {notification.link &&
+ (notification.linkContent ? (
+ <Link
+ href={notification.link}
+ target="_blank"
+ onClick={() => {
+ capture("notification:click_link", {
+ notification_id: notification.id,
+ });
+ }}
+ >
+ {notification.linkContent}
+ </Link>
+ ) : (
+ <Button
+ variant="secondary"
+ size="sm"
+ className="w-full"
+ asChild
+ >
+ <Link
+ href={notification.link}
+ target="_blank"
+ onClick={() => {
+ capture("notification:click_link", {
+ notification_id: notification.id,
+ });
+ }}
+ >
+ {notification.linkTitle ?? "Learn more"} &rarr;
+ </Link>
+ </Button>
+ ))}
+ </CardContent>
+ </Card>
+ ))}
+ </div>
);
}
diff --git a/web/src/features/posthog-analytics/usePostHogClientCapture.ts b/web/src/features/posthog-analytics/usePostHogClientCapture.ts
index d56b783928..64100debc4 100644
--- a/web/src/features/posthog-analytics/usePostHogClientCapture.ts
+++ b/web/src/features/posthog-analytics/usePostHogClientCapture.ts
@@ -204,6 +204,7 @@ export const events = {
], // also used on landing page for consistency
cmd_k_menu: ["opened", "search_entered", "navigated"],
spend_alert: ["created", "updated", "deleted"],
+ sidebar: ["book_a_call_clicked"],
} as const;
// type that represents all possible event names, e.g. "traces:bookmark"