Skip to content

Commit 15d2d34

Browse files
Only show privacy policy notice on Gitpod Cloud (#18985)
* Only show privacy policy notice on Gitpod Cloud * Track dismisses
1 parent 17f7b6c commit 15d2d34

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed

components/dashboard/src/Analytics.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@ export type Event =
1515
| "organisation_authorised"
1616
| "dotfile_repo_changed"
1717
| "feedback_submitted"
18-
| "workspace_class_changed";
18+
| "workspace_class_changed"
19+
| "privacy_policy_update_accepted";
1920
type InternalEvent = Event | "path_changed" | "dashboard_clicked";
2021

21-
export type EventProperties = TrackOrgAuthorised | TrackInviteUrlRequested | TrackDotfileRepo | TrackFeedback;
22+
export type EventProperties =
23+
| TrackOrgAuthorised
24+
| TrackInviteUrlRequested
25+
| TrackDotfileRepo
26+
| TrackFeedback
27+
| TrackPolicyUpdateClick;
2228
type InternalEventProperties = EventProperties | TrackDashboardClick | TrackPathChanged;
2329

2430
export interface TrackOrgAuthorised {
@@ -43,6 +49,12 @@ export interface TrackFeedback {
4349
error_object?: StartWorkspaceError;
4450
error_message?: string;
4551
}
52+
53+
export interface TrackPolicyUpdateClick {
54+
path: string;
55+
success: boolean;
56+
}
57+
4658
interface TrackDashboardClick {
4759
dnt?: boolean;
4860
path: string;

components/dashboard/src/AppNotifications.tsx

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
* See License-AGPL.txt in the project root for license information.
55
*/
66

7+
import dayjs from "dayjs";
8+
import deepMerge from "deepmerge";
79
import { useCallback, useEffect, useState } from "react";
810
import Alert, { AlertType } from "./components/Alert";
9-
import dayjs from "dayjs";
1011
import { useUserLoader } from "./hooks/use-user-loader";
1112
import { getGitpodService } from "./service/service";
12-
import deepMerge from "deepmerge";
13+
import { isGitpodIo } from "./utils";
14+
import { trackEvent } from "./Analytics";
1315

1416
const KEY_APP_DISMISSED_NOTIFICATIONS = "gitpod-app-notifications-dismissed";
1517
const PRIVACY_POLICY_LAST_UPDATED = "2023-10-17";
@@ -27,9 +29,23 @@ const UPDATED_PRIVACY_POLICY: Notification = {
2729
type: "info",
2830
preventDismiss: true,
2931
onClose: async () => {
30-
const userUpdates = { additionalData: { profile: { acceptedPrivacyPolicyDate: dayjs().toISOString() } } };
31-
const previousUser = await getGitpodService().server.getLoggedInUser();
32-
await getGitpodService().server.updateLoggedInUser(deepMerge(previousUser, userUpdates));
32+
let dismissSuccess = false;
33+
try {
34+
const userUpdates = { additionalData: { profile: { acceptedPrivacyPolicyDate: dayjs().toISOString() } } };
35+
const previousUser = await getGitpodService().server.getLoggedInUser();
36+
const updatedUser = await getGitpodService().server.updateLoggedInUser(
37+
deepMerge(previousUser, userUpdates),
38+
);
39+
dismissSuccess = !!updatedUser;
40+
} catch (err) {
41+
console.error("Failed to update user's privacy policy acceptance date", err);
42+
dismissSuccess = false;
43+
} finally {
44+
trackEvent("privacy_policy_update_accepted", {
45+
path: window.location.pathname,
46+
success: dismissSuccess,
47+
});
48+
}
3349
},
3450
message: (
3551
<span className="text-md">
@@ -48,10 +64,10 @@ export function AppNotifications() {
4864

4965
useEffect(() => {
5066
const notifications = [];
51-
if (!loading && user?.additionalData?.profile) {
67+
if (!loading && isGitpodIo()) {
5268
if (
53-
!user.additionalData.profile.acceptedPrivacyPolicyDate ||
54-
new Date(PRIVACY_POLICY_LAST_UPDATED) > new Date(user.additionalData.profile?.acceptedPrivacyPolicyDate)
69+
!user?.additionalData?.profile?.acceptedPrivacyPolicyDate ||
70+
new Date(PRIVACY_POLICY_LAST_UPDATED) > new Date(user.additionalData.profile.acceptedPrivacyPolicyDate)
5571
) {
5672
notifications.push(UPDATED_PRIVACY_POLICY);
5773
}

components/server/src/user/user-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class UserService {
7474
}
7575
if (newUser.additionalData) {
7676
// When a user is created, it does not have `additionalData.profile` set, so it's ok to rewrite it here.
77-
newUser.additionalData.profile = { acceptedPrivacyPolicyDate: new Date().toISOString() };
77+
// todo:revert newUser.additionalData.profile = { acceptedPrivacyPolicyDate: new Date().toISOString() };
7878
}
7979
}
8080

0 commit comments

Comments
 (0)