posthog-ruby 3.37.1 → 3.38.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/mcp/README.md +3 -9
- data/lib/posthog/mcp/analytics.rb +0 -2
- data/lib/posthog/mcp/client.rb +0 -2
- data/lib/posthog/mcp/options.rb +0 -2
- data/lib/posthog/mcp/rack_middleware.rb +0 -3
- data/lib/posthog/mcp.rb +1 -26
- 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: d05f7ca67ab432b07008d64fec5f39fb6c4480ffbb6ca45928d510884212f879
|
|
4
|
+
data.tar.gz: a9c2041dd36b0879f99ff40181300852a24993b3d5da415e4d1e0a7603f50fb4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4686b3814782dde23623aec3830fc8f5ea55c44b257db1e5962092cdc28bca447e9301f52ded4c7c728b058caffdb2f53b95443e617960a4b5d26ed731e541bb
|
|
7
|
+
data.tar.gz: 57d34acf114eb5c8f7e519aafab4ce7248f499bc506e64d94dfb53cf68aa304e92a7d2492dd44526d582f3a323d4c7347c24bb33b649a96be6c5c10b1b42c85b
|
data/lib/posthog/mcp/README.md
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
# PostHog MCP analytics for Ruby
|
|
2
2
|
|
|
3
|
-
> **Experimental and unsupported.** `PostHog::MCP` is not an officially supported PostHog SDK: no
|
|
4
|
-
> support is provided for it, and its API, options, and the captured `$mcp_*` event schema may change
|
|
5
|
-
> in a minor release. A one-line warning is logged when you require it. Bug reports and patches are
|
|
6
|
-
> welcome at https://github.com/PostHog/posthog-ruby/issues, but don't build production reporting on
|
|
7
|
-
> it yet.
|
|
8
|
-
|
|
9
3
|
Product analytics for [Model Context Protocol](https://modelcontextprotocol.io) servers built on the
|
|
10
4
|
official Ruby [`mcp`](https://rubygems.org/gems/mcp) gem. Wrap an `MCP::Server` so every tool call,
|
|
11
5
|
agent intent, handshake, listing, prompt, resource read, and failure is captured to PostHog.
|
|
@@ -32,9 +26,9 @@ These are the few things that differ from what the docs describe for the other S
|
|
|
32
26
|
* **Composed schemas are left alone.** A tool whose `input_schema` is `oneOf`/`allOf`/`anyOf` or a
|
|
33
27
|
`$ref` has nothing injected into it and nothing stripped from its calls.
|
|
34
28
|
* **stdio servers own `$stdout`.** The integration's own messages go only to the `logger:` you pass
|
|
35
|
-
(default: nowhere).
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
(default: nowhere). Outside Rails, misconfiguration warnings and the core SDK's default logger go
|
|
30
|
+
to stderr. Under Rails, warnings and SDK errors go to `Rails.logger`, so keep it (and any custom
|
|
31
|
+
`PostHog::Logging.logger`) off stdout.
|
|
38
32
|
|
|
39
33
|
## Layout
|
|
40
34
|
|
|
@@ -4,8 +4,6 @@ module PostHog
|
|
|
4
4
|
module MCP
|
|
5
5
|
# Handle returned by {PostHog::MCP.instrument}. Emits custom events onto the
|
|
6
6
|
# same pipeline as the auto-captured `$mcp_*` events.
|
|
7
|
-
#
|
|
8
|
-
# @note Experimental.
|
|
9
7
|
class Analytics
|
|
10
8
|
FLUSH_TIMEOUT_SECONDS = 10
|
|
11
9
|
private_constant :FLUSH_TIMEOUT_SECONDS
|
data/lib/posthog/mcp/client.rb
CHANGED
|
@@ -8,8 +8,6 @@ module PostHog
|
|
|
8
8
|
# events flow through the same sanitize -> truncate -> `$exception` fan-out
|
|
9
9
|
# pipeline as {PostHog::MCP.instrument}. Does not need the `mcp` gem.
|
|
10
10
|
#
|
|
11
|
-
# @note Experimental.
|
|
12
|
-
#
|
|
13
11
|
# @example
|
|
14
12
|
# posthog = PostHog::MCP::Client.new(api_key: 'phc_...', host: 'https://us.i.posthog.com')
|
|
15
13
|
# posthog.capture_tool_call('search_docs', duration_ms: 42, distinct_id: 'user_123')
|
data/lib/posthog/mcp/options.rb
CHANGED
|
@@ -43,8 +43,6 @@ module PostHog
|
|
|
43
43
|
:is_missing_capability, keyword_init: true)
|
|
44
44
|
|
|
45
45
|
# Configuration for {PostHog::MCP.instrument}.
|
|
46
|
-
#
|
|
47
|
-
# @note Experimental: option names may change in a future minor release.
|
|
48
46
|
class Options
|
|
49
47
|
# @return [#call, nil] STDIO-safe log sink receiving single String messages. Default: no-op.
|
|
50
48
|
attr_reader :logger
|
|
@@ -22,9 +22,6 @@ module PostHog
|
|
|
22
22
|
# The decoded token (replayed or freshly minted) is exposed to the app as
|
|
23
23
|
# `env['posthog_mcp.session']` ({SessionTokenPayload}).
|
|
24
24
|
#
|
|
25
|
-
# @note Experimental. `PostHog::MCP` is not officially supported; see the
|
|
26
|
-
# docs at https://posthog.com/docs/mcp-analytics.
|
|
27
|
-
#
|
|
28
25
|
# @example An instrumented server behind a custom Rack stack
|
|
29
26
|
# use PostHog::MCP::RackMiddleware
|
|
30
27
|
#
|
data/lib/posthog/mcp.rb
CHANGED
|
@@ -33,10 +33,7 @@ module PostHog
|
|
|
33
33
|
# Wrap an `MCP::Server` so every tool call, handshake, listing, prompt,
|
|
34
34
|
# resource read, and failure is captured to PostHog as a `$mcp_*` event.
|
|
35
35
|
#
|
|
36
|
-
#
|
|
37
|
-
# this integration, and its API and the captured event schema may change in a
|
|
38
|
-
# minor release. A warning is logged when this file is required.
|
|
39
|
-
# Docs: https://posthog.com/docs/mcp-analytics
|
|
36
|
+
# Docs: https://posthog.com/docs/mcp-analytics
|
|
40
37
|
#
|
|
41
38
|
# @example
|
|
42
39
|
# require 'posthog/mcp'
|
|
@@ -48,11 +45,6 @@ module PostHog
|
|
|
48
45
|
# # With posthog-rails the client is resolved from PostHog.client:
|
|
49
46
|
# PostHog::MCP.instrument(server)
|
|
50
47
|
module MCP
|
|
51
|
-
EXPERIMENTAL_NOTICE =
|
|
52
|
-
'PostHog::MCP is experimental and not officially supported: no support is provided for it, and its ' \
|
|
53
|
-
'API and the captured $mcp_* event schema may change in a minor release. Docs: ' \
|
|
54
|
-
'https://posthog.com/docs/mcp-analytics. Feedback welcome at https://github.com/PostHog/posthog-ruby/issues.'
|
|
55
|
-
|
|
56
48
|
class << self
|
|
57
49
|
# Instrument an `MCP::Server`.
|
|
58
50
|
#
|
|
@@ -70,7 +62,6 @@ module PostHog
|
|
|
70
62
|
opts = options.is_a?(Options) ? options : Options.new(**kwargs)
|
|
71
63
|
# rubocop:enable Style/ArgumentsForwarding
|
|
72
64
|
ensure_mcp_sdk!
|
|
73
|
-
experimental_notice!(opts)
|
|
74
65
|
|
|
75
66
|
begin
|
|
76
67
|
unless server.is_a?(::MCP::Server)
|
|
@@ -147,20 +138,6 @@ module PostHog
|
|
|
147
138
|
defined?(::MCP::Server) ? true : false
|
|
148
139
|
end
|
|
149
140
|
|
|
150
|
-
# @api private
|
|
151
|
-
def experimental_notice!(options = nil)
|
|
152
|
-
Log.debug(options, EXPERIMENTAL_NOTICE)
|
|
153
|
-
return if @experimental_notice_shown
|
|
154
|
-
|
|
155
|
-
@experimental_notice_shown = true
|
|
156
|
-
Kernel.warn("[posthog-ruby] #{EXPERIMENTAL_NOTICE}")
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
# @api private
|
|
160
|
-
def reset_for_tests!
|
|
161
|
-
@experimental_notice_shown = false
|
|
162
|
-
end
|
|
163
|
-
|
|
164
141
|
private
|
|
165
142
|
|
|
166
143
|
def ensure_mcp_sdk!
|
|
@@ -224,5 +201,3 @@ rescue LoadError
|
|
|
224
201
|
# The `mcp` gem is a peer dependency of PostHog::MCP.instrument; PostHog::MCP::Client
|
|
225
202
|
# (custom dispatchers) works without it. `instrument` raises a LoadError with a hint.
|
|
226
203
|
end
|
|
227
|
-
|
|
228
|
-
PostHog::MCP.experimental_notice!
|
data/lib/posthog/version.rb
CHANGED