Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a portal redirect endpoint #23375

Merged
merged 26 commits into from
Jul 2, 2024

Conversation

zlwaterfield
Copy link
Contributor

@zlwaterfield zlwaterfield commented Jul 1, 2024

Problem

Right now we load a portal session every time the user loads the app and we only cache it for 60 seconds which means we generate a TON of them. This isn't good practice and they should really be generated jit-in-time when the user requests it.

Changes

This PR updates the stripe_portal_url in the billing response to be a fixed endpoint from the API that the client can redirect to, which will generate the portal session and redirect the user to. No other changes have been made. Nice and simple :)

I updated the fixtures to match this pattern and added a test for portal endpoint.

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

How did you test this code?

Tested manually and added a test.

@zlwaterfield zlwaterfield self-assigned this Jul 1, 2024
@zlwaterfield zlwaterfield changed the title Add a portal redirect endpoint feat: add a portal redirect endpoint Jul 1, 2024
Copy link
Contributor

github-actions bot commented Jul 1, 2024

Size Change: 0 B

Total Size: 1.06 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 1.06 MB

compressed-size-action

@@ -85,8 +86,7 @@ def get_billing(self, organization: Optional[Organization], plan_keys: Optional[
products = self.get_default_products(organization)
response["products"] = products["products"]

stripe_portal_url = self._get_stripe_portal_url(organization)
response["stripe_portal_url"] = stripe_portal_url
response["stripe_portal_url"] = f"{settings.SITE_URL}/api/billing/portal"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the main change for the PR.

@zlwaterfield zlwaterfield requested a review from raquelmsmith July 1, 2024 19:14
EDsCODE and others added 16 commits July 2, 2024 12:28
* should be optional

* adjust test to account for null status

* Update query snapshots

* Update query snapshots

* func name

* Update query snapshots

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Dylan Martin <[email protected]>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
I've added a new option that survey authors can select so that we can show a survey every time an event in their selection occurs, not just the first time.

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Juraj Majerik <[email protected]>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
@zlwaterfield zlwaterfield merged commit c62058c into master Jul 2, 2024
91 checks passed
@zlwaterfield zlwaterfield deleted the zach/generate-less-stripe-portal-sessions branch July 2, 2024 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.