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

Customers architecture #4590

Merged
merged 47 commits into from
Dec 16, 2024
Merged

Customers architecture #4590

merged 47 commits into from
Dec 16, 2024

Conversation

frankie567
Copy link
Member

No description provided.

Copy link

vercel bot commented Dec 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
polar ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 16, 2024 7:56am
polar-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 16, 2024 7:56am

Copy link
Contributor

github-actions bot commented Dec 3, 2024

📦 Next.js Bundle Analysis for web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

New Pages Added

The following pages were added to the bundle from the code in this PR:

Page Size (compressed) First Load % of Budget (350 KB)
/(main)/[organization]/portal/page 105.92 KB 260.37 KB 74.39%
/(main)/[organization]/portal/layout 83.46 KB 237.91 KB 67.97%
/(main)/[organization]/portal/request/page 67.19 KB 221.64 KB 63.33%
/(main)/[organization]/portal/orders/[id]/page 194.8 KB 349.25 KB 99.79%
/(main)/[organization]/portal/subscriptions/[id]/page 199.03 KB 353.48 KB 100.99%
/(main)/[organization]/portal/authenticate/page 70.9 KB 225.35 KB 64.39%
/(main)/dashboard/[organization]/(header)/customers/page 594.37 KB 748.82 KB 213.95%

