Skip to content

chore(billing): Reduce hardcoding of data categories in ondemand budget utility functions #90545

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dashed
Copy link
Member

@dashed dashed commented Apr 28, 2025

Part of https://linear.app/getsentry/issue/BIL-520/refactor-ondemandbudgetsutilstsx-to-iterate-through-per-category.

This is just a first pass in the refactor.

Not all hardcoded data categories can be removed as they're hardcoded typescript types (e.g. monitorSeatsBudget). To be able to remove this limitation, we need to update the backend APIs to no longer use and consume them. Afterwards, we will be able to remove them.

@dashed dashed requested a review from a team April 28, 2025 20:46
@dashed dashed self-assigned this Apr 28, 2025
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 28, 2025
@@ -5,6 +5,7 @@ import type {Organization} from 'sentry/types/organization';
import oxfordizeArray from 'sentry/utils/oxfordizeArray';

import type {
DataCategories,
Copy link
Member

@isabellaenriquez isabellaenriquez Apr 28, 2025

Choose a reason for hiding this comment

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

Would it be possible to use DataCategory instead? I'm trying to get rid of DataCategories in this PR as it's basically another version of DataCategory

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why plural DataCategories was added in the first place.

Copy link

codecov bot commented Apr 28, 2025

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
10324 2 10322 5
View the top 2 failed test(s) by shortest run time
Subscription > PendingChanges renders on-demand to pay-as-you go pending changes for am2 to am3
Stack Traces | 0.027s run time
TestingLibraryElementError: Unable to find an element with the text: Pay-as-you-go budget change from per-category on-demand budget (errors at $10, performance units at $0, replays at $0, attachments at $0, cron monitors at $0, uptime monitors at $0, continuous profile hours at $0, and UI profile hours at $0) to shared pay-as-you-go budget of $50. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

Ignored nodes: comments, script, style
...
    at Object.getElementError (.../sentry/sentry/node_modules/@.../dom/dist/config.js:37:19)
    at .../sentry/sentry/node_modules/@.../dom/dist/query-helpers.js:76:38
    at .../sentry/sentry/node_modules/@.../dom/dist/query-helpers.js:52:17
    at .../sentry/sentry/node_modules/@.../dom/dist/query-helpers.js:95:19
    at Object.<anonymous> (.../views/subscriptionPage/pendingChanges.spec.tsx:404:40)
    at Promise.then.completed (.../sentry/sentry/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (.../sentry/sentry/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusTest (.../sentry/sentry/node_modules/jest-circus/build/run.js:316:40)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at _runTest (.../sentry/sentry/node_modules/jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (.../sentry/sentry/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (.../sentry/sentry/node_modules/jest-circus/build/run.js:121:9)
    at run (.../sentry/sentry/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (.../sentry/sentry/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (.../sentry/sentry/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (.../sentry/sentry/node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (.../sentry/sentry/node_modules/jest-runner/build/runTest.js:444:34)
    at Object.worker (.../sentry/sentry/node_modules/jest-runner/build/testWorker.js:106:12)
OnDemandBudgets AM Checkout AM checkout with AM plan - per-category budget
Stack Traces | 1.11s run time
Error: expect(jest.fn()).toHaveBeenCalledWith(...expected)

Expected: "....../customers/org-slug/subscription/", ObjectContaining {"data": {"onDemandBudget": {"attachmentsBudget": 3000, "budgetMode": "per_category", "budgets": {"attachments": 3000, "errors": 1000, "monitorSeats": 4000, "profileDuration": 0, "profileDurationUI": 0, "replays": 0, "transactions": 2000, "uptime": 0}, "errorsBudget": 1000, "monitorSeatsBudget": 4000, "profileDurationBudget": 0, "profileDurationUIBudget": 0, "replaysBudget": 0, "transactionsBudget": 2000, "uptimeBudget": 0}, "onDemandMaxSpend": 10000, "plan": "am2_business", "referrer": "billing", "reservedAttachments": 1, "reservedErrors": 50000, "reservedMonitorSeats": 1, "reservedProfileDuration": undefined, "reservedReplays": 500, "reservedSpans": undefined, "reservedTransactions": 100000, "reservedUptime": 1}}
Received: "....../customers/org-slug/subscription/", {"data": {"onDemandBudget": {"attachmentsBudget": 3000, "budgetMode": "per_category", "budgets": {"attachments": 3000, "errors": 1000, "monitorSeats": 4000, "transactions": 2000}, "errorsBudget": 1000, "monitorSeatsBudget": 4000, "profileDurationBudget": 0, "profileDurationUIBudget": 0, "replaysBudget": 0, "transactionsBudget": 2000, "uptimeBudget": 0}, "onDemandMaxSpend": 10000, "plan": "am2_business", "referrer": "billing", "reservedAttachments": 1, "reservedErrors": 50000, "reservedMonitorSeats": 1, "reservedProfileDuration": undefined, "reservedReplays": 500, "reservedSpans": undefined, "reservedTransactions": 100000, "reservedUptime": 1}, "error": [Function error], "method": "PUT", "success": [Function success]}

Number of calls: 1
    at Object.<anonymous> (.../amCheckout/steps/onDemandBudgets.spec.tsx:220:28)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants