#markr_usage-records

1 messages ยท Page 1 of 1 (latest)

blazing fogBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1273711049614299206

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

frank yew
#

Relevant events we sent:

#

Result in Stripe:

prisma forge
#

Hi ๐Ÿ‘‹

Sorry this isn't making much sense to me. Can you explain the usage records you are creating, the aggregation method you are using, and what the behavior is that you do not expect?

frank yew
#

We are a file storage platform, and we bill based on storage used.

We create usage records each time a user creates or deletes a file to make sure that the usage is up to date.

We are using max aggregation.

I would expect each record to be separate, and never combined, instead they appear to be summing when they are sent too close to each other. (see example above of when we reported records, and what is shown in Stripe)

#

This is how we create the usage records.

blazing fogBOT
tawdry zenith
#

Hi ๐Ÿ‘‹ can you share the IDs of the requests you made to create the usage records that appear to be getting summed?

frank yew
#

I have no idea how I would get those, we did not log them at the time that this occurred.

tawdry zenith
frank yew
#

req_5nY8oakSybfwtW
req_OQzzSXffbkUstl

#

The second one we sent 526, and got back 1052

tawdry zenith
#

That's happening because you provided the same timestamp in the requests:

When there is more than one usage record with the same timestamp, Stripe adds the quantity values together. In most cases, this is the desired resolution, however, you can change this behavior with the action parameter.
https://docs.stripe.com/api/usage_records/create

You'll want to try passing action set to set to reset the quantity for that timestamp.

frank yew
#

Ah ok. That is a weird default behaviour, but makes sense.

#

I assume if I don't provide the timestamp it also would not have happened?

#

I will add the action parameter to my requests though. Thank you!

tawdry zenith
#

If you don't specify a timestamp, we use the timestamp of when the request was received.

frank yew
#

OK, so that would be even harder to debug.

Would be nice to have that same callout in the timestamp description. I know I just completely skipped over the description of the endpoint, and just looked at the parameters when setting this up

tawdry zenith
blazing fogBOT
#

markr_usage-records

frank yew
#

I don't see any mention of the more than one record with the same timestamp?

tawdry zenith
#

Oh, I see what you're saying (I thought you were referring to the now behavior, not the summing behavior). The summing is talked about in the action description, since the action controls that behavior.

frank yew
#

Yeah, it's a bit weird since the action controls the behaviour, but the timestamp is what is being acted upon.