DEV: Add verbose logging site setting (#230)

To aid in debugging I'm adding a verbose logging site setting. I'm
adding this because I'm currently getting some errors in production that
I'm unable to replicate locally.

See: https://meta.discourse.org/t/323450/4
This commit is contained in:
Blake Erickson 2024-08-27 18:40:12 -06:00 committed by GitHub
parent f0b4984cee
commit e92dd39928
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 0 deletions

View File

@ -30,6 +30,10 @@ module DiscourseSubscriptions
case event[:type]
when "checkout.session.completed"
checkout_session = event[:data][:object]
if SiteSetting.discourse_subscriptions_enable_verbose_logging
Rails.logger.info("checkout.session.completed data: #{checkout_session}")
end
email = checkout_session[:customer_email]
return head 200 if checkout_session[:status] != "complete"
@ -38,6 +42,10 @@ module DiscourseSubscriptions
customer_id = checkout_session[:customer]
if SiteSetting.discourse_subscriptions_enable_verbose_logging
Rails.logger.info("Looking up user with email: #{email}")
end
user = ::User.find_by_username_or_email(email)
return render_json_error "customer not found" if !user

View File

@ -22,6 +22,7 @@ en:
discourse_subscriptions_campaign_show_contributors: Show avatars of the most recent purchases of subscription products.
discourse_subscriptions_campaign_product: The Stripe product id to send supporters when they click the button on the campaign. If this setting is blank, supporters will be directed to the main products page.
discourse_subscriptions_enable_automatic_tax: Enables automatic tax calculation which will automatically compute tax rates on all invoices generated by the subscription.
discourse_subscriptions_enable_verbose_logging: Enables more verbose logging to aid in debugging. Please do not leave permantly enabled in production.
errors:
discourse_patrons_amount_must_be_currency: "Currency amounts must be currencies without dollar symbol (eg 1.50)"

View File

@ -82,3 +82,5 @@ discourse_subscriptions:
hidden: true
discourse_subscriptions_enable_automatic_tax:
default: false
discourse_subscriptions_enable_verbose_logging:
default: false