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 +4 -4
- data/lib/posthog/client.rb +21 -2
- data/lib/posthog/defaults.rb +1 -1
- data/lib/posthog/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 69348dbe265c2d43c2bf8531dacd7faf30e02dc8b6621ad99e634a762465374b
|
|
4
|
+
data.tar.gz: 2303defa785affa2c78a24608529b36582a29dbc69133bf17908665262edafe0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 68ad8367f240c9b78cfa7eecc40296e5f24bfcd60dd7db4498b2fddb7acf9f279a2e90e6bf06c25b965b568e8039bfd553bb2dc7ebc6001d145def99f0e63464
|
|
7
|
+
data.tar.gz: eaa6abbcf83d2f8f1f390dd3c244dbe10939fdbced0d4f1502395d036e49a7124554181dc466299d34aa5d6756569a662bf532cbac61afaef1e7aa99d54e6738
|
data/lib/posthog/client.rb
CHANGED
|
@@ -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://
|
|
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[:
|
|
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
|
|
data/lib/posthog/defaults.rb
CHANGED
data/lib/posthog/version.rb
CHANGED