Class: PostHog::MCP::Sink Private
- Inherits:
-
Object
- Object
- PostHog::MCP::Sink
- Defined in:
- lib/posthog/mcp/sink.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
The capture pipeline: stringify keys -> sanitize -> truncate -> fan out into
$mcp_* / $exception payloads -> before_send -> PostHog::Client#capture.
Wraps a host-supplied client and never owns its lifecycle. Errors at any stage are logged and the event dropped, never re-raised into tool code.
Instance Attribute Summary collapse
- #client ⇒ Object readonly private
Instance Method Summary collapse
-
#capture(event, options = nil) ⇒ Array<Hash>
private
The payloads handed to the client (for tests).
-
#initialize(client) ⇒ Sink
constructor
private
A new instance of Sink.
-
#process(event, options = nil) ⇒ Object
private
Runs the full transform and returns the payloads that survived
before_send.
Constructor Details
#initialize(client) ⇒ Sink
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Sink.
15 16 17 |
# File 'lib/posthog/mcp/sink.rb', line 15 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/posthog/mcp/sink.rb', line 13 def client @client end |
Instance Method Details
#capture(event, options = nil) ⇒ Array<Hash>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the payloads handed to the client (for tests).
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/posthog/mcp/sink.rb', line 22 def capture(event, = nil) processed = process(event, ) return [] if processed.nil? processed.each { |payload| dispatch(payload) } processed rescue StandardError => e Log.debug(, "Failed to capture PostHog event: #{e.}") [] end |
#process(event, options = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Runs the full transform and returns the payloads that survived before_send.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/posthog/mcp/sink.rb', line 34 def process(event, = nil) processed = Sanitization.stringify_keys(event) begin processed = Sanitization.sanitize_event(processed) rescue StandardError => e Log.debug(, "Failed to sanitize event: #{e.}") return nil end begin processed = Truncation.truncate_event(processed) rescue StandardError => e Log.debug(, "Failed to truncate event: #{e.}") return nil end processed['id'] = Ids.new_prefixed_id('evt') unless processed['id'].is_a?(String) && !processed['id'].empty? autocapture = .nil? || .enable_exception_autocapture payloads = EventBuilder.build(processed, enable_exception_autocapture: autocapture) apply_before_send(payloads, ) end |