Skip to content

Commit 045b83f

Browse files
jankeromnesmustard-mh
authored andcommitted
[server] Track snapshot access requests, and whether they are granted or denied
1 parent 6a1262f commit 045b83f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

components/server/src/workspace/gitpod-server-impl.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,8 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
836836
]);
837837

838838
if (SnapshotContext.is(context)) {
839+
// TODO(janx): Remove snapshot access tracking once we're certain that enforcing repository read access doesn't disrupt the snapshot UX.
840+
this.trackEvent(ctx, { event: "snapshot_access_request", properties: { snapshot_id: context.snapshotId } }).catch();
839841
const snapshot = await this.workspaceDb.trace(ctx).findSnapshotById(context.snapshotId);
840842
if (!snapshot) {
841843
throw new ResponseError(ErrorCodes.NOT_FOUND, "No snapshot with id '" + context.snapshotId + "' found.");
@@ -847,11 +849,13 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
847849
try {
848850
await this.guardAccess({ kind: "snapshot", subject: snapshot, workspace }, "get");
849851
} catch (error) {
852+
this.trackEvent(ctx, { event: "snapshot_access_denied", properties: { snapshot_id: context.snapshotId, error: String(error) } }).catch();
850853
if (UnauthorizedError.is(error)) {
851854
throw error;
852855
}
853856
throw new ResponseError(ErrorCodes.PERMISSION_DENIED, `Snapshot URLs require read access to the underlying repository. Please request access from the repository owner.`)
854857
}
858+
this.trackEvent(ctx, { event: "snapshot_access_granted", properties: { snapshot_id: context.snapshotId } }).catch();
855859
}
856860

857861
// if we're forced to use the default config, mark the context as such

0 commit comments

Comments
 (0)