posthog-ruby 3.34.4 → 3.35.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/feature_flag_evaluations.rb +0 -1
- data/lib/posthog/feature_flags.rb +0 -1
- data/lib/posthog/mcp/README.md +0 -3
- data/lib/posthog/mcp/analytics.rb +4 -4
- data/lib/posthog/mcp/ids.rb +1 -1
- data/lib/posthog/mcp/instrumentation.rb +5 -5
- data/lib/posthog/mcp/request_scope.rb +4 -10
- data/lib/posthog/mcp/sanitization.rb +0 -1
- data/lib/posthog/mcp/tracking_data.rb +2 -2
- data/lib/posthog/mcp.rb +3 -0
- data/lib/posthog/transport.rb +2 -2
- 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: 74ded46673020dda3dfaaf97e5911e0075f34b3c9eb482ba5ba3af9f2c67207a
|
|
4
|
+
data.tar.gz: 4a8609d238306cccbc1b80dd263dec54dd9a7317461cce2e15abfea9d1d2fac6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 57ebfdb7c813f13604d5ba589d16188076609e5945cba79b7bfd822380800b7aba81f9d41c085fcd20974c0a489b2cad32b13c9b73cc993b3cffdf6c022134d3
|
|
7
|
+
data.tar.gz: b02e0e22a71a2e2af00b31498f4ca05b137b4468500cce5966c8fb5fd22a6a90084f2ed0c43930e96bd957b35783da82b19d54222a42ee49d5313df449724bd6
|
data/lib/posthog/mcp/README.md
CHANGED
|
@@ -29,9 +29,6 @@ These are the few things that differ from what the docs describe for the other S
|
|
|
29
29
|
* **Truncation is tighter.** Events are truncated to fit the core client's 32KB per-message limit,
|
|
30
30
|
because posthog-ruby drops larger messages at batch time - truncating harder beats losing the
|
|
31
31
|
event.
|
|
32
|
-
* **Request scope needs Ruby 3.2+ to be inherited.** A custom event captured from a thread or fiber
|
|
33
|
-
a tool spawns is attributed to that request on 3.2+ (fiber storage); before 3.2 capture from the
|
|
34
|
-
tool body itself, or an HTTP server falls back to a standalone session.
|
|
35
32
|
* **Composed schemas are left alone.** A tool whose `input_schema` is `oneOf`/`allOf`/`anyOf` or a
|
|
36
33
|
`$ref` has nothing injected into it and nothing stripped from its calls.
|
|
37
34
|
* **stdio servers own `$stdout`.** The integration's own messages go only to the `logger:` you pass
|
|
@@ -63,8 +63,8 @@ module PostHog
|
|
|
63
63
|
# that has served an HTTP request the server-wide session is not a safe
|
|
64
64
|
# fallback: it belongs to whichever request settled it last, which under
|
|
65
65
|
# concurrency is somebody else's. That happens when a tool hands its work to
|
|
66
|
-
# a thread
|
|
67
|
-
#
|
|
66
|
+
# a thread that did not inherit the request's fiber storage, such as a pool
|
|
67
|
+
# created before the request. Fail closed with a standalone session
|
|
68
68
|
# rather than filing the event under another caller's identity; over stdio a
|
|
69
69
|
# server only ever talks to one client, so the fallback stays.
|
|
70
70
|
def current_session_id(data, scope)
|
|
@@ -90,8 +90,8 @@ module PostHog
|
|
|
90
90
|
Log.warn(
|
|
91
91
|
data.options,
|
|
92
92
|
'Warning: analytics.capture() ran without the scope of the request that started it, so its event got ' \
|
|
93
|
-
'a standalone $session_id instead of the caller\'s.
|
|
94
|
-
'
|
|
93
|
+
'a standalone $session_id instead of the caller\'s. The scope follows threads and fibers a tool ' \
|
|
94
|
+
'spawns, but not work handed to a thread created outside the request, such as an existing pool.'
|
|
95
95
|
)
|
|
96
96
|
end
|
|
97
97
|
end
|
data/lib/posthog/mcp/ids.rb
CHANGED
|
@@ -11,7 +11,7 @@ module PostHog
|
|
|
11
11
|
module Ids
|
|
12
12
|
module_function
|
|
13
13
|
|
|
14
|
-
# RFC 9562 UUIDv7 (time-ordered), implemented inline
|
|
14
|
+
# RFC 9562 UUIDv7 (time-ordered), implemented inline because `SecureRandom.uuid_v7` needs Ruby 3.3.
|
|
15
15
|
#
|
|
16
16
|
# @return [String] lowercase, hyphenated uuid
|
|
17
17
|
def uuid_v7
|
|
@@ -124,12 +124,12 @@ module PostHog
|
|
|
124
124
|
|
|
125
125
|
private
|
|
126
126
|
|
|
127
|
-
def dispatch_kind(&
|
|
127
|
+
def dispatch_kind(&)
|
|
128
128
|
case @kind
|
|
129
|
-
when :tools_call then dispatch_tool_call(&
|
|
130
|
-
when :tools_list then dispatch_tools_list(&
|
|
131
|
-
when :initialize then dispatch_initialize(&
|
|
132
|
-
else dispatch_generic(&
|
|
129
|
+
when :tools_call then dispatch_tool_call(&)
|
|
130
|
+
when :tools_list then dispatch_tools_list(&)
|
|
131
|
+
when :initialize then dispatch_initialize(&)
|
|
132
|
+
else dispatch_generic(&)
|
|
133
133
|
end
|
|
134
134
|
end
|
|
135
135
|
|
|
@@ -8,14 +8,12 @@ module PostHog
|
|
|
8
8
|
# HTTP headers cannot travel with the request object; this is the one place
|
|
9
9
|
# the integration relies on ambient state.
|
|
10
10
|
#
|
|
11
|
-
# Uses fiber storage (`Fiber[]
|
|
12
|
-
#
|
|
13
|
-
# fiber-local `Thread.current[]` on Ruby 3.0/3.1.
|
|
11
|
+
# Uses fiber storage (`Fiber[]`), which is per fiber, isolated per Ractor, and
|
|
12
|
+
# inherited by fibers/threads a tool spawns.
|
|
14
13
|
#
|
|
15
14
|
# @api private
|
|
16
15
|
module RequestScope
|
|
17
16
|
KEY = :posthog_mcp_request_scope
|
|
18
|
-
FIBER_STORAGE = Fiber.respond_to?(:[]) && Fiber.respond_to?(:[]=)
|
|
19
17
|
|
|
20
18
|
module_function
|
|
21
19
|
|
|
@@ -27,15 +25,11 @@ module PostHog
|
|
|
27
25
|
# even while another request on the same server is in flight. `actor` is absent until
|
|
28
26
|
# the request resolves identity, which is what tells {Analytics} it has none to use.
|
|
29
27
|
def current
|
|
30
|
-
|
|
28
|
+
Fiber[KEY]
|
|
31
29
|
end
|
|
32
30
|
|
|
33
31
|
def current=(value)
|
|
34
|
-
|
|
35
|
-
Fiber[KEY] = value
|
|
36
|
-
else
|
|
37
|
-
Thread.current[KEY] = value
|
|
38
|
-
end
|
|
32
|
+
Fiber[KEY] = value
|
|
39
33
|
end
|
|
40
34
|
|
|
41
35
|
# Rack `env` keys for the two request headers Rack stores without `HTTP_`.
|
data/lib/posthog/mcp.rb
CHANGED
|
@@ -63,8 +63,11 @@ module PostHog
|
|
|
63
63
|
# @return [PostHog::MCP::Analytics] handle for custom events; a no-op handle when
|
|
64
64
|
# instrumentation fails (logged, never raised)
|
|
65
65
|
# @raise [LoadError] when the `mcp` gem is not available
|
|
66
|
+
# Named so the documented `kwargs` parameter stays in the public signature.
|
|
67
|
+
# rubocop:disable Style/ArgumentsForwarding
|
|
66
68
|
def instrument(server, client = nil, options: nil, **kwargs)
|
|
67
69
|
opts = options.is_a?(Options) ? options : Options.new(**kwargs)
|
|
70
|
+
# rubocop:enable Style/ArgumentsForwarding
|
|
68
71
|
ensure_mcp_sdk!
|
|
69
72
|
experimental_notice!(opts)
|
|
70
73
|
|
data/lib/posthog/transport.rb
CHANGED
|
@@ -122,7 +122,7 @@ module PostHog
|
|
|
122
122
|
# duration to sleep between attempts
|
|
123
123
|
#
|
|
124
124
|
# Returns [last_result, raised_exception]
|
|
125
|
-
def retry_with_backoff(retries_remaining, &
|
|
125
|
+
def retry_with_backoff(retries_remaining, &)
|
|
126
126
|
result, caught_exception = nil
|
|
127
127
|
should_retry = false
|
|
128
128
|
|
|
@@ -137,7 +137,7 @@ module PostHog
|
|
|
137
137
|
if should_retry && (retries_remaining > 1)
|
|
138
138
|
logger.debug("Retrying request, #{retries_remaining} retries left")
|
|
139
139
|
sleep(retry_delay_seconds)
|
|
140
|
-
retry_with_backoff(retries_remaining - 1, &
|
|
140
|
+
retry_with_backoff(retries_remaining - 1, &)
|
|
141
141
|
else
|
|
142
142
|
[result, caught_exception]
|
|
143
143
|
end
|
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.35.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ''
|
|
@@ -100,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
100
100
|
requirements:
|
|
101
101
|
- - ">="
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '3.
|
|
103
|
+
version: '3.2'
|
|
104
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
requirements:
|
|
106
106
|
- - ">="
|