Report credits in zenrows usage, and say the allowance renews - #17
Open
pablomogamon wants to merge 2 commits into
Open
Report credits in zenrows usage, and say the allowance renews#17pablomogamon wants to merge 2 commits into
pablomogamon wants to merge 2 commits into
Conversation
quotaExhausted told an exhausted account to "add credits or upgrade your
plan" and stopped there. Both are true, and both cost money — but neither is
the cheapest answer, which is that the allowance comes back at the end of the
billing period.
Leaving that out is why an exhausted client retries instead of waiting or
deciding. It matches what the API itself says on AUTH004 ("Purchase a new
subscription to continue"), and the traffic shows the result: one account
spent seven days at ~3 requests/second against this wall with zero successes.
The date is not hardcoded here — `zenrows usage` prints the exact
period_ends_at, and now gets suggested in both the claimed and unclaimed
cases rather than only the claimed one.
No code-path change: POLICY_MAX_CREDITS_EXCEEDED already means the account
wall, and a policy cap already raises POLICY_LIMIT_EXCEEDED. Only the wording
and the suggested command move.
Verified against the live endpoint: /v1/subscriptions/self/details returns usage_credits and credit_limit next to the dollar figure. Neither was declared on UsageDetails, so the command printed dollars and left the reader to convert. They cannot. The rate is per plan, not a platform constant: Free bills $0.001/credit (5,000 credits for $5) while a Business yearly plan bills 8.9997e-05. The response carries plan.unit_cost for exactly this reason, and credit_limit * unit_cost === plan.price holds on the live payload. So the command now leads with credits used, the credit limit and what is left, which is the unit the docs, the dashboard and the error messages all speak in. The dollar line stays underneath. unit_cost is declared with a note against ever hardcoding a conversion factor — an easy mistake to make from a single account's numbers, and wrong on every other plan.
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.
Two small changes to the same blind spot: a client that runs out of credits is not told the one thing that would stop it retrying.
zenrows usagewas dropping the credits/v1/subscriptions/self/detailsreturnsusage_creditsandcredit_limitalongside the dollar figure. Neither was declared onUsageDetails, so they arrived through the index signature and went nowhere — the command printed dollars and left the reader to convert.They cannot convert. The rate is per plan, not a platform constant: Free bills $0.001/credit (5,000 credits for $5) while a Business yearly plan bills 8.9997e-05. The payload carries
plan.unit_costfor exactly this reason, andcredit_limit × unit_cost === plan.priceholds on the live response.Before and after, run against a real account:
Credits are the unit the docs, the dashboard and the error messages all speak in, so they lead; the dollar line stays underneath.
usage_credits,credit_limitandunit_costare now declared, withunit_costcarrying a note against ever hardcoding a conversion factor — an easy mistake to make from one account's numbers and wrong on every other plan.quotaExhausteddid not mention the renewalIt told an exhausted account to "add credits or upgrade your plan" and stopped. Both are true, both cost money, and neither is the cheapest answer: the allowance comes back at the end of the billing period.
Leaving that out is what turns a wait into a retry loop. It matches what the API itself says on AUTH004 — "Purchase a new subscription to continue" — and the traffic shows the result: 413 accounts are against this wall, one of them at ~3.3 requests/second for seven days with zero successes.
The date is not hardcoded here.
zenrows usageprints the exactperiod_ends_at, and is now suggested in both the claimed and unclaimed cases rather than only the claimed one.No behaviour reclassified
POLICY_MAX_CREDITS_EXCEEDEDalready means the account wall, and a policy cap already raisesPOLICY_LIMIT_EXCEEDEDfor bothmax_pages_per_runandmax_credits_per_run. I had read the docs table as evidence the two were conflated in code and came close to "fixing" that; they are not. Only wording, one suggested command, and three previously undeclared response fields change here. The docs table is corrected separately in ZenRows/docs#213.Verification
typecheckclean, 187 tests green, 2 of them new.zenrows usagewas run against a live account, not only unit-tested — the output above is real, and 35,999,978 − 62,982 = 35,936,996 checks out.credit_limit × unit_cost === plan.priceinvariant that makes the rate per-plan.Opened from a fork: I do not have push on this repo.
Context: ACT-1581, ACT-1577.