posthog-ruby 3.24.0 → 3.25.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 +4 -4
- data/lib/posthog/client.rb +21 -0
- data/lib/posthog/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2ff857115cd53eb41945a0bad1a05768bb54770b4f5e2d8e8fda17a2bdb8a758
|
|
4
|
+
data.tar.gz: 910d5e7ade22aa5c3d8fed8794ad4f3b72230f1c649e40de8790b2acc9fa80e9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 34f457e72fb2c137e38f6188b9fb63dfb9541a21b705f373e1c4d39d4037c70ae2762f48774d9fbdfec015f3c745a6e0d6775e56c57d011b8f57bc5ee99e299c
|
|
7
|
+
data.tar.gz: dccddee87b9b57ae401a36f31f76685bb353974eb94c390d564582ad79cf4060544ede2b28229f87de486afb68d0f740b28becd8dcd878ab96494b1b0c6958de
|
data/lib/posthog/client.rb
CHANGED
|
@@ -44,9 +44,16 @@ module PostHog
|
|
|
44
44
|
$is_server
|
|
45
45
|
$lib
|
|
46
46
|
$lib_version
|
|
47
|
+
$release_id
|
|
47
48
|
].flat_map { |key| [key, key.to_sym] }.freeze
|
|
48
49
|
private_constant :MINIMAL_FLAG_CALLED_EVENT_PROPERTIES
|
|
49
50
|
|
|
51
|
+
# Holds the id that `posthog-cli release resolve` prints. Error tracking
|
|
52
|
+
# links an exception to its release by this id, because a Ruby app has no
|
|
53
|
+
# build step that could inject it.
|
|
54
|
+
RELEASE_ID_ENV_VAR = 'POSTHOG_RELEASE_ID'
|
|
55
|
+
private_constant :RELEASE_ID_ENV_VAR
|
|
56
|
+
|
|
50
57
|
# Thread-safe tracking of client instances per API key for singleton warnings
|
|
51
58
|
@instances_by_api_key = {}
|
|
52
59
|
@instances_mutex = Mutex.new
|
|
@@ -217,6 +224,7 @@ module PostHog
|
|
|
217
224
|
|
|
218
225
|
@before_send = opts[:before_send]
|
|
219
226
|
@is_server = opts.fetch(:is_server, true) != false
|
|
227
|
+
@release_id = normalize_string_option(ENV.fetch(RELEASE_ID_ENV_VAR, nil), blank_as_nil: true)
|
|
220
228
|
@deprecation_emitted_for = Concurrent::Set.new
|
|
221
229
|
end
|
|
222
230
|
|
|
@@ -1137,6 +1145,8 @@ module PostHog
|
|
|
1137
1145
|
def enqueue(action)
|
|
1138
1146
|
return false if @disabled || shutdown?
|
|
1139
1147
|
|
|
1148
|
+
# Every event type passes through here, and before_send still sees the id.
|
|
1149
|
+
action = add_release_id(action)
|
|
1140
1150
|
action = process_before_send(action)
|
|
1141
1151
|
return false if action.nil? || action.empty?
|
|
1142
1152
|
|
|
@@ -1168,6 +1178,17 @@ module PostHog
|
|
|
1168
1178
|
end
|
|
1169
1179
|
end
|
|
1170
1180
|
|
|
1181
|
+
# A `$release_id` the caller or the request context already set wins.
|
|
1182
|
+
def add_release_id(action)
|
|
1183
|
+
return action if @release_id.nil?
|
|
1184
|
+
|
|
1185
|
+
properties = action[:properties]
|
|
1186
|
+
return action unless properties.is_a?(Hash)
|
|
1187
|
+
return action if properties.key?('$release_id') || properties.key?(:$release_id)
|
|
1188
|
+
|
|
1189
|
+
action.merge(properties: properties.merge('$release_id' => @release_id))
|
|
1190
|
+
end
|
|
1191
|
+
|
|
1171
1192
|
def normalize_string_option(value, blank_as_nil: false)
|
|
1172
1193
|
return value unless value.is_a?(String)
|
|
1173
1194
|
|
data/lib/posthog/version.rb
CHANGED
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.
|
|
4
|
+
version: 3.25.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ''
|
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
100
100
|
- !ruby/object:Gem::Version
|
|
101
101
|
version: '0'
|
|
102
102
|
requirements: []
|
|
103
|
-
rubygems_version: 4.0.
|
|
103
|
+
rubygems_version: 4.0.20
|
|
104
104
|
specification_version: 4
|
|
105
105
|
summary: PostHog library
|
|
106
106
|
test_files: []
|