One Hundred Sixteen Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (350 KB)
/not-found 47.54 KB 201.99 KB 57.71% (+/- <0.01%)
/layout 110.8 KB 265.26 KB 75.79% (🟡 +0.11%)
/error 10.09 KB 164.54 KB 47.01% (🟡 +0.01%)
/global-error 10.12 KB 164.58 KB 47.02% (🟡 +0.01%)
/checkout/[clientSecret]/confirmation/page 269.25 KB 423.7 KB 121.06% (🔴 +22.51%)
/checkout/[clientSecret]/page 261.11 KB 415.56 KB 118.73% (🟡 +1.23%)
/(main)/layout 80.03 KB 234.48 KB 66.99% (🟡 +0.09%)
/(main)/signup/page 135.09 KB 289.54 KB 82.73% (🟢 -0.33%)
/(main)/login/page 161.15 KB 315.6 KB 90.17% (🟢 -0.32%)
/(main)/login/magic-link/request/page 361 B 154.8 KB 44.23% (+/- <0.01%)
/(main)/new/page 11.57 KB 166.02 KB 47.43% (🟡 +0.01%)
/(main)/(installation)/github/installation/page 128.9 KB 283.35 KB 80.96% (🟡 +0.09%)
/(main)/(topbar)/layout 240.78 KB 395.23 KB 112.92% (🟢 -0.35%)
/(main)/(topbar)/not-found 47.54 KB 201.99 KB 57.71% (+/- <0.01%)
/(main)/[organization]/(header)/layout 265.45 KB 419.91 KB 119.97% (🟢 -0.38%)
/(main)/[organization]/(header)/issues/page 122.2 KB 276.65 KB 79.04% (🟡 +0.09%)
/(main)/[organization]/(header)/subscriptions/page 360 B 154.8 KB 44.23% (+/- <0.01%)
/(main)/[organization]/(header)/products/[productId]/page 191.36 KB 345.81 KB 98.80% (🟡 +1.47%)
/(main)/[organization]/[repo]/issues/[number]/(create)/page 194.93 KB 349.38 KB 99.82% (🟢 -0.29%)
/(main)/[organization]/[repo]/layout 232.19 KB 386.64 KB 110.47% (🟢 -0.32%)
/(main)/[organization]/(header)/page 134.09 KB 288.54 KB 82.44% (🟡 +0.08%)
/(main)/[organization]/[repo]/page 205.06 KB 359.51 KB 102.72% (🟡 +0.09%)
/(main)/[organization]/[repo]/issues/[number]/status/page 228.45 KB 382.91 KB 109.40% (🟡 +0.30%)
/(main)/backoffice/pledges/page 55.38 KB 209.83 KB 59.95% (🟡 +0.09%)
/(main)/backoffice/layout 564.91 KB 719.36 KB 205.53% (🟢 -0.28%)
/(main)/backoffice/rewards_pending/page 57.14 KB 211.59 KB 60.45% (🟡 +0.10%)
/(main)/backoffice/issue/[id]/page 53.12 KB 207.57 KB 59.31% (🟡 +0.09%)
/(main)/backoffice/badge/page 43.18 KB 197.63 KB 56.47% (🟡 +0.09%)
/(main)/backoffice/rebadge/page 40.64 KB 195.09 KB 55.74% (🟡 +0.09%)
/(main)/dashboard/layout 359 B 154.8 KB 44.23% (+/- <0.01%)
/(main)/docs/api/[...endpoint]/page 495.46 KB 649.92 KB 185.69% (🟢 -0.01%)
/(main)/docs/layout 361 B 154.8 KB 44.23% (+/- <0.01%)
/(main)/(landing)/page 491.86 KB 646.32 KB 184.66% (🟡 +0.99%)
/(main)/(landing)/layout 207.58 KB 362.03 KB 103.44% (🟢 -0.32%)
/(main)/(topbar)/(backer)/purchases/products/[id]/page 194.95 KB 349.4 KB 99.83% (🟢 -22.69%)
/(main)/(topbar)/(backer)/layout 79.27 KB 233.72 KB 66.78% (🟡 +0.09%)
/(main)/(topbar)/(backer)/purchases/license-keys/page 88.59 KB 243.04 KB 69.44% (🟡 +0.11%)
/(main)/(topbar)/(backer)/purchases/page 361 B 154.8 KB 44.23% (+/- <0.01%)
/(main)/(topbar)/(backer)/purchases/products/page 88.72 KB 243.17 KB 69.48% (🟡 +0.10%)
/(main)/(topbar)/(backer)/purchases/subscriptions/[id]/page 199.26 KB 353.71 KB 101.06% (🟢 -21.99%)
/(main)/(topbar)/(backer)/purchases/subscriptions/page 88.28 KB 242.73 KB 69.35% (🟡 +0.10%)
/(main)/(topbar)/(backer)/settings/page 253.1 KB 407.55 KB 116.44% (🟢 -0.26%)
/(main)/(topbar)/(backer)/purchases/file-downloads/page 174.59 KB 329.04 KB 94.01% (🟡 +0.11%)
/(main)/dashboard/(create)/create/page 151.39 KB 305.84 KB 87.38% (🟡 +0.06%)
/(main)/dashboard/(create)/layout 359 B 154.8 KB 44.23% (+/- <0.01%)
/(main)/dashboard/[organization]/storefront/page 374.5 KB 528.96 KB 151.13% (🟡 +6.98%)
/(main)/dashboard/[organization]/layout 45.67 KB 200.12 KB 57.18% (🟡 +0.09%)
/(main)/(landing)/(mdx)/careers/page 33.09 KB 187.55 KB 53.58% (🟡 +0.01%)
/(main)/(landing)/(mdx)/blog/(header)/mitchell-hashimoto-joins-polar-as-an-advisor/page 33.09 KB 187.55 KB 53.58% (🟡 +0.01%)
/(main)/(landing)/(mdx)/legal/terms/page 33.09 KB 187.55 KB 53.58% (🟡 +0.01%)
/(main)/docs/(mdx)/customers/purchases/page 33.09 KB 187.55 KB 53.58% (🟡 +0.01%)
/(main)/docs/(mdx)/layout 495.28 KB 649.74 KB 185.64% (🟢 -0.01%)
/(main)/docs/(mdx)/github/funding-yaml/page 33.09 KB 187.54 KB 53.58% (+/- <0.01%)
/(main)/docs/(mdx)/merchant-of-record/compliance/page 33.09 KB 187.55 KB 53.58% (+/- <0.01%)
/(main)/docs/(mdx)/payments-taxes/page 33.09 KB 187.55 KB 53.58% (+/- <0.01%)
/(main)/docs/(mdx)/onboarding/page 179.47 KB 333.92 KB 95.41% (🟢 -0.33%)
/(main)/docs/developers/(mdx)/layout 495.28 KB 649.73 KB 185.64% (🟢 -0.01%)
/(main)/docs/api/(mdx)/page 33.09 KB 187.55 KB 53.58% (🟡 +0.01%)
/(main)/docs/api/(mdx)/layout 495.28 KB 649.73 KB 185.64% (🟢 -0.01%)
/(main)/docs/api/(mdx)/authentication/page 226.5 KB 380.95 KB 108.84% (🟢 -0.24%)
/(main)/docs/developers/open-source/layout 495.28 KB 649.73 KB 185.64% (🟢 -0.01%)
/(main)/docs/developers/sandbox/layout 495.28 KB 649.73 KB 185.64% (🟢 -0.01%)
/(main)/docs/developers/sdk/polar-for-framer/page 33.09 KB 187.55 KB 53.58% (🟡 +0.01%)
/(main)/docs/developers/sdk/layout 495.27 KB 649.73 KB 185.64% (🟢 -0.01%)
/(main)/docs/developers/sdk/python/page 33.09 KB 187.55 KB 53.58% (🟡 +0.01%)
/(main)/docs/developers/sdk/typescript/page 33.09 KB 187.55 KB 53.58% (🟡 +0.01%)
/(main)/docs/developers/sdk/page 33.09 KB 187.55 KB 53.58% (🟡 +0.01%)
/(main)/docs/developers/guides/page 362 B 154.81 KB 44.23% (+/- <0.01%)
/(main)/docs/developers/guides/layout 495.28 KB 649.73 KB 185.64% (🟢 -0.01%)
/(main)/docs/support/layout 495.27 KB 649.73 KB 185.64% (🟢 -0.01%)
/(main)/docs/developers/webhooks/events/page 361 B 154.8 KB 44.23% (+/- <0.01%)
/(main)/docs/developers/webhooks/layout 495.55 KB 650 KB 185.71% (🟢 -0.01%)
/(main)/(topbar)/(backer)/finance/account/page 201.3 KB 355.75 KB 101.64% (🟡 +0.09%)
/(main)/(topbar)/(backer)/finance/layout 213.48 KB 367.94 KB 105.12% (🟢 -0.28%)
/(main)/(topbar)/(backer)/finance/incoming/page 234 KB 388.45 KB 110.99% (🟡 +0.09%)
/(main)/(topbar)/(backer)/finance/outgoing/page 183.94 KB 338.39 KB 96.68% (🟡 +0.22%)
/(main)/(topbar)/(backer)/(sidebar)/funding/page 247.17 KB 401.62 KB 114.75% (🟡 +0.09%)
/(main)/(topbar)/(backer)/(sidebar)/layout 135.12 KB 289.57 KB 82.74% (🟡 +0.10%)
/(main)/(topbar)/(backer)/finance/rewards/page 113.64 KB 268.09 KB 76.60% (🟡 +0.09%)
/(main)/dashboard/[organization]/(header)/@breadcrumb/[...all]/page 37.51 KB 191.97 KB 54.85% (+/- <0.01%)
/(main)/dashboard/[organization]/(header)/@breadcrumb/layout 50.92 KB 205.38 KB 58.68% (+/- <0.01%)
/(main)/dashboard/[organization]/(header)/analytics/page 694.46 KB 848.92 KB 242.55% (🟢 -0.28%)
/(main)/dashboard/[organization]/(header)/layout 564.9 KB 719.35 KB 205.53% (🟢 -0.28%)
/(main)/dashboard/[organization]/(header)/benefits/license-keys/page 591.91 KB 746.37 KB 213.25% (🟢 -0.19%)
/(main)/dashboard/[organization]/(header)/benefits/page 658.24 KB 812.7 KB 232.20% (🟡 +1.03%)
/(main)/dashboard/[organization]/(header)/initialize/page 145.6 KB 300.05 KB 85.73% (🟡 +1.45%)
/(main)/dashboard/[organization]/(header)/issues/badge/page 592.51 KB 746.96 KB 213.42% (🟡 +0.97%)
/(main)/dashboard/[organization]/(header)/issues/organizations/page 567.27 KB 721.73 KB 206.21% (🟢 -0.28%)
/(main)/dashboard/[organization]/(header)/issues/overview/page 607.87 KB 762.32 KB 217.81% (🟡 +1.26%)
/(main)/dashboard/[organization]/(header)/@breadcrumb/products/[id]/page 50.93 KB 205.38 KB 58.68% (+/- <0.01%)
/(main)/dashboard/[organization]/(header)/@breadcrumb/products/layout 37.52 KB 191.97 KB 54.85% (+/- <0.01%)
/(main)/dashboard/[organization]/(header)/products/[id]/page 653.53 KB 807.98 KB 230.85% (🟡 +1.08%)
/(main)/dashboard/[organization]/(header)/products/benefits/page 657.77 KB 812.22 KB 232.06% (🟡 +1.03%)
/(main)/dashboard/[organization]/(header)/@breadcrumb/products/new/page 37.51 KB 191.97 KB 54.85% (+/- <0.01%)
/(main)/dashboard/[organization]/(header)/products/new/page 645.91 KB 800.37 KB 228.68% (🟡 +1.08%)
/(main)/dashboard/[organization]/(header)/products/discounts/page 625.34 KB 779.8 KB 222.80% (🟢 -0.13%)
/(main)/dashboard/[organization]/(header)/members/page 565.77 KB 720.22 KB 205.78% (🟢 -0.28%)
/(main)/dashboard/[organization]/(header)/products/page 593.54 KB 748 KB 213.71% (🟢 -0.28%)
/(main)/dashboard/[organization]/(header)/sales/page 608.54 KB 762.99 KB 218.00% (🟢 -0.28%)
/(main)/dashboard/[organization]/(header)/@breadcrumb/settings/webhooks/endpoints/[id]/page 50.92 KB 205.38 KB 58.68% (+/- <0.01%)
/(main)/dashboard/[organization]/(header)/@breadcrumb/settings/layout 37.52 KB 191.97 KB 54.85% (+/- <0.01%)
/(main)/dashboard/[organization]/(header)/settings/webhooks/endpoints/[id]/page 595.89 KB 750.35 KB 214.38% (🟢 -0.28%)
/(main)/dashboard/[organization]/(header)/settings/custom-fields/page 597.25 KB 751.7 KB 214.77% (🟢 -0.28%)
/(main)/dashboard/[organization]/(header)/issues/embed/page 567.36 KB 721.82 KB 206.23% (🟢 -0.28%)
/(main)/dashboard/[organization]/(header)/settings/page 584.44 KB 738.89 KB 211.11% (🟢 -0.28%)
/(main)/dashboard/[organization]/(header)/sales/subscriptions/page 595.04 KB 749.49 KB 214.14% (🟢 -0.01%)
/(main)/dashboard/[organization]/(header)/(home)/page 654.4 KB 808.85 KB 231.10% (🟡 +1.08%)
/(main)/dashboard/[organization]/(header)/settings/webhooks/page 578.72 KB 733.17 KB 209.48% (🟢 -0.28%)
/(main)/dashboard/[organization]/(header)/finance/incoming/page 183.93 KB 338.39 KB 96.68% (🟡 +0.09%)
/(main)/dashboard/[organization]/(header)/finance/layout 564.91 KB 719.36 KB 205.53% (🟢 -0.28%)
/(main)/dashboard/[organization]/(header)/finance/outgoing/page 133.5 KB 287.95 KB 82.27% (🟡 +0.10%)
/(main)/dashboard/[organization]/(header)/finance/account/page 151.37 KB 305.83 KB 87.38% (🟡 +0.08%)
/(main)/dashboard/[organization]/(header)/finance/issue-funding/page 64.13 KB 218.59 KB 62.45% (🟡 +0.09%)
/(main)/dashboard/[organization]/(header)/finance/issue-funding/layout 564.91 KB 719.36 KB 205.53% (🟢 -0.28%)
/(main)/dashboard/[organization]/(header)/finance/issue-funding/contributors/page 63.42 KB 217.87 KB 62.25% (🟡 +0.09%)
/(main)/dashboard/[organization]/(header)/finance/issue-funding/rewarded/page 63.41 KB 217.87 KB 62.25% (🟡 +0.09%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.

@frankie567 frankie567 force-pushed the feat/customers-1 branch 3 times, most recently from 5841849 to 33c981f Compare December 3, 2024 12:26
def _get_readable_customer_statement(
self, auth_subject: AuthSubject[User | Organization]
) -> Select[tuple[Customer]]:
statement = select(Customer).where(Customer.deleted_at.is_(None))
Copy link
Member Author

Choose a reason for hiding this comment

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

We may need to allow to list deleted customers to get historical data.

@frankie567 frankie567 force-pushed the feat/customers-1 branch 3 times, most recently from 93ae45f to 477d2b1 Compare December 9, 2024 12:57
@frankie567 frankie567 force-pushed the feat/customers-1 branch 4 times, most recently from 7b5bd6a to 9752b93 Compare December 11, 2024 13:16
We already have a token at hand which should be enough to prove access
Ease migration from Users.

Also fixes the logic that were trying to tie a payment Transaction to a Customer/User. It was simply not working because most of the time, the Customer/User didn't exist at the time of handling the transaction. Now, we link it when handling the Order, which already had some logic to update that Transaction.
The builtin EventSource class doesn't support to pass custom headers to the request, like Authorization.

From what I read, this class is somewhat deprecated and browser developers encourage to use `fetch` instead. The thing is, it's a much lower level API which doesn't do the work of reading and parsing the stream. Ref: whatwg/html#2177

I found `event-source-plus`, a library which does all that work on top of `fetch`.
Copy link

sentry-io bot commented Dec 16, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ IntegrityError: (sqlalchemy.dialects.postgresql.asyncpg.IntegrityError) <class 'asyncpg.exceptions.UniqueViolatio... polar.checkout.endpoints.client_confirm View Issue

Did you find this useful? React with a 👍 or 👎

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.

1 participant