Skip to content

Commit

Permalink
[dashboard] Allow onboarding mail
Browse files Browse the repository at this point in the history
Fixes #5327
  • Loading branch information
laushinka authored and roboquat committed Aug 26, 2021
1 parent 498cd69 commit 8aab84e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
28 changes: 28 additions & 0 deletions components/dashboard/src/settings/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -69,6 +92,11 @@ export default function Notifications() {
desc="Receive essential emails about changes to your account"
checked={true}
disabled={true} />
<CheckBox
title="Onboarding guide"
desc="In the first weeks after you sign up, we'll guide you through the product, so you can get the most out of it"
checked={isOnboardingMail}
onChange={toggleOnboardingMail} />
<CheckBox
title="Changelog"
desc="Be the first to learn about new features and overall product improvements"
Expand Down
2 changes: 1 addition & 1 deletion components/gitpod-db/src/typeorm/user-db-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class TypeORMUserDBImpl implements UserDB {
identities: [],
additionalData: {
ideSettings: { defaultIde: 'code' },
emailNotificationSettings: { allowsChangelogMail: true, allowsDevXMail: true }
emailNotificationSettings: { allowsChangelogMail: true, allowsDevXMail: true, allowsOnboardingMail: true }
},
};
await this.storeUser(user);
Expand Down
1 change: 1 addition & 0 deletions components/gitpod-protocol/src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export interface AdditionalUserData {
export interface EmailNotificationSettings {
allowsChangelogMail?: boolean;
allowsDevXMail?: boolean;
allowsOnboardingMail?: boolean;
}

export type IDESettings = {
Expand Down

0 comments on commit 8aab84e

Please sign in to comment.