mirror of
https://gitlab.com/tildes/tildes.git
synced 2026-04-17 14:59:11 +02:00
Add metrics for donations and failures
This commit is contained in:
@@ -18,6 +18,12 @@ _COUNTERS = {
|
||||
"comment_labels": Counter(
|
||||
"tildes_comment_labels_total", "Comment Labels", labelnames=["label"]
|
||||
),
|
||||
"donations": Counter(
|
||||
"tildes_donations_total", "Donation Attempts", labelnames=["type"]
|
||||
),
|
||||
"donation_failures": Counter(
|
||||
"tildes_donation_failures_total", "Donation Failures", labelnames=["type"]
|
||||
),
|
||||
"invite_code_failures": Counter(
|
||||
"tildes_invite_code_failures_total", "Invite Code Failures"
|
||||
),
|
||||
|
||||
@@ -12,6 +12,7 @@ from pyramid.security import NO_PERMISSION_REQUIRED
|
||||
from pyramid.view import view_config
|
||||
from webargs.pyramidparser import use_kwargs
|
||||
|
||||
from tildes.metrics import incr_counter
|
||||
from tildes.views.decorators import rate_limit_view
|
||||
|
||||
|
||||
@@ -40,6 +41,8 @@ def post_donate_stripe(
|
||||
except KeyError:
|
||||
raise HTTPInternalServerError
|
||||
|
||||
incr_counter("donations", type="stripe")
|
||||
|
||||
payment_successful = True
|
||||
try:
|
||||
stripe.Charge.create(
|
||||
@@ -51,6 +54,7 @@ def post_donate_stripe(
|
||||
statement_descriptor="Donation - tildes.net",
|
||||
)
|
||||
except stripe.error.StripeError:
|
||||
incr_counter("donation_failures", type="stripe")
|
||||
payment_successful = False
|
||||
|
||||
return {"payment_successful": payment_successful}
|
||||
|
||||
Reference in New Issue
Block a user