posthog-ruby 3.23.5 → 3.23.6

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: 3e7240af788ef7054780bd976e8d568fc5c5deab52c8e448e18097b3ab2f4206
4
- data.tar.gz: 64fe80390d35ffd7aac25a10ff2c98584a0f74cf353ba4d697503b472e1859ee
3
+ metadata.gz: 48bec2a9194efaee9e0b2dee9c7ca1c3af4697a8b85b8256b34302cd9ab91818
4
+ data.tar.gz: f5c4ae56806620e636e1d65fd20f18baed769b1f2e8fec9154c4cbb1515ebb80
5
5
  SHA512:
6
- metadata.gz: 63adc1ce6c3381d2261076783610e1e71d04cbc4d925548dc777663d8c996228bd61ce80b3813ecec1a5b98c07ad687953b1bee408d30931a8002b1e5175ea3e
7
- data.tar.gz: 24954a02c8857733331f5976718e212786e7ce713ca60b3ea329dcbadc5defcd28d6c5cf02f684cc1f285573d972374b718653885b98daf7e05df4ecb386f6cd
6
+ metadata.gz: 1aaf63d6764d231e7f461650651e419abebeaf26cb151ef168497c4ac0d8ce3ced14ef1e23a3308f14126f57aa78f337e2b9b3064983713d92dfea26cd7ffffa
7
+ data.tar.gz: 3b851e37e73b2cb8e1dfe8439da24c45e341ca3adf5f1bfe89318e6f9a8270e7ee070216df644320ca16bc9236aa1f9e1b28d73f0968d63ca38ad80cc8dfe1c0
@@ -141,6 +141,9 @@ module PostHog
141
141
  @api_key = opts[:api_key]
142
142
  @disabled = @api_key.nil? || @api_key.empty?
143
143
  @max_queue_size = opts[:max_queue_size] || Defaults::Queue::MAX_SIZE
144
+ @lib = opts[:_lib] || 'posthog-ruby'
145
+ @lib_version = (opts[:_lib_version] || PostHog::VERSION).to_s
146
+ @headers = Defaults::Request::HEADERS.merge('User-Agent' => "#{@lib}/#{@lib_version}")
144
147
  @worker_mutex = Mutex.new
145
148
  @shutdown_mutex = Mutex.new
146
149
  @shutdown_condition = ConditionVariable.new
@@ -154,11 +157,12 @@ module PostHog
154
157
  elsif @sync_mode
155
158
  nil
156
159
  else
157
- SendWorker.new(@queue, @api_key, opts)
160
+ SendWorker.new(@queue, @api_key, opts.merge(headers: @headers))
158
161
  end
159
162
  if @sync_mode
160
163
  @transport = Transport.new(
161
164
  api_host: opts[:host],
165
+ headers: @headers,
162
166
  skip_ssl_verification: opts[:skip_ssl_verification],
163
167
  retries: opts.key?(:max_retries) ? opts[:max_retries].to_i + 1 : 3,
164
168
  compress_request: opts[:compress_request]
@@ -198,7 +202,8 @@ module PostHog
198
202
  opts[:on_error],
199
203
  flag_definition_cache_provider: opts[:flag_definition_cache_provider],
200
204
  feature_flag_request_max_retries: opts[:feature_flag_request_max_retries],
201
- async_load: opts[:feature_flags_async_load] == true
205
+ async_load: opts[:feature_flags_async_load] == true,
206
+ user_agent: @headers['User-Agent']
202
207
  )
203
208
  end
204
209
 
@@ -362,6 +367,8 @@ module PostHog
362
367
  end
363
368
 
364
369
  attrs[:is_server] = @is_server
370
+ attrs[:lib] = @lib
371
+ attrs[:lib_version] = @lib_version
365
372
  message = FieldParser.parse_for_capture(attrs)
366
373
  # Minimal events are built from the allowlist after full assembly so
367
374
  # context properties and parser-added metadata can never leak in.
@@ -417,6 +424,8 @@ module PostHog
417
424
 
418
425
  symbolize_keys! attrs
