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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19f299cd4a1cfc192bd98c7b5bc1ec1b1fed38bcefbe61fbad73b3b5f1567d54
4
- data.tar.gz: 20838301fba089aeaed57f14355c795145999ca4036b747ac933b9b57e6a2c9e
3
+ metadata.gz: 74ded46673020dda3dfaaf97e5911e0075f34b3c9eb482ba5ba3af9f2c67207a
4
+ data.tar.gz: 4a8609d238306cccbc1b80dd263dec54dd9a7317461cce2e15abfea9d1d2fac6
5
5
  SHA512:
6
- metadata.gz: 5ddd2561257e60ca531ff06dc0f2b936179901d85d1859872358af45fa38a4b1f3d51c94811adf09adf08e471fc69f7a088c4eba967e798dd635d11bb8eb4cb0
7
- data.tar.gz: 1880304e4a536a4eae1e7fd06b2a4a3583833ffd3eb19c2cd2533d527ed33d22814ab86d7216942bbd6ecbcebdfe60b4bf5776801b765d2ee62070dad74d5760
6
+ metadata.gz: 57ebfdb7c813f13604d5ba589d16188076609e5945cba79b7bfd822380800b7aba81f9d41c085fcd20974c0a489b2cad32b13c9b73cc993b3cffdf6c022134d3
7
+ data.tar.gz: b02e0e22a71a2e2af00b31498f4ca05b137b4468500cce5966c8fb5fd22a6a90084f2ed0c43930e96bd957b35783da82b19d54222a42ee49d5313df449724bd6
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'set'
4
3
  require 'posthog/feature_flag_error'
5
4
 
6
5
  module PostHog
@@ -12,7 +12,6 @@ require 'posthog/flag_definition_cache'
12
12
  require 'posthog/unresolved_flag_reason'
13
13
  require 'posthog/flag_evaluation_errors'
14
14
  require 'digest'
15
- require 'set'
16
15
 
17
16
  module PostHog
18
17
  # Polls and evaluates feature flag definitions for {PostHog::Client}.
@@ -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 or fiber it spawned on Ruby 3.0/3.1, where {RequestScope} is
67
- # fiber-local and is not inherited. Fail closed with a standalone session
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. On Ruby 3.2+ the scope follows threads and fibers ' \
94
- 'a tool spawns; before that it does not, so capture custom events from the tool body itself.'
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
@@ -11,7 +11,7 @@ module PostHog
11
11
  module Ids
12
12
  module_function
13
13
 
14
- # RFC 9562 UUIDv7 (time-ordered), implemented inline so Ruby 3.0/3.1 work too.
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(&handler)
127
+ def dispatch_kind(&)
128
128
  case @kind
129
- when :tools_call then dispatch_tool_call(&handler)
130
- when :tools_list then dispatch_tools_list(&handler)
131
- when :initialize then dispatch_initialize(&handler)
132
- else dispatch_generic(&handler)
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[]`, Ruby 3.2+), which is per fiber, isolated per
12
- # Ractor, and inherited by fibers/threads a tool spawns. Falls back to
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
- FIBER_STORAGE ? Fiber[KEY] : Thread.current[KEY]
28
+ Fiber[KEY]
31
29
  end
32
30
 
33
31
  def current=(value)
34
- if FIBER_STORAGE
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_`.
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'json'
4
- require 'set'
5
4
  require 'uri'
6
5
 
7
6
  module PostHog
@@ -40,11 +40,11 @@ module PostHog
40
40
  @tool_owned_params = {}
41
41
  end
42
42
 
43
- def synchronize(&block)
43
+ def synchronize(&)
44
44
  if @mutex.owned?
45
45
  yield
46
46
  else
47
- @mutex.synchronize(&block)
47
+ @mutex.synchronize(&)
48
48
  end
49
49
  end
50
50
 
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
 
@@ -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, &block)
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, &block)
140
+ retry_with_backoff(retries_remaining - 1, &)
141
141
  else
142
142
  [result, caught_exception]
143
143
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PostHog
4
- VERSION = '3.34.4'
4
+ VERSION = '3.35.0'
5
5
  end
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.34.4
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.0'
103
+ version: '3.2'
104
104
  required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - ">="