posthog-ruby 3.30.1 → 3.30.3

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: 3323f6b57f59dee5d46a1155a9590321db63de451469e7eb300669e2d5764c76
4
- data.tar.gz: 8937b2a07396151e8721d91d83e53dc4f75a38762eeef6c4559b43bd33b2e35e
3
+ metadata.gz: ec40e402922143be4f22157257b68e9defda8ba3a295a0aecfc96134c4aaa037
4
+ data.tar.gz: bd9f64d9cef723f651d0fffd6a0fd869ddbf702bc5ec3f2b130251e0414de627
5
5
  SHA512:
6
- metadata.gz: a68a913329b8a51ac472e2767518285c55afaed27ec70af46d1fef8bd97ec07f89ba1b8b92d1133d63b0c64e3246d1d81712b4fc8e87da15f8805e0fcb35dd8c
7
- data.tar.gz: cea4bf1a1ecd6e0f608838175e144516673b01903118d82d05f0ada8b881682bceb5ccd1db647e17346f4b5774aa2ad0ffcb9980ad51ca8f982e2af617c6870e
6
+ metadata.gz: 5da3c282d9ac3f78bd6ccc34637a32ecdda5a99c0807c055f4c8f6ed47da5b46d64c1ec2c16aacd3a9fbf399f9a3bcc63f954058b182bf22bae5855e9a6bb4d8
7
+ data.tar.gz: 23e3fd4a70c576a096ddc47c628cc86ce0294c7436a33366d4accfb142f27d29fb59f7f8b181cda3d174523312eab90c75e95f0c754d71a0fd4f9f9a623e3121
@@ -1804,6 +1804,8 @@ module PostHog
1804
1804
  # the definition by content and ignores key order, so a reordered copy does not warn again.
1805
1805
  def _unresolvable_flags(flags, flags_by_key, cohorts, group_type_mapping)
1806
1806
  flags.each_with_object({}) do |flag, unresolvable|
1807
+ next if flag[:evaluation_runtime] == 'client'
1808
+
1807
1809
  reason = self.class.definition_unresolved_reason(flag, flags_by_key, cohorts, group_type_mapping)
1808
1810
  next if reason.nil? || flag[:key].nil?
1809
1811
 
@@ -249,7 +249,7 @@ module PostHog
249
249
  yield
250
250
  rescue StandardError => e
251
251
  safely do
252
- session_id = prepare_request(@request, skip_initialize: true)
252
+ session_id = prepare_request(@request)
253
253
  record_initialize(session_id, client_name, client_version, requested_version, error: e)
254
254
  end
255
255
  raise
@@ -258,7 +258,7 @@ module PostHog
258
258
  safely do
259
259
  negotiated = (result.is_a?(Hash) ? fetch(result, :protocolVersion) : nil) || requested_version
260
260
  minted = mint_session_token(client_name, client_version, negotiated, requested_version)
261
- session_id = prepare_request(@request, skip_initialize: true, token: minted)
261
+ session_id = prepare_request(@request, token: minted)
262
262
  record_initialize(session_id, client_name, client_version, negotiated, response: result)
263
263
  end
264
264
  result
@@ -360,7 +360,6 @@ module PostHog
360
360
  end
361
361
 
362
362
  def record_initialize(session_id, client_name, client_version, protocol_version, response: nil, error: nil)
363
- @data.mark_session_initialized(session_id)
364
363
  event = base_event(EventType::MCP_INITIALIZE, session_id, @request)
365
364
  event['client_name'] = client_name
366
365
  event['client_version'] = client_version
@@ -442,8 +441,8 @@ module PostHog
442
441
  @scope[:session_id] = session_id if @scope.is_a?(Hash)
443
442
  end
444
443
 
445
- # Resolve the session id, run identify, then lazily emit initialize.
446
- def prepare_request(request, conversation_id: nil, skip_initialize: false, token: nil)
444
+ # Resolve the session id and run identify.
445
+ def prepare_request(request, conversation_id: nil, token: nil)
447
446
  token ||= @token