419
426
  attrs[:is_server] = @is_server
427
+ attrs[:lib] = @lib
428
+ attrs[:lib_version] = @lib_version
420
429
  enqueue(FieldParser.parse_for_identify(attrs))
421
430
  end
422
431
 
@@ -435,6 +444,8 @@ module PostHog
435
444
 
436
445
  symbolize_keys! attrs
437
446
  attrs[:is_server] = @is_server
447
+ attrs[:lib] = @lib
448
+ attrs[:lib_version] = @lib_version
438
449
  enqueue(FieldParser.parse_for_group_identify(attrs))
439
450
  end
440
451
 
@@ -450,6 +461,8 @@ module PostHog
450
461
 
451
462
  symbolize_keys! attrs
452
463
  attrs[:is_server] = @is_server
464
+ attrs[:lib] = @lib
465
+ attrs[:lib_version] = @lib_version
453
466
  enqueue(FieldParser.parse_for_alias(attrs))
454
467
  end
455
468
 
@@ -44,6 +44,7 @@ module PostHog
44
44
  # @param async_load [Boolean] When true, flag definitions are fetched only on the poller thread: an
45
45
  # immediate first tick at construction, then the regular polling cadence, which keeps retrying until a
46
46
  # load succeeds.
47
+ # @param user_agent [String] User-Agent header sent with feature flag requests.
47
48
  def initialize(
48
49
  polling_interval,
49
50
  secret_key,
@@ -53,7 +54,8 @@ module PostHog
53
54
  on_error = nil,
54
55
  flag_definition_cache_provider: nil,
55
56
  feature_flag_request_max_retries: nil,
56
- async_load: false
57
+ async_load: false,
58
+ user_agent: "posthog-ruby/#{PostHog::VERSION}"
57
59
  )
58
60
  @polling_interval = polling_interval || Defaults::FeatureFlags::POLLING_INTERVAL_SECONDS
59
61
  @secret_key = secret_key
@@ -72,6 +74,7 @@ module PostHog
72
74
  @flags_etag = Concurrent::AtomicReference.new(nil)
73
75
  @flag_definitions_loaded_at = Concurrent::AtomicReference.new(nil)
74
76
  @async_load = async_load
77
+ @user_agent = user_agent
75
78
  # Server-controlled gate for minimal `$feature_flag_called` events, read
76
79
  # from the top-level `minimal_flag_called_events` key of the local
77
80
  # evaluation definitions payload. false when the server does not send it.
@@ -1326,7 +1329,7 @@ module PostHog
1326
1329
  RETRYABLE_FLAGS_REQUEST_STATUS_CODES = [502, 504].freeze
1327
1330
 
1328
1331
  def _request(uri, request_object, timeout = nil, include_etag: false, retry_status_codes: [])
1329
- request_object['User-Agent'] = "posthog-ruby/#{PostHog::VERSION}"
1332
+ request_object['User-Agent'] = @user_agent
1330
1333
  request_timeout = timeout || 10
1331
1334
  backoff_policy = nil
1332
1335
  attempts = 0
@@ -144,8 +144,8 @@ module PostHog
144
144
  is_server = fields.fetch(:is_server, true) != false
145
145
 
146
146
  properties = {
147
- '$lib' => 'posthog-ruby',
148
- '$lib_version' => PostHog::VERSION.to_s
147
+ '$lib' => fields.fetch(:lib, 'posthog-ruby'),
148
+ '$lib_version' => fields.fetch(:lib_version, PostHog::VERSION.to_s)
149
149
  }
150
150
  properties['$is_server'] = true if is_server
151
151
 
@@ -45,6 +45,7 @@ module PostHog
45
45
  @pid = Process.pid
46
46
  @transport_options = {
47
47
  api_host: options[:host],
48
+ headers: options[:headers],
48
49
  skip_ssl_verification: options[:skip_ssl_verification],
49
50
  compress_request: options[:compress_request]
50
51
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PostHog
4
- VERSION = '3.23.5'
4
+ VERSION = '3.23.6'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posthog-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.23.5
4
+ version: 3.23.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''