Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
✨ Add feedback menu item (#1920)
Luke Vellaa71829c13f48
diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/components/feedback-menu-item.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/components/feedback-menu-item.tsxnew file mode 100644index 000000000..ffb4e2b77--- /dev/null+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/components/feedback-menu-item.tsx@@ -0,0 +1,33 @@+"use client";++import { usePostHog } from "@rallly/posthog/client";+import { useDialog } from "@rallly/ui/dialog";+import { Icon } from "@rallly/ui/icon";+import { SidebarMenuButton, SidebarMenuItem } from "@rallly/ui/sidebar";+import { MegaphoneIcon } from "lucide-react";+import { Trans } from "@/components/trans";+import { FeedbackDialog } from "@/features/feedback/components/feedback-dialog";++export function FeedbackMenuItem() {+ const dialog = useDialog();+ const posthog = usePostHog();+ return (+ <>+ <SidebarMenuItem>+ <SidebarMenuButton+ {...dialog.triggerProps}+ onClick={() => {+ posthog?.capture("space_sidebar:feedback_menu_item_click");+ dialog.trigger();+ }}+ >+ <Icon>+ <MegaphoneIcon />+ </Icon>+ <Trans i18nKey="sendFeedback" defaults="Send Feedback" />+ </SidebarMenuButton>+ </SidebarMenuItem>+ <FeedbackDialog {...dialog.dialogProps} />+ </>+ );+}diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/components/sidebar/nav-user.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/components/nav-user.tsxsimilarity index 100%rename from apps/web/src/app/[locale]/(space)/(dashboard)/components/sidebar/nav-user.tsxrename to apps/web/src/app/[locale]/(space)/(dashboard)/components/nav-user.tsxdiff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/components/sidebar/space-sidebar.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/components/sidebar/space-sidebar.tsxdeleted file mode 100644index 34dc40a32..000000000--- a/apps/web/src/app/[locale]/(space)/(dashboard)/components/sidebar/space-sidebar.tsx+++ /dev/null@@ -1,74 +0,0 @@-import { Button } from "@rallly/ui/button";-import { Icon } from "@rallly/ui/icon";-import {- Sidebar,- SidebarContent,- SidebarFooter,- SidebarHeader,- SidebarSeparator,-} from "@rallly/ui/sidebar";-import { ChevronsUpDownIcon } from "lucide-react";-import type React from "react";-import { UpgradeToProAlert } from "@/app/[locale]/(space)/(dashboard)/components/sidebar/upgrade-to-pro-alert";-import { requireSpace, requireUser } from "@/auth/data";-import { SpaceDropdown } from "@/features/space/components/space-dropdown";-import { SpaceIcon } from "@/features/space/components/space-icon";-import { SpaceTierLabel } from "@/features/space/components/space-tier";-import { loadSpaces } from "@/features/space/data";-import { NavUser } from "./nav-user";-import { SpaceSidebarMenu } from "./space-sidebar-menu";--async function loadData() {- const [user, activeSpace, spaces] = await Promise.all([- requireUser(),- requireSpace(),- loadSpaces(),- ]);-- return {- user,- spaces,- activeSpace,- };-}--export async function SpaceSidebar({- ...props-}: React.ComponentProps<typeof Sidebar>) {- const { user, spaces, activeSpace } = await loadData();-- return (- <Sidebar variant="inset" {...props}>- <SidebarHeader>- <SpaceDropdown spaces={spaces} activeSpaceId={activeSpace.id}>- <Button className="flex h-auto w-full p-2" variant="ghost">- <SpaceIcon src={activeSpace.image} name={activeSpace.name} />- <div className="min-w-0 flex-1 px-0.5 text-left">- <div className="truncate font-medium text-sm">- {activeSpace.name}- </div>- <div className="text-muted-foreground text-xs">- <SpaceTierLabel tier={activeSpace.tier} />- </div>- </div>- <Icon>- <ChevronsUpDownIcon />- </Icon>- </Button>- </SpaceDropdown>- </SidebarHeader>- <SidebarContent>- <SpaceSidebarMenu />- </SidebarContent>- <SidebarFooter>- {activeSpace.tier !== "pro" ? (- <>- <UpgradeToProAlert />- <SidebarSeparator className="my-1" />- </>- ) : null}- <NavUser name={user.name} image={user.image} email={user.email} />- </SidebarFooter>- </Sidebar>- );-}diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/components/sidebar/space-sidebar-menu.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/components/space-sidebar-menu.tsxsimilarity index 100%rename from apps/web/src/app/[locale]/(space)/(dashboard)/components/sidebar/space-sidebar-menu.tsxrename to apps/web/src/app/[locale]/(space)/(dashboard)/components/space-sidebar-menu.tsxdiff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/components/sidebar/space-sidebar-provider.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/components/space-sidebar-provider.tsxsimilarity index 100%rename from apps/web/src/app/[locale]/(space)/(dashboard)/components/sidebar/space-sidebar-provider.tsxrename to apps/web/src/app/[locale]/(space)/(dashboard)/components/space-sidebar-provider.tsxdiff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/components/upgrade-menu-item.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/components/upgrade-menu-item.tsxnew file mode 100644index 000000000..f27e24af1--- /dev/null+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/components/upgrade-menu-item.tsx@@ -0,0 +1,27 @@+"use client";++import { usePostHog } from "@rallly/posthog/client";+import { SidebarMenuButton, SidebarMenuItem } from "@rallly/ui/sidebar";+import { SparklesIcon } from "lucide-react";+import { Trans } from "@/components/trans";+import { useBilling } from "@/features/billing/client";++export function UpgradeMenuItem() {+ const { showPayWall } = useBilling();+ const posthog = usePostHog();++ return (+ <SidebarMenuItem>+ <SidebarMenuButton+ variant="primary"+ onClick={() => {+ posthog?.capture("space_sidebar:upgrade_button_click");+ showPayWall();+ }}+ >+ <SparklesIcon className="size-4" />+ <Trans i18nKey="upgradeToPro" defaults="Upgrade to Pro" />+ </SidebarMenuButton>+ </SidebarMenuItem>+ );+}diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/components/sidebar/upgrade-to-pro-alert.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/components/upgrade-to-pro-alert.tsxsimilarity index 100%rename from apps/web/src/app/[locale]/(space)/(dashboard)/components/sidebar/upgrade-to-pro-alert.tsxrename to apps/web/src/app/[locale]/(space)/(dashboard)/components/upgrade-to-pro-alert.tsxdiff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/layout.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/layout.tsxindex 98cc376f1..0c1bbfdf4 100644--- a/apps/web/src/app/[locale]/(space)/(dashboard)/layout.tsx+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/layout.tsx@@ -1,20 +1,63 @@-import { SidebarInset } from "@rallly/ui/sidebar";+import {+ Sidebar,+ SidebarContent,+ SidebarFooter,+ SidebarGroup,+ SidebarGroupContent,+ SidebarHeader,+ SidebarInset,+ SidebarMenu,+ SidebarSeparator,+} from "@rallly/ui/sidebar";import type { Metadata } from "next";-import { requireSpace } from "@/auth/data";+import { FeedbackMenuItem } from "@/app/[locale]/(space)/(dashboard)/components/feedback-menu-item";+import { NavUser } from "@/app/[locale]/(space)/(dashboard)/components/nav-user";+import { SpaceSidebarMenu } from "@/app/[locale]/(space)/(dashboard)/components/space-sidebar-menu";+import { UpgradeMenuItem } from "@/app/[locale]/(space)/(dashboard)/components/upgrade-menu-item";+import { requireSpace, requireUser } from "@/auth/data";import { LicenseLimitWarning } from "@/features/licensing/components/license-limit-warning";import { CommandMenu } from "@/features/navigation/command-menu";-import { SpaceSidebar } from "./components/sidebar/space-sidebar";-import { SpaceSidebarProvider } from "./components/sidebar/space-sidebar-provider";+import { SpaceDropdown } from "@/features/space/components/space-dropdown";+import { loadSpaces } from "@/features/space/data";+import { IfFeatureEnabled } from "@/lib/feature-flags/client";+import { SpaceSidebarProvider } from "./components/space-sidebar-provider";export default async function Layout({children,}: {children: React.ReactNode;}) {+ const [user, activeSpace, spaces] = await Promise.all([+ requireUser(),+ requireSpace(),+ loadSpaces(),+ ]);+return (<SpaceSidebarProvider><CommandMenu />- <SpaceSidebar />+ <Sidebar variant="inset">+ <SidebarHeader>+ <SpaceDropdown spaces={spaces} activeSpaceId={activeSpace.id} />+ </SidebarHeader>+ <SidebarContent>+ <SpaceSidebarMenu />+ </SidebarContent>+ <SidebarFooter>+ <SidebarGroup>+ <SidebarGroupContent>+ <SidebarMenu>+ {activeSpace.tier === "hobby" ? <UpgradeMenuItem /> : null}+ <IfFeatureEnabled feature="feedback">+ <FeedbackMenuItem />+ </IfFeatureEnabled>+ </SidebarMenu>+ </SidebarGroupContent>+ </SidebarGroup>+ <SidebarSeparator className="my-1" />+ <NavUser name={user.name} image={user.image} email={user.email} />+ </SidebarFooter>+ </Sidebar><SidebarInset className="min-w-0"><LicenseLimitWarning /><div className="flex flex-1 flex-col">diff --git a/apps/web/src/components/user-dropdown.tsx b/apps/web/src/components/user-dropdown.tsxindex 3405ca97a..895870990 100644--- a/apps/web/src/components/user-dropdown.tsx+++ b/apps/web/src/components/user-dropdown.tsx@@ -18,7 +18,6 @@ import {LifeBuoyIcon,ListIcon,LogOutIcon,- MegaphoneIcon,Settings2Icon,UserIcon,} from "lucide-react";@@ -27,7 +26,6 @@ import { signOut } from "next-auth/react";import { OptimizedAvatarImage } from "@/components/optimized-avatar-image";import { Trans } from "@/components/trans";import { IfCloudHosted, IfSelfHosted } from "@/contexts/environment";-import { isFeedbackEnabled } from "@/utils/constants";import { useAuthenticatedUser } from "./user-provider";export const UserDropdown = ({ className }: { className?: string }) => {@@ -120,18 +118,6 @@ export const UserDropdown = ({ className }: { className?: string }) => {</Link></DropdownMenuItem></IfSelfHosted>- {isFeedbackEnabled ? (- <DropdownMenuItem asChild={true}>- <Link- target="_blank"- href="https://feedback.rallly.co"- className="flex items-center gap-x-2"- >- <MegaphoneIcon className="size-4 text-muted-foreground" />- <Trans i18nKey="feedback" defaults="Feedback" />- </Link>- </DropdownMenuItem>- ) : null}<DropdownMenuSeparator /><DropdownMenuItemonClick={async () => {diff --git a/apps/web/src/features/feedback/actions.ts b/apps/web/src/features/feedback/actions.tsindex 64bd59bbd..8c5acab1b 100644--- a/apps/web/src/features/feedback/actions.ts+++ b/apps/web/src/features/feedback/actions.ts@@ -21,6 +21,12 @@ export const submitFeedbackAction = authActionClientsubject: "Feedback",text: `User: ${ctx.user.name} (${ctx.user.email})\n\n${content}`,});++ ctx.posthog?.capture({+ event: "feedback_send",+ distinctId: ctx.user.id,+ });+return {success: true,};diff --git a/apps/web/src/features/feedback/components/feedback-toggle.tsx b/apps/web/src/features/feedback/components/feedback-dialog.tsxsimilarity index 79%rename from apps/web/src/features/feedback/components/feedback-toggle.tsxrename to apps/web/src/features/feedback/components/feedback-dialog.tsxindex 1bf74a39c..064d14fbd 100644--- a/apps/web/src/features/feedback/components/feedback-toggle.tsx+++ b/apps/web/src/features/feedback/components/feedback-dialog.tsx@@ -2,24 +2,17 @@import { zodResolver } from "@hookform/resolvers/zod";import { Button } from "@rallly/ui/button";+import type { DialogProps } from "@rallly/ui/dialog";import {Dialog,DialogContent,DialogDescription,DialogHeader,DialogTitle,- DialogTrigger,} from "@rallly/ui/dialog";import { Form, FormField, FormItem, FormMessage } from "@rallly/ui/form";-import { Icon } from "@rallly/ui/icon";import { Textarea } from "@rallly/ui/textarea";-import {- Tooltip,- TooltipContent,- TooltipPortal,- TooltipTrigger,-} from "@rallly/ui/tooltip";-import { CheckCircle2Icon, MegaphoneIcon } from "lucide-react";+import { CheckCircle2Icon } from "lucide-react";import { useForm } from "react-hook-form";import { Trans } from "@/components/trans";@@ -30,7 +23,7 @@ import { submitFeedbackAction } from "../actions";import type { Feedback } from "../schema";import { feedbackSchema } from "../schema";-export function FeedbackToggle() {+export function FeedbackDialog(props: DialogProps) {const submitFeedback = useSafeAction(submitFeedbackAction);const form = useForm<Feedback>({resolver: zodResolver(feedbackSchema),@@ -41,23 +34,7 @@ export function FeedbackToggle() {}return (- <Dialog>- <Tooltip>- <TooltipTrigger asChild>- <DialogTrigger asChild>- <Button variant="ghost" size="icon">- <Icon>- <MegaphoneIcon />- </Icon>- </Button>- </DialogTrigger>- </TooltipTrigger>- <TooltipPortal>- <TooltipContent>- <Trans i18nKey="feedback" defaults="Feedback" />- </TooltipContent>- </TooltipPortal>- </Tooltip>+ <Dialog {...props}><DialogContent>{!form.formState.isSubmitSuccessful ? (<>diff --git a/apps/web/src/features/feedback/constants.ts b/apps/web/src/features/feedback/constants.tsnew file mode 100644index 000000000..406d8472c--- /dev/null+++ b/apps/web/src/features/feedback/constants.ts@@ -0,0 +1,3 @@+import { isSelfHosted } from "@/utils/constants";++export const isFeedbackEnabled = !isSelfHosted;diff --git a/apps/web/src/features/space/components/space-dropdown.tsx b/apps/web/src/features/space/components/space-dropdown.tsxindex 98bbf0423..8f0f36722 100644--- a/apps/web/src/features/space/components/space-dropdown.tsx+++ b/apps/web/src/features/space/components/space-dropdown.tsx@@ -1,5 +1,6 @@"use client";+import { Button } from "@rallly/ui/button";import { useDialog } from "@rallly/ui/dialog";import {DropdownMenu,@@ -12,10 +13,11 @@ import {DropdownMenuTrigger,} from "@rallly/ui/dropdown-menu";import { Icon } from "@rallly/ui/icon";-import { CirclePlusIcon } from "lucide-react";+import { ChevronsUpDownIcon, CirclePlusIcon } from "lucide-react";import { RouterLoadingIndicator } from "@/components/router-loading-indicator";import { Trans } from "@/components/trans";import { setActiveSpaceAction } from "@/features/space/actions";+import { SpaceTierLabel } from "@/features/space/components/space-tier";import { useSafeAction } from "@/lib/safe-action/client";import { CreateSpaceDialog } from "./create-space-dialog";import { SpaceIcon } from "./space-icon";@@ -23,7 +25,6 @@ import { SpaceIcon } from "./space-icon";export function SpaceDropdown({spaces,activeSpaceId,- children,}: {spaces: {id: string;@@ -32,11 +33,11 @@ export function SpaceDropdown({image?: string;}[];activeSpaceId: string;- children?: React.ReactNode;}) {const setActiveSpace = useSafeAction(setActiveSpaceAction);const newSpaceDialog = useDialog();const activeSpace = spaces.find((space) => space.id === activeSpaceId);+if (!activeSpace) {return null;}@@ -44,8 +45,21 @@ export function SpaceDropdown({return (<><DropdownMenu>- <DropdownMenuTrigger asChild={Boolean(children)}>- {children}+ <DropdownMenuTrigger asChild={true}>+ <Button className="flex h-auto w-full p-2" variant="ghost">+ <SpaceIcon src={activeSpace.image} name={activeSpace.name} />+ <div className="min-w-0 flex-1 px-0.5 text-left">+ <div className="truncate font-medium text-sm">+ {activeSpace.name}+ </div>+ <div className="text-muted-foreground text-xs">+ <SpaceTierLabel tier={activeSpace.tier} />+ </div>+ </div>+ <Icon>+ <ChevronsUpDownIcon />+ </Icon>+ </Button></DropdownMenuTrigger><DropdownMenuContentclassName="min-w-[var(--radix-dropdown-menu-trigger-width)]"diff --git a/apps/web/src/lib/feature-flags/config.ts b/apps/web/src/lib/feature-flags/config.tsindex 563e1defd..f040eb017 100644--- a/apps/web/src/lib/feature-flags/config.ts+++ b/apps/web/src/lib/feature-flags/config.ts@@ -1,8 +1,10 @@import { isBillingEnabled } from "@/features/billing/constants";+import { isFeedbackEnabled } from "@/features/feedback/constants";import type { FeatureFlagConfig } from "@/lib/feature-flags/types";import { isStorageEnabled } from "@/lib/storage";export const featureFlagConfig: FeatureFlagConfig = {storage: isStorageEnabled,billing: isBillingEnabled,+ feedback: isFeedbackEnabled,};diff --git a/apps/web/src/lib/feature-flags/types.ts b/apps/web/src/lib/feature-flags/types.tsindex dbb6733c7..f4fbfeeec 100644--- a/apps/web/src/lib/feature-flags/types.ts+++ b/apps/web/src/lib/feature-flags/types.ts@@ -1,6 +1,7 @@export interface FeatureFlagConfig {storage: boolean;billing: boolean;+ feedback: boolean;}export type Feature = keyof FeatureFlagConfig;diff --git a/apps/web/src/lib/safe-action/server.ts b/apps/web/src/lib/safe-action/server.tsindex 200e3dc7c..788cac22f 100644--- a/apps/web/src/lib/safe-action/server.ts+++ b/apps/web/src/lib/safe-action/server.ts@@ -14,19 +14,13 @@ import type { Duration } from "@/lib/rate-limit";import { rateLimit } from "@/lib/rate-limit";const posthogMiddleware = createMiddleware().define(async ({ next }) => {- if (!process.env.NEXT_PUBLIC_POSTHOG_API_KEY) {- return next({- ctx: {- posthog: null,- },- });- }-- const posthog = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_API_KEY, {- host: process.env.NEXT_PUBLIC_POSTHOG_API_HOST,- flushAt: 20,- flushInterval: 10000,- });+ const posthog = process.env.NEXT_PUBLIC_POSTHOG_API_KEY+ ? new PostHog(process.env.NEXT_PUBLIC_POSTHOG_API_KEY, {+ host: process.env.NEXT_PUBLIC_POSTHOG_API_HOST,+ flushAt: 20,+ flushInterval: 10000,+ })+ : null;const result = await next({ctx: {diff --git a/apps/web/src/utils/constants.ts b/apps/web/src/utils/constants.tsindex 73e8c9afd..e868ea928 100644--- a/apps/web/src/utils/constants.ts+++ b/apps/web/src/utils/constants.ts@@ -1,5 +1,3 @@export const isSelfHosted = process.env.NEXT_PUBLIC_SELF_HOSTED === "true";-export const isFeedbackEnabled = false;-export const appVersion = process.env.NEXT_PUBLIC_APP_VERSION;diff --git a/packages/ui/src/sidebar.tsx b/packages/ui/src/sidebar.tsxindex 86988f2ea..6732a1cee 100644--- a/packages/ui/src/sidebar.tsx+++ b/packages/ui/src/sidebar.tsx@@ -514,7 +514,8 @@ const sidebarMenuButtonVariants = cva({variants: {variant: {- primary: "text-primary data-[active=false]:hover:bg-primary-100",+ primary:+ "text-primary active:text-primary data-[active=false]:hover:bg-primary-100",default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:text-sidebar-accent-foreground focus:bg-sidebar-accent focus:text-sidebar-accent-foreground focus-visible:text-sidebar-accent-foreground data-[active=false]:hover:bg-sidebar-accent/50",outline: