From 8aab84e62d0d9013eed1d624539eb5f697ca3ced Mon Sep 17 00:00:00 2001 From: "Laurie T. Malau" Date: Thu, 26 Aug 2021 12:26:58 +0000 Subject: [PATCH] [dashboard] Allow onboarding mail Fixes #5327 --- .../dashboard/src/settings/Notifications.tsx | 28 +++++++++++++++++++ .../gitpod-db/src/typeorm/user-db-impl.ts | 2 +- components/gitpod-protocol/src/protocol.ts | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/components/dashboard/src/settings/Notifications.tsx b/components/dashboard/src/settings/Notifications.tsx index 2db1994e39c754..8b03b5aea7c189 100644 --- a/components/dashboard/src/settings/Notifications.tsx +++ b/components/dashboard/src/settings/Notifications.tsx @@ -13,9 +13,32 @@ import settingsMenu from "./settings-menu"; export default function Notifications() { const { user, setUser } = useContext(UserContext); + const [isOnboardingMail, setOnboardingMail] = useState(!!user?.additionalData?.emailNotificationSettings?.allowsOnboardingMail); const [isChangelogMail, setChangelogMail] = useState(!!user?.additionalData?.emailNotificationSettings?.allowsChangelogMail); const [isDevXMail, setDevXMail] = useState(!!user?.additionalData?.emailNotificationSettings?.allowsDevXMail); + const toggleOnboardingMail = async () => { + if (user && user.additionalData && user.additionalData.emailNotificationSettings) { + const newIsOnboardingMail = !isOnboardingMail; + user.additionalData.emailNotificationSettings.allowsOnboardingMail = newIsOnboardingMail; + await getGitpodService().server.updateLoggedInUser({ + additionalData: { + ...user.additionalData, + emailNotificationSettings: { + ...user.additionalData.emailNotificationSettings, + allowsOnboardingMail: newIsOnboardingMail + } + } + }); + await getGitpodService().server.trackEvent({ + event: "notification_change", + properties: { "unsubscribed_onboarding": !newIsOnboardingMail } + }) + setUser(user); + setOnboardingMail(newIsOnboardingMail); + } + } + const toggleChangelogMail = async () => { if (user && user.additionalData && user.additionalData.emailNotificationSettings) { const newIsChangelogMail = !isChangelogMail; @@ -69,6 +92,11 @@ export default function Notifications() { desc="Receive essential emails about changes to your account" checked={true} disabled={true} /> +