Skip to content

Conversation

@filiptronicek
Copy link
Member

@filiptronicek filiptronicek commented Dec 9, 2024

Description

Adds a /insights page, offering access to the listing from WorkspaceService.ListWorkspaceSessions both as a table and as a downloadable CSV, similar to the one under /usage.

image

Related Issue(s)

Fixes CLC-1017

How to test

  1. Join my org (to get some initial data)
  2. (optional) start a workspace
  3. Check out /insights, along with the downloadable CSV

Documentation

Possibly, yeah. It's not as crucial now, though, since it's not publicly accessible (without knowing about the endpoint) and also pretty straight forward as far as interaction goes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return (
<li key={index} className="text-sm text-gray-600 dark:text-gray-300">
{session.creationTime ? displayTime(session.creationTime) : "n/a"} (
{session.workspace?.status?.instanceId.slice(0, 7) || "No instance ID"}){isRunning ? " - running" : ""}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should get rid of this or add our little colored circle icon like we have in the ws list.

type Args = Pick<ListWorkspaceSessionsRequest, "organizationId" | "from" | "to"> & {
organizationName: string;
signal?: AbortSignal;
onProgress?: (percentage: number) => void;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pagination is another issue that I faced here - WorkspaceService.ListWorkspaceSessions does not properly report a total, so we can't know how far in the process we are. For now, we just report "Exporting page ${n}".

Comment on lines -472 to +473
.offset(offset)
.limit(limit)
.skip(offset)
.take(limit)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This caused some inconsistencies with the way we design our pagination in other API calls, so I aligned it with those.

Comment on lines 75 to 79
<SelectItem value="day">Last 24 hours</SelectItem>{" "}
{/* here for debugging, probably not useful */}
<SelectItem value="week">Last 7 days</SelectItem>
<SelectItem value="month">Last 30 days</SelectItem>
<SelectItem value="year">Last 365 days</SelectItem>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not see a good reason for being able to select an absolute time range (like we use today with the usage dashboard), so I just made it use some relative options.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also because I don't really enjoy using date pickers

}

// WorkspaceContext is the git context from which the workspace is created
message WorkspaceContext {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added so that we can fill in the values for contextURLSegment_1, contextURLSegment_2 and contextURL_cloneURL in the CSV. I imagine that it can come in handy to get it directly from the API as well.

What I want to draw attention to is that I did not add the ws ctx as a top-level property (like it is for workspaces in the DB and in the protocol), but rather hid it under metadata. I'm happy to push it up, but it made sense at the time I was trying to use it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I think what you proposed makes sense in itself, and feels like a nice "completion" of our API, I don't feel the usecase we have is a compelling reason to add the WorkspaceContext shape (with all it's complexity) to the (central) Workspace shape.

My two main concerns are:

  1. extent: most of the fields exposed here we won't use going forward - not even in the narrow use-case we have right now
  2. exposing the concept of WorkspaceContext right now, with such little benefit, but a significant "cost"
  • this shows in the "where to place it" problem
  • adding it now would severely reduce our solution space if we really needed it in the future (a bit speculative given the state of Classic, but still)

Could we get a way without adding this shape at all? E.g. treat contextUrl as URL, and just focus on the path elements? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@geropl this is definitely fair. The addition of the workspace context is something I tried to really get around - it's true we most likely won't be able to use this much outside of the context of workspace sessions and insights1.

I have tried some simple parsing of context URLs, but because we don't offer the cloneURL on the Workspace responses, there is close to no way to parse URLs and split segments properly without running into the question of "is this a repo name part, a subgroup or already some extra path like /commits?".

Additionally, we could really expose some bare-bones information, potentially just on the WorkspaceSession object.

Footnotes

  1. that said, the flip side here is that now folks utilizing our ListWorkspaceSessions responses will be able to have a lot more data about the contexts, and will be able to answer adoption-related questions like "do users open PRs/MRs with Gitpod?"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that said, the flip side here is that now folks utilizing our ListWorkspaceSessions responses will be able to have a lot more data about the contexts, and will be able to answer adoption-related questions like "do users open PRs/MRs with Gitpod?"

That is a good argument indeed. Let me dwell a bit on it.

I have tried some simple parsing of context URLs, but because we don't offer the cloneURL

Argh, you are right. The naming of fields is really all over the place 😬

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In sync, we decided to keep all of the details, but stick them under the WorkspaceSession shape.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've implemented the changes as discussed in 79a97aa.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ping me once it's finalized and the preview is ready (still seeing the "react flower" on the bottom, so you might still be changing things...?). 🙏

@filiptronicek filiptronicek self-assigned this Dec 11, 2024
@filiptronicek filiptronicek marked this pull request as ready for review December 11, 2024 14:01
Copy link
Contributor

@mustard-mh mustard-mh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code and preview env looks great!

One more question, do we plan to provide a link on the dashboard to access the "/insights" page?

Update: Found this on PR description

Possibly, yeah. It's not as crucial now, though, since it's not publicly accessible (without knowing about the endpoint) and also pretty straight forward as far as interaction goes.

@socket-security
Copy link

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@radix-ui/[email protected] None +14 349 kB chancestrickland

View full report↗︎

Copy link
Member

@geropl geropl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM, tested and works! ✔️ 🎉

Awesome work Filip 🚀

@roboquat roboquat merged commit a303660 into main Dec 12, 2024
19 checks passed
@roboquat roboquat deleted the ft/add-insights-page branch December 12, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants