Beacon

Integrations

Rails SDK

Report incidents, update components, and send heartbeats from your Rails application. Zero dependencies beyond the Ruby stdlib.

Rails SDK: coming soon

This package is not published yet, so the install command and code below will not work today. Everything it does is a single HTTPS request to the REST API, which works now from any language:

# Open an incident
curl -X POST https://usebeacon.pro/api/v1/pages/YOUR-PAGE-SLUG/incidents \
  -H "Authorization: Bearer $BEACON_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title": "Payment processing delays", "impact": "major", "state": "investigating", "message": "Investigating."}'

# Set a component status
curl -X PATCH https://usebeacon.pro/api/v1/pages/YOUR-PAGE-SLUG/components/COMPONENT_ID \
  -H "Authorization: Bearer $BEACON_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"status": "degraded_performance"}'

# Heartbeat (no token needed; the URL is the secret)
curl -fsS https://usebeacon.pro/api/v1/heartbeat/YOUR-HEARTBEAT-TOKEN
// JavaScript / TypeScript (fetch, Node 18+ or the browser)
await fetch('https://usebeacon.pro/api/v1/pages/YOUR-PAGE-SLUG/incidents', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.BEACON_API_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ title: 'Payment processing delays', impact: 'major', state: 'investigating' }),
});

Full reference: REST API · Incidents · Heartbeats

Installation

# Gemfile
gem "beacon-rails"
bundle install

Configuration

Create an initializer to configure the client.

# config/initializers/beacon.rb
Beacon.configure do |config|
  config.token     = ENV["BEACON_API_TOKEN"]
  config.base_url  = ENV.fetch("BEACON_BASE_URL", "https://app.usebeacon.pro")
  config.page_slug = ENV["BEACON_PAGE_SLUG"]
end

Create an incident

Beacon.create_incident(
  title: "Database connection errors",
  impact: "major",
  state: "investigating",
  message: "Elevated connection timeouts from primary DB."
)

Update component status

Beacon.update_component(component_id, status: "degraded")

Resolve an incident

Beacon.resolve_incident(incident_id,
  message: "Database connections restored after failover."
)

Heartbeat with Sidekiq

class InvoiceProcessingJob
  include Sidekiq::Job

  def perform
    process_invoices
    Beacon.heartbeat("invoice-processing-token")
  end
end

Exception handler

class ApplicationController < ActionController::Base
  rescue_from StandardError do |e|
    if e.is_a?(CriticalDatabaseError)
      Beacon.create_incident(
        title: "Critical database failure",
        impact: "critical"
      )
    end
    raise e
  end
end

Async mode

By default, API calls are dispatched in a background thread so they never block your request cycle. Set config.async = false for synchronous calls.

Features

  • Zero dependencies (Net::HTTP from Ruby stdlib)
  • Thread-safe async mode
  • Auto-configures from environment variables
  • Never raises exceptions — rescues and logs
  • Works with Rails 7+, Ruby 3.1+
  • Railtie for automatic initialization