Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dashboard] Allow onboarding mail #5397

Merged
merged 1 commit into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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