generate proper DSN.

This commit is contained in:
Dan Milne
2025-11-09 21:57:31 +11:00
parent 1e4c6f35d8
commit 1bbea9bf67
3 changed files with 55 additions and 6 deletions

View File

@@ -10,6 +10,27 @@ class Dsn < ApplicationRecord
enabled.find_by(key: key)
end
def full_dsn_url
# Generate a complete DSN URL like Sentry does
# Format: https://{key}@{domain}/api/events
domain = Rails.application.config.action_mailer.default_url_options[:host] ||
ENV['RAILS_HOST'] ||
'localhost:3000'
protocol = Rails.env.development? ? 'http' : 'https'
"#{protocol}://#{key}@#{domain}/api/events"
end
def api_endpoint_url
# Just the API endpoint URL (without key)
domain = Rails.application.config.action_mailer.default_url_options[:host] ||
ENV['RAILS_HOST'] ||
'localhost:3000'
protocol = Rails.env.development? ? 'http' : 'https'
"#{protocol}://#{domain}/api/events"
end
private
def generate_key