posthog-ruby 3.28.2 → 3.28.4
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/mcp/server_extension.rb +1 -1
- data/lib/posthog/message_batch.rb +34 -0
- 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: f6e3857125c3ca1a120a8ab1680b518c79ca92729186bf0dcc868d5d83126612
|
|
4
|
+
data.tar.gz: 5bce014fe04b202359313e36e6adae530dfc77a23be2824eb42c28b29a12fa8b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9df1007084659857d4f38c386cedc310a89a0c7adde2681b06bba0a8924b76545160092c2fd7140bc12a2f41038b69baf46ba40db5c3ef7c7b4394da1b30310e
|
|
7
|
+
data.tar.gz: 02c14a66f74f619b3da4f2e680f67a186e74f9193ffbb7149cdca12d5bb60d7b554983c8b66a69d46f38002c0caab6facadb5aa92bcd7b690969a6de25ddd038
|
|
@@ -11,7 +11,7 @@ module PostHog
|
|
|
11
11
|
module ServerExtension
|
|
12
12
|
private
|
|
13
13
|
|
|
14
|
-
def handle_request(request, method, session: nil, related_request_id: nil)
|
|
14
|
+
def handle_request(request, method, session: nil, related_request_id: nil, **kwargs)
|
|
15
15
|
handler = super
|
|
16
16
|
data = PostHog::MCP.tracking_data(self)
|
|
17
17
|
return handler unless data && handler.is_a?(Proc) && Instrumentation.tracked?(method)
|
|
@@ -26,6 +26,7 @@ module PostHog
|
|
|
26
26
|
# @return [Array<Hash>, nil]
|
|
27
27
|
def <<(message)
|
|
28
28
|
begin
|
|
29
|
+
message = normalize_non_finite_numbers(message)
|
|
29
30
|
message_json = message.to_json
|
|
30
31
|
rescue StandardError => e
|
|
31
32
|
raise JSONGenerationError, "Serialization error: #{e}"
|
|
@@ -57,6 +58,39 @@ module PostHog
|
|
|
57
58
|
|
|
58
59
|
private
|
|
59
60
|
|
|
61
|
+
def normalize_non_finite_numbers(message)
|
|
62
|
+
copies = {}.compare_by_identity
|
|
63
|
+
pending = []
|
|
64
|
+
normalized = copy_json_value(message, copies, pending)
|
|
65
|
+
|
|
66
|
+
# Traverse iteratively so circular/deep containers still reach the JSON encoder's error handling.
|
|
67
|
+
until pending.empty?
|
|
68
|
+
container = pending.pop
|
|
69
|
+
if container.is_a?(Hash)
|
|
70
|
+
container.transform_values! { |value| copy_json_value(value, copies, pending) }
|
|
71
|
+
else
|
|
72
|
+
container.map! { |value| copy_json_value(value, copies, pending) }
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
normalized
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def copy_json_value(value, copies, pending)
|
|
79
|
+
case value
|
|
80
|
+
when Float
|
|
81
|
+
value.finite? ? value : nil
|
|
82
|
+
when Hash, Array
|
|
83
|
+
copies.fetch(value) do
|
|
84
|
+
copy = value.clone(freeze: false)
|
|
85
|
+
copies[value] = copy
|
|
86
|
+
pending << copy
|
|
87
|
+
copy
|
|
88
|
+
end
|
|
89
|
+
else
|
|
90
|
+
value
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
60
94
|
def item_count_exhausted?
|
|
61
95
|
@messages.length >= @max_message_count
|
|
62
96
|
end
|
data/lib/posthog/version.rb
CHANGED