AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

omnibus-instrument-error-tracking

Add PostHog error tracking to capture and monitor exceptions. Use after implementing features or reviewing PRs to ensure errors are tracked with stack traces and source maps. Also handles initial PostHog SDK setup if not yet installed.

Original source
posthog
License
MIT
Pinned revision
cac7c80a9e5b73484d18eda1bffb47297c938e0c

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

Ask your assistant

Use Agentic Memory skills to read posthog--omnibus-instrument-error-tracking at revision cac7c80a9e5b73484d18eda1bffb47297c938e0c, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 21

references/ruby-on-rails.md

Ruby on Rails error tracking installation - Docs

  1. 1

    Install the gems

    Required

    Add the posthog-ruby and posthog-rails gems to your Gemfile:

    Gemfile

    PostHog AI

    gem "posthog-ruby"
    gem "posthog-rails"
    

    Then run:

    Terminal

    PostHog AI

    bundle install
    
  2. 2

    Generate the initializer

    Required

    Run the install generator to create the PostHog initializer:

    Terminal

    PostHog AI

    rails generate posthog:install
    

    This will create config/initializers/posthog.rb with sensible defaults and documentation.

  3. 3

    Configure PostHog

    Required

    Update config/initializers/posthog.rb with your project token and host:

    config/initializers/posthog.rb

    PostHog AI

    PostHog.init do |config|
      config.api_key = '<ph_project_token>'
      config.host = 'https://us.i.posthog.com'
    end
    
  4. 4

    Send events

    Recommended

    Once installed, you can manually send events to test your integration:

    Ruby

    PostHog AI

    PostHog.capture({
        distinct_id: 'user_123',
        event: 'button_clicked',
        properties: {
            button_name: 'signup'
        }
    })
    
  5. 5

    Configure error tracking

    Required

    Update config/initializers/posthog.rb to enable automatic exception capture:

    config/initializers/posthog.rb

    PostHog AI

    PostHog::Rails.configure do |config|
      config.auto_capture_exceptions = true
      config.report_rescued_exceptions = true
      config.auto_instrument_active_job = true
      config.capture_user_context = true
      config.current_user_method = :current_user
    end
    
  6. 6

    Automatic exception capture

    Recommended

    With auto_capture_exceptions enabled, exceptions are automatically captured from your controllers:

    app/controllers/posts_controller.rb

    PostHog AI

    class PostsController < ApplicationController
      def show
        @post = Post.find(params[:id])
        # Any exception here is automatically captured
      end
    end
    
  7. 7

    Background jobs

    Optional

    When auto_instrument_active_job is enabled, ActiveJob exceptions are automatically captured:

    app/jobs/email_job.rb

    PostHog AI

    class EmailJob < ApplicationJob
      def perform(user_id)
        user = User.find(user_id)
        UserMailer.welcome(user).deliver_now
        # Exceptions are automatically captured with job context
      end
    end
    
  8. 8

    Manually capture exceptions

    Optional

    You can also manually capture exceptions that you handle in your application:

    Ruby

    PostHog AI

    PostHog.capture_exception(
      exception,
      current_user.id,
      { custom_property: 'value' }
    )
    
  9. Verify error tracking

    Recommended

    Confirm events are being sent to PostHog

    Before proceeding, let's make sure exception events are being captured and sent to PostHog. You should see events appear in the activity feed.

    Activity feed with eventsActivity feed with events

    Check for exceptions in PostHog

Community questions

Ask a question

Was this page useful?

HelpfulCould be better