posthog-ruby 3.6.3 → 3.6.5

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: 9ee597d2f948853594d24df6345898f78d60cf7f9e1d4aeb527d74e87b89c2bf
4
- data.tar.gz: 8b8ca556f3e3666109c3594aba78a1ca1905d5a81a8ba94c09e1855414b4acbc
3
+ metadata.gz: 69348dbe265c2d43c2bf8531dacd7faf30e02dc8b6621ad99e634a762465374b
4
+ data.tar.gz: 2303defa785affa2c78a24608529b36582a29dbc69133bf17908665262edafe0
5
5
  SHA512:
6
- metadata.gz: 5c9907b374dc116192f3acfe89779917fbef94c54436e39c7a84b417c3ac5c2c092e4389547e3a3e19c9e9bf0a56354826889b60bfb61fb03608c77de2367c01
7
- data.tar.gz: 05fd1cf95d9fcd4c732a3abb212619057470f24bb440d6590615329425dff0729f861c78a2f391511b8f46f532ee09d01a7458d96fa7e22a4481867f5038931e
6
+ metadata.gz: 68ad8367f240c9b78cfa7eecc40296e5f24bfcd60dd7db4498b2fddb7acf9f279a2e90e6bf06c25b965b568e8039bfd553bb2dc7ebc6001d145def99f0e63464
7
+ data.tar.gz: eaa6abbcf83d2f8f1f390dd3c244dbe10939fdbced0d4f1502395d036e49a7124554181dc466299d34aa5d6756569a662bf532cbac61afaef1e7aa99d54e6738
@@ -59,7 +59,7 @@ module PostHog
59
59
  # on the calling thread. Useful in forking environments like Sidekiq
60
60
  # and Resque. Defaults to +false+.
61
61
  # @option opts [Proc] :on_error Handles error calls from the API.
62
- # @option opts [String] :host Fully qualified hostname of the PostHog server. Defaults to `https://app.posthog.com`
62
+ # @option opts [String] :host Fully qualified hostname of the PostHog server. Defaults to `https://us.i.posthog.com`
63
63
  # @option opts [Integer] :feature_flags_polling_interval How often to poll for feature flag definition changes.
64
64
  # Measured in seconds, defaults to 30.
65
65
  # @option opts [Integer] :feature_flag_request_timeout_seconds How long to wait for feature flag evaluation.
@@ -74,7 +74,9 @@ module PostHog
74
74
  def initialize(opts = {})
75
75
  symbolize_keys!(opts)
76
76
 
77
- opts[:host] ||= 'https://app.posthog.com'
77
+ opts[:api_key] = normalize_string_option(opts[:api_key])
78
+ opts[:personal_api_key] = normalize_string_option(opts[:personal_api_key], blank_as_nil: true)
79
+ opts[:host] = normalize_host_option(opts[:host])
78
80
 
79
81
  @queue = Queue.new
80
82
  @api_key = opts[:api_key]
@@ -102,6 +104,7 @@ module PostHog
102
104
  @personal_api_key = opts[:personal_api_key]
103
105
 
104
106
  check_api_key!
107
+ logger.error('api_key is empty after trimming whitespace; check your project API key') if @api_key == ''
105
108
 
106
109
  # Warn when multiple clients are created with the same API key (can cause dropped events)
107
110
  unless opts[:test_mode] || opts[:disable_singleton_warning]
@@ -585,6 +588,22 @@ module PostHog
585
588
  raise ArgumentError, 'API key must be initialized' if @api_key.nil?
586
589
  end
587
590
 
591
+ def normalize_string_option(value, blank_as_nil: false)
592
+ return value unless value.is_a?(String)
593
+
594
+ normalized = value.strip
595
+ return nil if blank_as_nil && normalized.empty?
596
+
597
+ normalized
598
+ end
599
+
600
+ def normalize_host_option(host)
601
+ normalized = normalize_string_option(host)
602
+ return 'https://us.i.posthog.com' if normalized.nil? || normalized.empty?
603
+
604
+ normalized
605
+ end
606
+
588
607
  def ensure_worker_running
589
608
  return if worker_running?
590
609
 
@@ -5,7 +5,7 @@ module PostHog
5
5
  MAX_HASH_SIZE = 50_000
6
6
 
7
7
  module Request
8
- HOST = 'app.posthog.com'
8
+ HOST = 'us.i.posthog.com'
9
9
  PORT = 443
10
10
  PATH = '/batch/'
11
11
  SSL = true
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PostHog
4
- VERSION = '3.6.3'
4
+ VERSION = '3.6.5'
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.6.3
4
+ version: 3.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''