PostHog support (#313)

This commit is contained in:
Juan José Mata
2025-11-11 16:06:08 +01:00
committed by GitHub
parent c47a790ad9
commit fcf792b560
7 changed files with 36 additions and 0 deletions

View File

@@ -11,6 +11,7 @@
# policy.img_src :self, :https, :data
# policy.object_src :none
# policy.script_src :self, :https
# policy.script_src :self, :https, 'https://us.i.posthog.com'
# policy.style_src :self, :https
# # Specify URI for violation reports
# # policy.report_uri "/csp-violation-report-endpoint"

View File

@@ -0,0 +1,14 @@
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