Skip to content

feat: update billing to run daily#601

Merged
BravoNatalie merged 9 commits intomainfrom
feat/update-billing-run-to-daily
Feb 25, 2026
Merged

feat: update billing to run daily#601
BravoNatalie merged 9 commits intomainfrom
feat/update-billing-run-to-daily

Conversation

@BravoNatalie
Copy link
Contributor

@BravoNatalie BravoNatalie commented Jan 22, 2026

According to this RFC#78

This PR updates the billing process to run daily, enabling more frequent snapshot generation, which should help reduce usage report timeouts, and allow for more regular reporting to Stripe.

@seed-deploy
Copy link

seed-deploy bot commented Jan 22, 2026

View stack outputs
  • pr601-warm-upload-api-BillingDbStack

    Name Value
    customerTableName pr601-warm-upload-api-customer
    egressTrafficTableName pr601-warm-upload-api-egress-traffic-events
    spaceDiffArchiveTableName pr601-warm-upload-api-space-diff-archive
    spaceDiffTableName pr601-warm-upload-api-space-diff
    spaceSnapshotTableName pr601-warm-upload-api-space-snapshot
    usageTable pr601-warm-upload-api-usage
  • pr601-warm-upload-api-BillingStack

    Name Value
    ApiEndpoint https://9fiqlvv0j8.execute-api.us-east-2.amazonaws.com
    billingCronHandlerURL https://5ht4fzka2zj7ymddrmxxg7jrse0tgnke.lambda-url.us-east-2.on.aws/
    CustomDomain https://pr601.billing.warm.storacha.network
    EgressTrafficQueueURL https://sqs.us-east-2.amazonaws.com/505595374361/pr601-warm-upload-api-egress-traffic-queue
  • pr601-warm-upload-api-CarparkStack

    Name Value
    BucketName pr601-warm-upload-api-carpark-0
    Region us-east-2
  • pr601-warm-upload-api-RoundaboutStack

    Name Value
    ApiEndpoint https://staging.roundabout.web3.storage/
    CustomDomain Using ROUNDABOUT_API_URL - no custom domain
  • pr601-warm-upload-api-UcanInvocationStack

    Name Value
    agentIndexBucketName pr601-warm-upload-api-invocation-store-0
    agentMessageBucketName pr601-warm-upload-api-workflow-store-0
  • pr601-warm-upload-api-UploadApiStack

    Name Value
    ApiEndpoints ["https://pe860ok7ya.execute-api.us-east-2.amazonaws.com"]
    CustomDomains ["https://pr601.up.warm.storacha.network"]
  • pr601-warm-upload-api-BusStack

  • pr601-warm-upload-api-FilecoinStack

  • pr601-warm-upload-api-UcanFirehoseStack

  • pr601-warm-upload-api-UploadDbStack

Copy link
Contributor

@travis travis left a comment

Choose a reason for hiding this comment

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

this seems right to me! I think we should start this after the next billing run on Feb 1, so I'd recommend merging first thing next week, testing for a couple days in staging and then pushing to prod

Copy link
Member

@hannahhoward hannahhoward left a comment

Choose a reason for hiding this comment

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

It vaguely looks this wouldn't work for the first run for a new customer where there is no previous usage, but I don't have context on the larger system. Assuming this properly handles the first run where there is no previous usage, LGTM.

If not, please fix.

}

if (recoveryResult.error?.name === 'RecordNotFound') {
console.error(`CRITICAL DATA LOSS: Cannot calculate usage delta. Manual investigation and correction required.' \n ${JSON.stringify({
Copy link
Member

Choose a reason for hiding this comment

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

Are we certain this never happens? Should it just be set to zero in this case?

Copy link
Contributor Author

@BravoNatalie BravoNatalie Feb 11, 2026

Choose a reason for hiding this comment

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

I’m not sure this wouldn’t happen, I don’t think it’s impossible. Yes, I could return zero, but that would undercharge the user since we'd lose previous usage.

update: as we discussed, it's better to let it error out and handle the issue later. That way we can easily track where it failed.

const cumulativeByteQuantity = Math.floor(new Big(usage.usage.toString()).div(duration).toNumber())

// Query previous day's usage to calculate delta
const previousCumulativeUsage = await getPreviousUsage(usage, ctx)
Copy link
Member

Choose a reason for hiding this comment

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

what happens the very first time this runs? Is there a value for previous then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it's the first time, we won't find anything in the usage table or Stripe, so we'll return zero.

@seed-deploy
Copy link

seed-deploy bot commented Feb 24, 2026

Stack outputs updated

@seed-deploy seed-deploy bot temporarily deployed to pr601 February 24, 2026 22:10 Inactive
@seed-deploy seed-deploy bot temporarily deployed to pr601 February 24, 2026 22:13 Inactive
@BravoNatalie BravoNatalie merged commit 2db9e6a into main Feb 25, 2026
4 of 5 checks passed
@BravoNatalie BravoNatalie deleted the feat/update-billing-run-to-daily branch February 25, 2026 01:59
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.

Daily Billing Runs

3 participants