Repository navigation
feat(usage): split credit usage by endpoint and by day - #583
Merged
Merged
Conversation
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 11 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
…est daily fallback Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 10 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
firecrawl_credit_usagecould only report balance and monthly totals, so an agent asked "what did I spend credits on?" had nothing to answer with. This adds two historical options and states what the tool can and can't break down.byEndpoint: truesplits each period by the endpoint that used the credits. Rows carryendpoint(scrape, search, crawl, map, agent, ...). It can't be combined withbyApiKeyorview: "current".bin: "day"returns one period per UTC day instead of per calendar month. It works with the totals,byApiKeyandbyEndpoint.creditsUsed,metadata.creditsUsed), and that the dashboard's Usage and Logs pages list usage per job.Depends on firecrawl/firecrawl#5291, which adds
byEndpointandbintoGET /v2/team/credit-usage/historical. This PR is safe to deploy before it. Whenever the tool uses either option, it sendsbin, and that API echoesbinback. If the echo is missing, the API ignored the new parameters, and the tool returns the monthly figures it got plus anoticesaying the split or daily periods aren't available yet. It doesn't fail and doesn't pass totals off as a breakdown. Calls without the new options send exactly the requests they sent before.The output schema adds
binandnotice. Contract snapshots were regenerated withUPDATE_CONTRACT_SNAPSHOTS=1; the only change isfirecrawl_credit_usage. The smoke test covers the new request shapes, the fallback against an older API, and the new argument errors.pnpm test: 198 passed.Summary by cubic
firecrawl_credit_usagenow supportsbyEndpointandbin: "day"so the historical view can answer what credits were spent on and when, not just monthly totals.byEndpoint: truesplits each period by endpoint (scrape, search, crawl, map, agent, ...). It cannot be combined withbyApiKeyorview: "current".bin: "day"returns one period per UTC day instead of per calendar month, and works with totals,byApiKey, andbyEndpoint.noticeinstead of failing or passing totals off as a breakdown.binandnotice; contract snapshots regenerated and smoke tests cover new request shapes, the fallback, and new argument errors.Written for commit 2aace80. Summary will update on new commits.