Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Make SSC base url dynamic#62790

Merged
vdavid merged 7 commits into
mainfrom
dv/make-ssc-base-url-dynamic
May 21, 2024
Merged

Make SSC base url dynamic#62790
vdavid merged 7 commits into
mainfrom
dv/make-ssc-base-url-dynamic

Conversation

@vdavid

@vdavid vdavid commented May 20, 2024

Copy link
Copy Markdown
Contributor

For a long time, it was annoying that we couldn't properly test some SSC features because https://accounts.sourcegraph.com/cody/subscription (production URL) was hard-coded for the "Manage subscription" links.
This PR makes that setting dynamic.

Also:

  • It wires up the "Create a Cody Pro team" button to pass an extra ?team=1 argument which we'll handle on the checkout page.
  • It contains an unrelated event logging cleanup because the deprecation warnings made it difficult for me to focus on the linter warnings related to my PR.

Note: If sscBaseUrl is not configured in the site config, it falls back to the previously hard-coded URL https://accounts.sourcegraph.com/cody.

The PR consists of four individual commits to make the PR review easier.

Test plan

Tested it manually: it works nicely.

@vdavid vdavid requested a review from a team May 20, 2024 11:00
@cla-bot cla-bot Bot added the cla-signed label May 20, 2024

@chrsmith chrsmith left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This LGTM, and thanks for taking care of it. But IMHO we should probably keep the specific URL we need the user to navigate to in the utils.ts file.

Just so that we have a single location where that exists in the code, and therefore can make any changes without unintentionally forgetting to update "all places" where we generate the URL and introduce bugs down the road.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the purpose of ?team=1? It is probably worth calling out in a code comment, since it isn't entirely obvious why (or even if) that is required?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

?team=1 is the only difference between the actions of the "Create a Cody Pro team" and "Upgrade yourself to Pro" buttons. The checkout UI should initiate slightly differently. I don't remember the exact diff in the Figma, but there was something, maybe the initial value of the seat counter.

I'll call this out in a comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread client/web/src/cody/util.ts Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Rather than defining this as a constant in two places, can we instead just make this a function instead? And that way we only have the logic for what the subscription management URL should be, in only one place?

e.g.

// getManageSubscriptionUrl returns the URL that a user should navigate to in order
// to manage their Cody Pro subscription.
export function getManageSubscriptionUrl(): string {
    ...
}

Having a "single source of truth" for something important like that seems like it would be in our best interest. Since otherwise, it's super easy to forget to find all places where we have code to generate the URL. (And therefore, could use a different name or do it in such a way we'd miss it when we need to modify the URL when we go live with the UI migrated to the Sourcegraph.com.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@vdavid vdavid force-pushed the dv/make-ssc-base-url-dynamic branch from d9c8559 to 41964e8 Compare May 21, 2024 09:40
@vdavid vdavid enabled auto-merge (squash) May 21, 2024 09:41
@vdavid vdavid merged commit 376a737 into main May 21, 2024
@vdavid vdavid deleted the dv/make-ssc-base-url-dynamic branch May 21, 2024 09:58
@chrsmith

Copy link
Copy Markdown
Contributor

Note: If sscBaseUrl is not configured in the site config, it falls back to the previously hard-coded URL https://accounts.sourcegraph.com/cody.

For posterity, the "default" value in the site.schema.json file absolutely does not do what you think it does. And if you do want to set a default value, you need to actually hard-code it in all of the locations where we would read the value.

(Which I guess is the purpose of internal/conf/computed.go.) 😭

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants