Closed fforbeck closed 2 weeks ago
Generally LGTM with one big comment:
I don't think we will have the customer DID when we call usage/record in freeway. @Peeja can you confirm that I'm right on that? Or maybe @travis has more context.
I'm sorry I didn't catch this earlier. You should be able to look it up via the subscription for the space.
Thanks for the review. No problem. That's right @hannahhoward , we won't have the Customer DID in the Freeway project, but we will have the Space DID, and this is what we will pass in the invocation. The w3up project was updated to derive the Customer DID from the Space+Provider: https://github.com/storacha/w3up/blob/main/packages/upload-api/src/usage/record.js#L18, and then it pushes the event to the queue with the Customer DID expected in the w3infra.
Perfect block removed
Egress Traffic Tracking and Stripe Billing Meters API Integration
This PR introduces an asynchronous solution for tracking egress traffic in the Freeway Gateway and reporting events to Stripe’s Billing Meters API.
RFC Reference
Storacha Network is implementing a scalable, automated mechanism for tracking egress traffic and updating Stripe’s API with relevant data to ensure accurate customer billing. This RFC outlines the proposed approaches and their trade-offs.
Implementation
The selected approach for this implementation is Alternative 3:
usage/record
, SQS, Lambda with Stripe IntegrationFlow
usage/record
capability usingctx.waitUntil
.w3infra/upload-api/stores/usage.js
receives the events from the Kinesis stream and places the egress data into an Egress Traffic SQS queue.Key Advantages
ctx.waitUntil
ensures the Freeway Worker won’t block, allowing seamless egress traffic handling.Summary of Changes
usage/record
capability handler inw3infra/upload-api/stores/usage.js
to handle egress data from the Kinesis stream and place them into the SQS queue.Next Steps