generate proper DSN.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -34,7 +34,38 @@
|
||||
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2"><%= @dsn.name %></dd>
|
||||
</div>
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||
<dt class="text-sm font-medium text-gray-500">DSN Key</dt>
|
||||
<dt class="text-sm font-medium text-gray-500">Complete DSN URL</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
<div class="bg-blue-50 border border-blue-200 rounded-lg p-3">
|
||||
<p class="text-sm text-blue-800 mb-2">Use this complete URL in your agent configuration:</p>
|
||||
<div class="flex items-center space-x-2">
|
||||
<code class="bg-blue-100 px-3 py-2 rounded text-sm font-mono flex-1 break-all"><%= @dsn.full_dsn_url %></code>
|
||||
<button onclick="copyToClipboard('<%= @dsn.full_dsn_url %>')" class="text-blue-600 hover:text-blue-800 text-sm whitespace-nowrap">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" />
|
||||
</svg>
|
||||
Copy
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||
<dt class="text-sm font-medium text-gray-500">API Endpoint</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
<div class="flex items-center space-x-2">
|
||||
<code class="bg-gray-100 px-2 py-1 rounded text-sm font-mono"><%= @dsn.api_endpoint_url %></code>
|
||||
<button onclick="copyToClipboard('<%= @dsn.api_endpoint_url %>')" class="text-blue-600 hover:text-blue-800 text-sm">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" />
|
||||
</svg>
|
||||
Copy
|
||||
</button>
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||
<dt class="text-sm font-medium text-gray-500">DSN Key (for manual auth)</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
<div class="flex items-center space-x-2">
|
||||
<code class="bg-gray-100 px-2 py-1 rounded text-sm font-mono"><%= @dsn.key %></code>
|
||||
|
||||
@@ -12,16 +12,13 @@ postgres_default: &postgres_default
|
||||
adapter: postgresql
|
||||
encoding: unicode
|
||||
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
||||
host: postgres
|
||||
host: localhost
|
||||
port: 5432
|
||||
|
||||
development:
|
||||
primary:
|
||||
<<: *postgres_default
|
||||
host: localhost
|
||||
user: dev_user
|
||||
password: password
|
||||
database: baffle-dev
|
||||
database: baffle_hub_development
|
||||
cache:
|
||||
<<: *sqlite_default
|
||||
database: storage/development_cache.sqlite3
|
||||
|
||||
Reference in New Issue
Block a user