From 4c92877a3adc1bd44747d7065546b266d89e0234 Mon Sep 17 00:00:00 2001 From: Siddhant Khare Date: Mon, 28 Oct 2024 16:10:55 +0000 Subject: [PATCH 1/2] feat: Add AWS re:Invent 2024 notification --- components/dashboard/src/AppNotifications.tsx | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/components/dashboard/src/AppNotifications.tsx b/components/dashboard/src/AppNotifications.tsx index 528fd89e3ed82d..6cffe602840a89 100644 --- a/components/dashboard/src/AppNotifications.tsx +++ b/components/dashboard/src/AppNotifications.tsx @@ -131,6 +131,61 @@ const INVALID_BILLING_ADDRESS = (stripePortalUrl: string | undefined) => { } as Notification; }; +const GENERAL_NOTIFICATION = ( + id: string, + message: JSX.Element, + updateUser: (user: Partial) => Promise, + eventName: string = "general_notification", +) => { + return { + id, + type: "info", + preventDismiss: true, + onClose: async () => { + let dismissSuccess = false; + try { + const updatedUser = await updateUser({ + additionalData: { + profile: { + coachmarksDismissals: { + [id]: new Date().toISOString(), + }, + }, + }, + }); + dismissSuccess = !!updatedUser; + } catch (err) { + dismissSuccess = false; + } finally { + trackEvent("coachmark_dismissed", { + name: eventName, + success: dismissSuccess, + }); + } + }, + message, + } as Notification; +}; + +const AWS_REINVENT_NOTIFICATION = (updateUser: (user: Partial) => Promise) => { + return GENERAL_NOTIFICATION( + "aws_reinvent_2024", + + AWS re:Invent: Book a demo during re:Invent or join our exclusive dinner for Engineering Executives |{" "} + + Learn more + + , + updateUser, + "aws_reinvent_notification", + ); +}; + export function AppNotifications() { const [topNotification, setTopNotification] = useState(undefined); const { user, loading } = useUserLoader(); @@ -163,6 +218,10 @@ export function AppNotifications() { if (isGitpodIo() && !user?.profile?.coachmarksDismissals[GITPOD_FLEX_INTRODUCTION_COACHMARK_KEY]) { notifications.push(GITPOD_FLEX_INTRODUCTION((u: Partial) => mutateAsync(u))); } + + if (isGitpodIo() && !user?.profile?.coachmarksDismissals["aws_reinvent_2024"]) { + notifications.push(AWS_REINVENT_NOTIFICATION((u: Partial) => mutateAsync(u))); + } } if (!ignore) { From 88e442d08af44048135b74cfad6907c4c2c7caa0 Mon Sep 17 00:00:00 2001 From: Siddhant Khare Date: Mon, 28 Oct 2024 22:58:31 +0530 Subject: [PATCH 2/2] Update copy --- components/dashboard/src/AppNotifications.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/dashboard/src/AppNotifications.tsx b/components/dashboard/src/AppNotifications.tsx index 6cffe602840a89..9eb884538d45c9 100644 --- a/components/dashboard/src/AppNotifications.tsx +++ b/components/dashboard/src/AppNotifications.tsx @@ -171,7 +171,7 @@ const AWS_REINVENT_NOTIFICATION = (updateUser: (user: Partial) => return GENERAL_NOTIFICATION( "aws_reinvent_2024", - AWS re:Invent: Book a demo during re:Invent or join our exclusive dinner for Engineering Executives |{" "} + See you at re:Invent! Book a demo with us, and join our developer productivity leaders roundtable (limited tickets) |{" "}