448
447
  session_id, source = Session.resolve(@data, mcp_session_id(token), token: token,
449
448
  conversation_id: conversation_id)
@@ -463,30 +462,9 @@ module PostHog
463
462
  @scope[:actor] = actor if @scope.is_a?(Hash)
464
463
  self.class.capture_event(@data, identify_event, actor: actor) if identify_event
465
464
  end
466
- maybe_emit_initialize(session_id, request) unless skip_initialize
467
465
  session_id
468
466
  end
469
467
 
470
- def maybe_emit_initialize(session_id, request)
471
- # Claiming is atomic: two threads opening the same session concurrently
472
- # must not both get past the check and emit an initialize each.
473
- return unless @data.claim_session_initialized(session_id)
474
-
475
- name, version = client_identity(request)
476
- event = {
477
- 'event_type' => EventType::MCP_INITIALIZE,
478
- 'session_id' => session_id,
479
- 'client_name' => name,
480
- 'client_version' => version,
481
- 'protocol_version' => protocol_version,
482
- 'timestamp' => Time.now.utc
483
- }
484
- props = resolve_event_properties({ method: 'initialize', params: {} })
485
- event['properties'] = props unless props.nil?
486
- TransportIdentity.stamp(event, @headers)
487
- self.class.capture_event(@data, event, actor: actor_for(session_id))
488
- end
489
-
490
468
  # Era is decided by the version the client *asked for*:
491
469
  # a client declaring the 2026-07-28 revision or later must not be answered
492
470
  # with an `Mcp-Session-Id`, even though this gem counter-offers a legacy version.
@@ -7,8 +7,6 @@ module PostHog
7
7
  #
8
8
  # @api private
9
9
  class TrackingData
10
- MAX_INITIALIZED_SESSIONS = 1000
11
-
12
10
  attr_reader :options, :sink, :server_name, :server_version, :identified_sessions,
13
11
  :tool_descriptions, :tool_categories, :tool_output_instructions, :tool_owned_params
14
12
  attr_accessor :session_id, :session_source, :last_mcp_session_id, :last_activity, :warned_no_stateless_session,
@@ -40,7 +38,6 @@ module PostHog
40
38
  # Which injected argument names the analytics layer owns per tool (i.e.
41
39
  # the tool does not declare them itself).
42
40
  @tool_owned_params = {}
43
- @initialized_sessions = {}
44
41
  end
45
42
 
46
43
  def synchronize(&block)
@@ -51,31 +48,6 @@ module PostHog
51
48
  end
52
49
  end
53
50
 
54
- def mark_session_initialized(session_id)
55
- synchronize do
56
- @initialized_sessions.delete(session_id)
57
- @initialized_sessions[session_id] = true
58
- @initialized_sessions.shift while @initialized_sessions.length > MAX_INITIALIZED_SESSIONS
59
- end
60
- end
61
-
62
- def session_initialized?(session_id)
63
- synchronize { @initialized_sessions.key?(session_id) }
64
- end
65
-
66
- # Claim the one lazy initialize event a session gets. Check and mark are a
67
- # single critical section, so when concurrent first requests race only the
68
- # caller that inserted the key sees `true` and emits `$mcp_initialize`.
69
- def claim_session_initialized(session_id)
70
- synchronize do
71
- next false if @initialized_sessions.key?(session_id)
72
-
73
- @initialized_sessions[session_id] = true
74
- @initialized_sessions.shift while @initialized_sessions.length > MAX_INITIALIZED_SESSIONS
75
- true
76
- end
77
- end
78
-
79
51
  def remember_tool(name, description: nil, category: nil, owned_params: nil, output_instructions: nil)
80
52
  synchronize do
81
53
  @tool_descriptions[name] = description if description.is_a?(String) && !description.empty?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PostHog
4
- VERSION = '3.30.1'
4
+ VERSION = '3.30.3'
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.30.1
4
+ version: 3.30.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''