lundi 5 juillet 2021

How long to keep Stripe webhook event record for idempotence?

My app implements Stripe webhooks. I save a record of the ID of the event after I've processed it and check against these records before I process each webhooks. So my app is currently idempotent as per the Stripe docs best practices: https://stripe.com/docs/webhooks/best-practices

However how long do I need to keep these records? Should I keep them forever or can I delete them after 30 days, 6 months, 1 year, etc?

I store them in a Mongo DB and the data is just the ID of the Stripe webhook event so the collection data looks like after a few years (I only listen to a few events):

COLLECTION SIZE: 2.73MB TOTAL DOCUMENTS: 47183 INDEXES TOTAL SIZE: 1.51MB

Eventually this collection will get really big and every time I query it to check the latest webhook that query will get slower. But I imagine this will take quite a long time to really matter.

What is the software best practice here? I was in the process of writing a cron to delete after 14 days but I thought to myself is this wrong?

Aucun commentaire:

Enregistrer un commentaire