posthog-rails 3.5.3 → 3.6.0

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: 32c8090638dc6456a2cfe2abdfe0dec901ee549b44f3d52f8c1728019a931d57
4
+ data.tar.gz: 2371da2d51b6977fd8a2544270fae72c8c6e5e9465783ca9fd32bf118b85ae8c
5
5
  SHA512:
6
- metadata.gz: 30bbf87a63ef62bce4c0146ba49209d53bdbf3774cb45da43fcbc0ca3c20ed416f182fc811c4446300a370a39a37afb68066384c162a66c99149b4cb3112c9a7
7
- data.tar.gz: 3ec3f4b8daa595bc1c22a8d043d6815d6ec9a7d0c6daa64f789aea16cc1403397a5ffd4eddd36dbdef10fa84f9e827e27997652e2eae08f2d941e1460823e399
6
+ metadata.gz: 2cf658e5f2ebce148a07e221b3458925b22affb61196f1771691e0988e161a2024c29dcc021cf30c30e62f13ab71e01b5f8c2a10faeb02996f5ace063360dae2
7
+ data.tar.gz: '0338af574847d6c9f52e1c3f43b7f7b7401ee9966a1d0816d3b1a5967b3a4689d584e1801cfa50101e0106f4692239eb0ac2a9be5e7f7533099bca7266730705'
@@ -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,131 @@
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
+ # IMPORTANT: Use PostHog.init once — creating multiple clients can cause dropped events.
50
+ # PostHog.init provides a singleton-like pattern; use PostHog.capture, PostHog.identify, etc.
51
+
52
+ PostHog.init do |config|
53
+ # ============================================================================
54
+ # REQUIRED CONFIGURATION
55
+ # ============================================================================
56
+
57
+ # Your PostHog project API key (required)
58
+ # Get this from: PostHog Project Settings > API Keys
59
+ # https://app.posthog.com/settings/project-details#variables
60
+ config.api_key = ENV.fetch('POSTHOG_API_KEY', nil)
61
+
62
+ # ============================================================================
63
+ # OPTIONAL CONFIGURATION
64
+ # ============================================================================
65
+
66
+ # For PostHog Cloud, use: https://us.i.posthog.com or https://eu.i.posthog.com
67
+ config.host = ENV.fetch('POSTHOG_HOST', 'https://us.i.posthog.com')
68
+
69
+ # Personal API key (optional, but required for local feature flag evaluation)
70
+ # Get this from: PostHog Settings > Personal API Keys
71
+ # https://app.posthog.com/settings/user-api-keys
72
+ config.personal_api_key = ENV.fetch('POSTHOG_PERSONAL_API_KEY', nil)
73
+
74
+ # Maximum number of events to queue before dropping (default: 10000)
75
+ config.max_queue_size = 10_000
76
+
77
+ # Feature flags polling interval in seconds (default: 30)
78
+ config.feature_flags_polling_interval = 30
79
+
80
+ # Feature flag request timeout in seconds (default: 3)
81
+ config.feature_flag_request_timeout_seconds = 3
82
+
83
+ # Error callback - called when PostHog encounters an error
84
+ # config.on_error = proc { |status, message|
85
+ # Rails.logger.error("[PostHog] Error #{status}: #{message}")
86
+ # }
87
+
88
+ # Before send callback - modify or filter events before sending
89
+ # Return nil to prevent the event from being sent
90
+ # config.before_send = proc { |event|
91
+ # # Filter out test users
92
+ # return nil if event[:properties]&.dig('$user_email')&.end_with?('@test.com')
93
+ #
94
+ # # Add custom properties to all events
95
+ # event[:properties] ||= {}
96
+ # event[:properties]['environment'] = Rails.env
97
+ #
98
+ # event
99
+ # }
100
+
101
+ # ============================================================================
102
+ # ENVIRONMENT-SPECIFIC CONFIGURATION
103
+ # ============================================================================
104
+
105
+ # Disable in test environment
106
+ config.test_mode = true if Rails.env.test?
107
+
108
+ # Optional: Disable in development
109
+ # config.test_mode = true if Rails.env.test? || Rails.env.development?
110
+ end
111
+
112
+ # ============================================================================
113
+ # DEFAULT EXCLUDED EXCEPTIONS
114
+ # ============================================================================
115
+ # The following exceptions are excluded by default:
116
+ #
117
+ # - AbstractController::ActionNotFound
118
+ # - ActionController::BadRequest
119
+ # - ActionController::InvalidAuthenticityToken
120
+ # - ActionController::InvalidCrossOriginRequest
121
+ # - ActionController::MethodNotAllowed
122
+ # - ActionController::NotImplemented
123
+ # - ActionController::ParameterMissing
124
+ # - ActionController::RoutingError
125
+ # - ActionController::UnknownFormat
126
+ # - ActionController::UnknownHttpMethod
127
+ # - ActionDispatch::Http::Parameters::ParseError
128
+ # - ActiveRecord::RecordNotFound
129
+ # - ActiveRecord::RecordNotUnique
130
+ #
131
+ # These can be re-enabled by removing them from the exclusion list if needed.
@@ -160,6 +160,10 @@ module PostHog
160
160
  @base_options[:test_mode] = value
161
161
  end
162
162
 
163
+ def sync_mode=(value)
164
+ @base_options[:sync_mode] = value
165
+ end
166
+
163
167
  def on_error=(value)
164
168
  @base_options[:on_error] = value
165
169
  end
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.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PostHog
@@ -29,14 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: '3.5'
32
+ version: '3.6'
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '3.5'
39
+ version: '3.6'
40
40
  description: Automatic exception tracking and instrumentation for Ruby on Rails applications
41
41
  using PostHog
42
42
  email: hey@posthog.com
@@ -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
@@ -73,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
74
  - !ruby/object:Gem::Version
74
75
  version: '0'
75
76
  requirements: []
76
- rubygems_version: 4.0.3
77
+ rubygems_version: 4.0.6
77
78
  specification_version: 4
78
79
  summary: PostHog integration for Rails
79
80
  test_files: []