Skip to content

Commit

Permalink
Add AWS re:Invent 2024 notification (#20323)
Browse files Browse the repository at this point in the history
* feat: Add AWS re:Invent 2024 notification

* Update copy
  • Loading branch information
Siddhant-K-code authored Oct 28, 2024
1 parent 9442b52 commit 6bc053e
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions components/dashboard/src/AppNotifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,61 @@ const INVALID_BILLING_ADDRESS = (stripePortalUrl: string | undefined) => {
} as Notification;
};

const GENERAL_NOTIFICATION = (
id: string,
message: JSX.Element,
updateUser: (user: Partial<UserProtocol>) => Promise<User>,
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<UserProtocol>) => Promise<User>) => {
return GENERAL_NOTIFICATION(
"aws_reinvent_2024",
<span className="text-md">
<b>See you at re:Invent!</b> Book a demo with us, and join our developer productivity leaders roundtable (limited tickets) |{" "}
<a
className="text-kumquat-ripe font-bold"
href="https://www.gitpod.io/aws-reinvent-24"
target="_blank"
rel="noreferrer"
>
Learn more
</a>
</span>,
updateUser,
"aws_reinvent_notification",
);
};

export function AppNotifications() {
const [topNotification, setTopNotification] = useState<Notification | undefined>(undefined);
const { user, loading } = useUserLoader();
Expand Down Expand Up @@ -163,6 +218,10 @@ export function AppNotifications() {
if (isGitpodIo() && !user?.profile?.coachmarksDismissals[GITPOD_FLEX_INTRODUCTION_COACHMARK_KEY]) {
notifications.push(GITPOD_FLEX_INTRODUCTION((u: Partial<UserProtocol>) => mutateAsync(u)));
}

if (isGitpodIo() && !user?.profile?.coachmarksDismissals["aws_reinvent_2024"]) {
notifications.push(AWS_REINVENT_NOTIFICATION((u: Partial<UserProtocol>) => mutateAsync(u)));
}
}

if (!ignore) {
Expand Down

0 comments on commit 6bc053e

Please sign in to comment.