-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
chore: platform api usage based billing using queue #15085
base: main
Are you sure you want to change the base?
Conversation
Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link. |
Graphite Automations"Add foundation team as reviewer" took an action on this PR • (05/16/24)1 reviewer was added to this PR based on Keith Williams's automation. "Add platform team as reviewer" took an action on this PR • (05/16/24)1 reviewer was added to this PR based on Keith Williams's automation. |
🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎ To accept the risk, merge this PR and you will not be notified again.
Next stepsWhat is an install script?Install scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts. Packages should not be running non-essential scripts during install and there are often solutions to problems people solve with install scripts that can be run at publish time instead. What is telemetry?This package contains telemetry which tracks how it is used. Most telemetry comes with settings to disable it. Consider disabling telemetry if you do not want to be tracked. Take a deeper look at the dependencyTake a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev. Remove the packageIf you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency. Mark a package as acceptable riskTo ignore an alert, reply with a comment starting with
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Ignored Deployments
|
📦 Next.js Bundle Analysis for @calcom/webThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
…al.com into chore-platformapi-billing-queue
…alcom/cal.com into chore-platformapi-billing-queue
Current Playwright Test Results Summary✅ 321 Passing - Run may still be in progress, this comment will be updated as current testing workflow or job completes... (Last updated on 05/18/2024 06:12:57am UTC) Run DetailsRunning Workflow PR Update on Github Actions Commit: 2f0fdf0 Started: 05/18/2024 06:10:46am UTC
|
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Reschedule for booking with seats If rescheduled/cancelled booking with seats it should display the correct number of seats
Retry 1 • Initial Attempt |
0% (0)0 / 212 runsfailed over last 7 days |
1.89% (4)4 / 212 runsflaked over last 7 days |
📄 apps/web/playwright/profile.e2e.ts • 1 Flake
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Update Profile Can update a users email (verification enabled)
Retry 2 • Retry 1 • Initial Attempt |
38.02% (92)92 / 242 runsfailed over last 7 days |
33.47% (81)81 / 242 runsflaked over last 7 days |
📄 packages/app-store/routing-forms/playwright/tests/basic.e2e.ts • 1 Flake
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Routing Forms Seeded Routing Form Test preview should return correct route
Retry 1 • Initial Attempt |
0.91% (2)2 / 219 runsfailed over last 7 days |
31.05% (68)68 / 219 runsflaked over last 7 days |
📄 apps/web/playwright/event-types.e2e.ts • 1 Flake
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Event Types tests -- legacy user Different Locations Tests Can remove location from multiple locations that are saved
Retry 1 • Initial Attempt |
4.48% (10)10 / 223 runsfailed over last 7 days |
19.28% (43)43 / 223 runsflaked over last 7 days |
📄 apps/web/playwright/managedBooking/advancedOptions.e2e.ts • 1 Flake
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Check advanced options in a managed team event type Check advanced options in a managed team event type without offer seats
Retry 1 • Initial Attempt |
0.45% (1)1 / 220 runfailed over last 7 days |
48.18% (106)106 / 220 runsflaked over last 7 days |
📄 apps/web/playwright/signup.e2e.ts • 1 Flake
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Signup Flow Test Email verification sent if enabled
Retry 1 • Initial Attempt |
0.85% (2)2 / 234 runsfailed over last 7 days |
25.64% (60)60 / 234 runsflaked over last 7 days |
📄 packages/embeds/embed-core/playwright/tests/namespacing.e2e.ts • 4 Flakes
Top 1 Common Error Messages
|
4 Test Cases Affected |
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Namespacing Inline Embed Add inline embed using a namespace without reload
Retry 1 • Initial Attempt |
0.46% (1)1 / 219 runfailed over last 7 days |
60.27% (132)132 / 219 runsflaked over last 7 days |
Namespacing Inline Embed Double install Embed Snippet with inline embed without a namespace(i.e. default namespace)
Retry 1 • Initial Attempt |
0% (0)0 / 219 runsfailed over last 7 days |
63.01% (138)138 / 219 runsflaked over last 7 days |
Namespacing Inline Embed Double install Embed Snippet with inline embed using a namespace
Retry 1 • Initial Attempt |
0.46% (1)1 / 219 runfailed over last 7 days |
60.27% (132)132 / 219 runsflaked over last 7 days |
Namespacing Different namespaces can have different init configs
Retry 1 • Initial Attempt |
0% (0)0 / 217 runsfailed over last 7 days |
60.37% (131)131 / 217 runsflaked over last 7 days |
📄 apps/web/playwright/hash-my-url.e2e.ts • 1 Flake
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
hash my url generate url hash
Retry 2 • Retry 1 • Initial Attempt |
5.96% (13)13 / 218 runsfailed over last 7 days |
27.98% (61)61 / 218 runsflaked over last 7 days |
📄 apps/web/playwright/teams.e2e.ts • 1 Flake
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Teams - NonOrg -- legacy Can create a booking for Round Robin EventType
Retry 2 • Retry 1 • Initial Attempt |
7.30% (17)17 / 233 runsfailed over last 7 days |
28.76% (67)67 / 233 runsflaked over last 7 days |
📄 apps/web/playwright/organization/booking.e2e.ts • 1 Flake
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Bookings Team Event Can create a booking for Round Robin EventType
Retry 2 • Retry 1 • Initial Attempt |
7.89% (18)18 / 228 runsfailed over last 7 days |
27.63% (63)63 / 228 runsflaked over last 7 days |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have refactor suggestions below.
Also, do you think it's possible to add tests to ensure that queue works as expected? It's hard to test this one manually.
…b.com:calcom/cal.com into chore-platformapi-billing-queue
…al.com into chore-platformapi-billing-queue
@ThyMinimalDev Curious if you think we could achieve the same result by having a cron running every X minutes that calculates number of bookings completed and updates usage? With that approach, we don't need to handle all this logic to chase down the message that was pushed to the queue in the future. |
A cron is a good option as well, we could have it look at the non cancelled booking of managed users that are in the past, we would need to add en entry in the database to index and filter the ones that have not yet been counted toward usage I don't think we would need to worry about stripe rate limiting until some time |
Would we actually need this if you can just compare the count of the current bookings - even if you keep a running count elsewhere - redis for example? Then every billing period we just compare the current usage to the value we have in redis and charge accordingly. I was just thinking of ways to do this without queues as it feels weird if i booking is 3 months in advance, do i want that job sitting waiting to run for that long? |
that's a good idea, only difficulty I can see is that everyone has different billing cycles in the end I think the complexity is same-same, but different |
Agreed - I just wonder if that is a easier / better approach than doing it via canceling a job. I dont think billing cycles are an issue here if we already have a cron running every day to update this "count" we can check if its like a day before the billing date for that subscription then push the usage record to stripe? Should probably be an RFC where we come up with a standard to do this cause private-api needs it too |
I think the ea
If we don't want to use jobs, the easiest is to increment a count in a redis store, and have a cron that runs often enough to push the usage to stripe and reset it to 0, that way we don't to worry about billing cycles |
What does this PR do?
Usage based billing for platform api using Bull Queue
if you are wondering why we don't simply tell stripe to decrement usage, it's simply because stripe does not allow it.