Best practice to track 'credit' use overtime (e.g. 100 credit allowance per month, and display how many used in that month)

Hey all,

Wondering what might be the best practise for this, not necessarily Wappler specific, but in general.

The two ways I can think of doing this:

  1. Use of a table to capture each single credit use. Then on page load that displays credit use, count over the current month time period, and subtract from a static number in the table that shows how many credits they get each month.
  • Pro, I can then provide more analytics, credit use over a quarter and so on.
  • Con, this table can get into the 100’s of thousands, if not millions rapidly as these credits are used in high volume - so I imagine performance will be an issue.
  • 1 Table field = credit quota, renewed with a Cron each month, or renewed with the Stripe renewal workflow.
  • 1 Table field = current month used quota, accumulated with the workflow when credits are used each month.

Pro - Simpler, more performant.
Con - Lost the ability to run future analytics

This is an experiential question really, so really appreciate feedback from any pro’s who done this and can provide a smarter more future proof way of doing this.

@mgaussie I haven’t yet tried this but if you’re using Stripe, from what I gathered in your post, could you let Stripe handle the usage logging via api?

Hey Max,

Interesting. We don’t use Stripe in this way, we use it for subscription billing but not metered billing - but I might check in on them to see if we can use the usage logging functionality, anyway

1 Like