Skip to content

Commit 3ad9230

Browse files
committed
[dashboard] add modal_dismiss tracking event
1 parent e2d18d0 commit 3ad9230

15 files changed

+46
-5
lines changed

components/dashboard/src/Setup.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default function Setup() {
3838
return (
3939
<div>
4040
{!showModal && (
41+
// TODO: Use title and buttons props
4142
<Modal visible={true} onClose={() => {}} closeable={false}>
4243
<h3 className="pb-2">Welcome to Gitpod 🎉</h3>
4344
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4">

components/dashboard/src/components/Modal.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
*/
66

77
import { useEffect } from "react";
8+
import { getGitpodService } from "../service/service";
9+
10+
type CloseModalManner = "esc" | "enter" | "x";
811

912
export default function Modal(props: {
13+
referrer?: string;
1014
title?: string;
1115
buttons?: React.ReactChild[] | React.ReactChild;
1216
children: React.ReactChild[] | React.ReactChild;
@@ -16,20 +20,35 @@ export default function Modal(props: {
1620
onClose: () => void;
1721
onEnter?: () => boolean;
1822
}) {
23+
const closeModal = (manner: CloseModalManner) => {
24+
props.onClose();
25+
getGitpodService()
26+
.server.trackEvent({
27+
event: "modal_dismiss",
28+
properties: {
29+
manner,
30+
title: props.title,
31+
referrer: props.referrer,
32+
path: window.location.pathname,
33+
},
34+
})
35+
.then()
36+
.catch(console.error);
37+
};
1938
const handler = (evt: KeyboardEvent) => {
2039
if (evt.defaultPrevented) {
2140
return;
2241
}
2342
if (evt.key === "Escape") {
24-
props.onClose();
43+
closeModal("esc");
2544
}
2645
if (evt.key === "Enter") {
2746
if (props.onEnter) {
2847
if (props.onEnter()) {
29-
props.onClose();
48+
closeModal("enter");
3049
}
3150
} else {
32-
props.onClose();
51+
closeModal("enter");
3352
}
3453
}
3554
};
@@ -60,7 +79,7 @@ export default function Modal(props: {
6079
{props.closeable !== false && (
6180
<div
6281
className="absolute right-7 top-6 cursor-pointer text-gray-800 dark:text-gray-100 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-md p-2"
63-
onClick={props.onClose}
82+
onClick={() => closeModal("x")}
6483
>
6584
<svg version="1.1" width="14px" height="14px" viewBox="0 0 100 100">
6685
<line x1="0" y1="0" x2="100" y2="100" stroke="currentColor" strokeWidth="10px" />

components/dashboard/src/projects/ProjectVariables.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ function AddVariableModal(props: { project?: Project; onClose: () => void }) {
121121
};
122122

123123
return (
124+
// TODO: Use title and buttons props
124125
<Modal
125126
visible={true}
126127
onClose={props.onClose}

components/dashboard/src/settings/EnvironmentVariables.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ function AddEnvVarModal(p: EnvVarModalProps) {
5353
};
5454

5555
return (
56+
// TODO: Use title and buttons props
5657
<Modal visible={true} onClose={p.onClose} onEnter={save}>
5758
<h3 className="mb-4">{isNew ? "New" : "Edit"} Variable</h3>
5859
<div className="border-t border-b border-gray-200 dark:border-gray-800 -mx-6 px-6 py-4 flex flex-col">

components/dashboard/src/settings/Integrations.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ function GitProviders() {
294294
)}
295295

296296
{editModal && (
297+
// TODO: Use title and buttons props
297298
<Modal visible={true} onClose={() => setEditModal(undefined)}>
298299
<h3 className="pb-2">Edit Permissions</h3>
299300
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4">
@@ -744,6 +745,7 @@ export function GitIntegrationModal(
744745
};
745746

746747
return (
748+
// TODO: Use title and buttons props
747749
<Modal visible={!!props} onClose={onClose} closeable={props.closeable}>
748750
<h3 className="pb-2">{mode === "new" ? "New Git Integration" : "Git Integration"}</h3>
749751
<div className="space-y-4 border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4">

components/dashboard/src/settings/Plans.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ export default function () {
726726
</a>
727727
</InfoBox>
728728
{!!confirmUpgradeToPlan && (
729+
// TODO: Use title and buttons props
729730
<Modal visible={true} onClose={() => setConfirmUpgradeToPlan(undefined)}>
730731
<h3>Upgrade to {confirmUpgradeToPlan.name}</h3>
731732
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-4 -mx-6 px-6 py-2">
@@ -754,6 +755,7 @@ export default function () {
754755
</Modal>
755756
)}
756757
{!!confirmDowngradeToPlan && (
758+
// TODO: Use title and buttons props
757759
<Modal visible={true} onClose={() => setConfirmDowngradeToPlan(undefined)}>
758760
<h3>Downgrade to {confirmDowngradeToPlan.name}</h3>
759761
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-4 -mx-6 px-6 py-2">
@@ -783,6 +785,7 @@ export default function () {
783785
</Modal>
784786
)}
785787
{isConfirmCancelDowngrade && (
788+
// TODO: Use title and buttons props
786789
<Modal visible={true} onClose={() => setIsConfirmCancelDowngrade(false)}>
787790
<h3>Cancel downgrade and stay with {currentPlan.name}</h3>
788791
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-4 -mx-6 px-6 py-2">
@@ -799,6 +802,7 @@ export default function () {
799802
</Modal>
800803
)}
801804
{!!teamClaimModal && (
805+
// TODO: Use title and buttons props
802806
<Modal visible={true} onClose={() => setTeamClaimModal(undefined)}>
803807
<h3 className="pb-2">Team Invitation</h3>
804808
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4">

components/dashboard/src/settings/SelectAccountModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export function SelectAccountModal(
4545
};
4646

4747
return (
48+
// TODO: Use title and buttons props
4849
<Modal visible={true} onClose={props.close}>
4950
<h3 className="pb-2">Select Account</h3>
5051
<div className="border-t border-b border-gray-200 mt-2 -mx-6 px-6 py-4">

components/dashboard/src/settings/SelectIDEModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default function (props: { onClose?: () => void }) {
3333
};
3434

3535
return (
36+
// TODO: Use title and buttons props
3637
<Modal visible={visible} onClose={handleContinue} closeable={true} className="_max-w-xl">
3738
<h3 className="pb-2">Select Editor</h3>
3839
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4">

components/dashboard/src/settings/Teams.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ function AllTeams() {
514514
<a
515515
href="https://www.gitpod.io/docs/teams/"
516516
target="_blank"
517-
rel="noopener"
517+
rel="noopener noreferrer"
518518
className="gp-link"
519519
>
520520
Learn more
@@ -649,6 +649,7 @@ function InviteMembersModal(props: { sub: TeamSubscription; onClose: () => void
649649
};
650650

651651
return (
652+
// TODO: Use title and buttons props
652653
<Modal visible={true} onClose={props.onClose}>
653654
<h3 className="pb-2">Invite Members</h3>
654655
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4 space-y-2">
@@ -707,6 +708,7 @@ function AddMembersModal(props: {
707708
};
708709

709710
return (
711+
// TODO: Use title and buttons props
710712
<Modal visible={true} onClose={props.onClose}>
711713
<h3 className="pb-2">Add Members</h3>
712714
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4">
@@ -772,6 +774,7 @@ function NewTeamModal(props: {
772774
};
773775

774776
return (
777+
// TODO: Use title and buttons props
775778
<Modal visible={true} onClose={props.onClose}>
776779
<h3 className="pb-2">New Team Plan</h3>
777780
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4 space-y-2">
@@ -851,6 +854,7 @@ function ManageTeamModal(props: { slots: Slot[]; slotInputHandler: SlotInputHand
851854
}, [props.slots]);
852855

853856
return (
857+
// TODO: Use title and buttons props
854858
<Modal visible={true} onClose={props.onClose}>
855859
<h3 className="pb-2">Manage Team</h3>
856860
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4 space-y-2">

components/dashboard/src/start/CreateWorkspace.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ export default class CreateWorkspace extends React.Component<CreateWorkspaceProp
200200
return <StartWorkspace {...parseProps(result?.createdWorkspaceId, window.location.search)} />;
201201
} else if (result?.existingWorkspaces) {
202202
statusMessage = (
203+
// TODO: Use title and buttons props
203204
<Modal visible={true} closeable={false} onClose={() => {}}>
204205
<h3>Running Workspaces</h3>
205206
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-4 -mx-6 px-6 py-2">
@@ -292,6 +293,7 @@ export default class CreateWorkspace extends React.Component<CreateWorkspaceProp
292293
function LimitReachedModal(p: { children: React.ReactNode }) {
293294
const { user } = useContext(UserContext);
294295
return (
296+
// TODO: Use title and buttons props
295297
<Modal visible={true} closeable={false} onClose={() => {}}>
296298
<h3 className="flex">
297299
<span className="flex-grow">Limit Reached</span>

components/dashboard/src/teams/Members.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ export default function () {
273273
</ItemsList>
274274
</div>
275275
{genericInvite && showInviteModal && (
276+
// TODO: Use title and buttons props
276277
<Modal visible={true} onClose={() => setShowInviteModal(false)}>
277278
<h3 className="mb-4">Invite Members</h3>
278279
<div className="border-t border-b border-gray-200 dark:border-gray-800 -mx-6 px-6 py-4 flex flex-col">

components/dashboard/src/whatsnew/WhatsNew.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export function WhatsNew(props: { onClose: () => void }) {
6868
};
6969

7070
return (
71+
// TODO: Use title and buttons props
7172
<Modal visible={!!visibleEntry} onClose={internalClose}>
7273
<h3 className="pb-4">What's New 🎁</h3>
7374
<>{visibleEntry && user ? visibleEntry.children(user, setUser) : <></>}</>

components/dashboard/src/workspaces/ConnectToSSHModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export default function ConnectToSSHModal(props: {
9999
onClose: () => void;
100100
}) {
101101
return (
102+
// TODO: Use title and buttons props
102103
<Modal visible={true} onClose={props.onClose}>
103104
<h3 className="mb-4">Connect via SSH</h3>
104105
<SSHView workspaceId={props.workspaceId} ownerToken={props.ownerToken} ideUrl={props.ideUrl} />

components/dashboard/src/workspaces/StartWorkspaceModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export function StartWorkspaceModal() {
2020
}, [location]);
2121

2222
return (
23+
// TODO: Use title and buttons props
2324
<Modal
2425
onClose={() => setIsStartWorkspaceModalVisible(false)}
2526
onEnter={() => false}

components/dashboard/src/workspaces/WorkspaceEntry.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ export function WorkspaceEntry({ desc, model, isAdmin, stopWorkspace }: Props) {
207207
onConfirm={() => model.deleteWorkspace(ws.id)}
208208
/>
209209
)}
210+
{/* TODO: Use title and buttons props */}
210211
<Modal
211212
visible={isRenameModalVisible}
212213
onClose={() => setRenameModalVisible(false)}

0 commit comments

Comments
 (0)