Files
sure/config/initializers/posthog.rb
2025-11-11 16:06:08 +01:00

15 lines
531 B
Ruby

require "posthog"
Rails.configuration.x.posthog = ActiveSupport::OrderedOptions.new
Rails.configuration.x.posthog.api_key = ENV["POSTHOG_KEY"].presence
Rails.configuration.x.posthog.host = ENV.fetch("POSTHOG_HOST", "https://us.i.posthog.com")
if (api_key = Rails.configuration.x.posthog.api_key).present?
# Initialize PostHog client
$posthog = PostHog::Client.new({
api_key: api_key,
host: Rails.configuration.x.posthog.host,
on_error: Proc.new { |status, msg| puts "PostHog error: #{status} - #{msg}" }
})
end