posthog-rails 3.5.3 → 3.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b7a93ce29b1528ad68c2b03e82400e3b986c6bf78fab3f3dfed6e54079d271a
4
- data.tar.gz: 1c818a7ce001ab48a469a294a0f0dad6643e4e1a14975423b3a57cfe0fa9b240
3
+ metadata.gz: 73b3698f8394559833943f6d02e405620ee11772e92f05bfb88d1e20293d49a4
4
+ data.tar.gz: 3315690f7eb8c851b2c8f23179a9ed8ceb6d730177b800ddec883f5e21e7db5b
5
5
  SHA512:
6
- metadata.gz: 30bbf87a63ef62bce4c0146ba49209d53bdbf3774cb45da43fcbc0ca3c20ed416f182fc811c4446300a370a39a37afb68066384c162a66c99149b4cb3112c9a7
7
- data.tar.gz: 3ec3f4b8daa595bc1c22a8d043d6815d6ec9a7d0c6daa64f789aea16cc1403397a5ffd4eddd36dbdef10fa84f9e827e27997652e2eae08f2d941e1460823e399
6
+ metadata.gz: 0eb6a62fba135f4ff4c6b1830080d4a7272daf05d4a8b295e9e69212617cd8aa6b33ba9e0a485a4523d7e1d7c056a7f110c50abef0d59bff22cf93c4421adfed
7
+ data.tar.gz: 6c1ac4517141425d1b2528083cf3d8d9e97fa57ba8b73ff53913bd0c34b61735241e3e32043af932dea430441b3f8be0e2e64d99b70d9b5efeb8ce3920aacd3b
@@ -7,10 +7,10 @@ module Posthog
7
7
  class InstallGenerator < ::Rails::Generators::Base
8
8
  desc 'Creates a PostHog initializer file at config/initializers/posthog.rb'
9
9
 
10
- source_root File.expand_path('../../..', __dir__)
10
+ source_root File.expand_path('templates', __dir__)
11
11
 
12
12
  def copy_initializer
13
- copy_file 'examples/posthog.rb', 'config/initializers/posthog.rb'
13
+ copy_file 'posthog.rb', 'config/initializers/posthog.rb'
14
14
  end
15
15
 
16
16
  def show_readme
@@ -0,0 +1,129 @@
1
+ # frozen_string_literal: true
2
+
3
+ # PostHog Rails Initializer
4
+ # Place this file in config/initializers/posthog.rb
5
+
6
+ # ============================================================================
7
+ # RAILS-SPECIFIC CONFIGURATION
8
+ # ============================================================================
9
+ # Configure Rails-specific options via PostHog::Rails.configure
10
+ # These settings control how PostHog integrates with Rails features.
11
+
12
+ PostHog::Rails.configure do |config|
13
+ # Automatically capture exceptions (default: false)
14
+ # Set to true to enable automatic exception tracking
15
+ # config.auto_capture_exceptions = true
16
+
17
+ # Report exceptions that Rails rescues (e.g., with rescue_from) (default: false)
18
+ # Set to true to capture rescued exceptions
19
+ # config.report_rescued_exceptions = true
20
+
21
+ # Automatically instrument ActiveJob background jobs (default: false)
22
+ # Set to true to enable automatic ActiveJob exception tracking
23
+ # config.auto_instrument_active_job = true
24
+
25
+ # Capture user context with exceptions (default: true)
26
+ # config.capture_user_context = true
27
+
28
+ # Controller method name to get current user (default: :current_user)
29
+ # Change this if your app uses a different method name (e.g., :authenticated_user)
30
+ # When configured, exceptions will include user context (distinct_id, email, name),
31
+ # making it easier to identify affected users and debug user-specific issues.
32
+ # config.current_user_method = :current_user
33
+
34
+ # Additional exception classes to exclude from reporting
35
+ # These are added to the default excluded exceptions
36
+ # config.excluded_exceptions = [
37
+ # # 'MyCustom404Error',
38
+ # # 'MyCustomValidationError'
39
+ # ]
40
+ end
41
+
42
+ # You can also configure Rails options directly:
43
+ # PostHog::Rails.config.auto_capture_exceptions = true
44
+
45
+ # ============================================================================
46
+ # CORE POSTHOG CONFIGURATION
47
+ # ============================================================================
48
+ # Initialize the PostHog client with core SDK options.
49
+
50
+ PostHog.init do |config|
51
+ # ============================================================================
52
+ # REQUIRED CONFIGURATION
53
+ # ============================================================================
54
+
55
+ # Your PostHog project API key (required)
56
+ # Get this from: PostHog Project Settings > API Keys
57
+ # https://app.posthog.com/settings/project-details#variables
58
+ config.api_key = ENV.fetch('POSTHOG_API_KEY', nil)
59
+
60
+ # ============================================================================
61
+ # OPTIONAL CONFIGURATION
62
+ # ============================================================================
63
+
64
+ # For PostHog Cloud, use: https://us.i.posthog.com or https://eu.i.posthog.com
65
+ config.host = ENV.fetch('POSTHOG_HOST', 'https://us.i.posthog.com')
66
+
67
+ # Personal API key (optional, but required for local feature flag evaluation)
68
+ # Get this from: PostHog Settings > Personal API Keys
69
+ # https://app.posthog.com/settings/user-api-keys
70
+ config.personal_api_key = ENV.fetch('POSTHOG_PERSONAL_API_KEY', nil)
71
+
72
+ # Maximum number of events to queue before dropping (default: 10000)
73
+ config.max_queue_size = 10_000
74
+
75
+ # Feature flags polling interval in seconds (default: 30)
76
+ config.feature_flags_polling_interval = 30
77
+
78
+ # Feature flag request timeout in seconds (default: 3)
79
+ config.feature_flag_request_timeout_seconds = 3
80
+
81
+ # Error callback - called when PostHog encounters an error
82
+ # config.on_error = proc { |status, message|
83
+ # Rails.logger.error("[PostHog] Error #{status}: #{message}")
84
+ # }
85
+
86
+ # Before send callback - modify or filter events before sending
87
+ # Return nil to prevent the event from being sent
88
+ # config.before_send = proc { |event|
89
+ # # Filter out test users
90
+ # return nil if event[:properties]&.dig('$user_email')&.end_with?('@test.com')
91
+ #
92
+ # # Add custom properties to all events
93
+ # event[:properties] ||= {}
94
+ # event[:properties]['environment'] = Rails.env
95
+ #
96
+ # event
97
+ # }
98
+
99
+ # ============================================================================
100
+ # ENVIRONMENT-SPECIFIC CONFIGURATION
101
+ # ============================================================================
102
+
103
+ # Disable in test environment
104
+ config.test_mode = true if Rails.env.test?
105
+
106
+ # Optional: Disable in development
107
+ # config.test_mode = true if Rails.env.test? || Rails.env.development?
108
+ end
109
+
110
+ # ============================================================================
111
+ # DEFAULT EXCLUDED EXCEPTIONS
112
+ # ============================================================================
113
+ # The following exceptions are excluded by default:
114
+ #
115
+ # - AbstractController::ActionNotFound
116
+ # - ActionController::BadRequest
117
+ # - ActionController::InvalidAuthenticityToken
118
+ # - ActionController::InvalidCrossOriginRequest
119
+ # - ActionController::MethodNotAllowed
120
+ # - ActionController::NotImplemented
121
+ # - ActionController::ParameterMissing
122
+ # - ActionController::RoutingError
123
+ # - ActionController::UnknownFormat
124
+ # - ActionController::UnknownHttpMethod
125
+ # - ActionDispatch::Http::Parameters::ParseError
126
+ # - ActiveRecord::RecordNotFound
127
+ # - ActiveRecord::RecordNotUnique
128
+ #
129
+ # These can be re-enabled by removing them from the exclusion list if needed.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posthog-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.3
4
+ version: 3.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - PostHog
@@ -45,6 +45,7 @@ extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
47
  - lib/generators/posthog/install_generator.rb
48
+ - lib/generators/posthog/templates/posthog.rb
48
49
  - lib/posthog-rails.rb
49
50
  - lib/posthog/rails.rb
50
51
  - lib/posthog/rails/active_job.rb