posthog-ruby 3.35.3 → 3.35.4
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/client.rb +35 -13
- data/lib/posthog/logging.rb +1 -1
- data/lib/posthog/mcp/README.md +3 -2
- data/lib/posthog/mcp/log.rb +2 -2
- 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: ca76b03cf9cdedacc3fc41f55b03b28798b0f59c8a01fa11faa41de546b62c69
|
|
4
|
+
data.tar.gz: 626d764865453ddc624e5162b7b569357c620ff1a490befa401ba723d0f4269b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2e47a74d83e5226ade1d686670a93ebda829894c74850efc23f0112a22b63666eeda41df1cd9c09aaa445d4e48454c2e263d95832b30339bef0a638edeecae7d
|
|
7
|
+
data.tar.gz: f02e2e8188e821ddf662f2ea539889a5c34a403deb9ee9d8c1cd6a29325483607f7338762f5d8e96804518126df6dd2d860c72b53903460903dae2748609da2d
|
data/lib/posthog/client.rb
CHANGED
|
@@ -262,8 +262,8 @@ module PostHog
|
|
|
262
262
|
# @return [PostHog::Emails]
|
|
263
263
|
attr_reader :emails
|
|
264
264
|
|
|
265
|
-
# When sync_mode is enabled,
|
|
266
|
-
#
|
|
265
|
+
# When sync_mode is enabled, waits until any in-flight request completes or
|
|
266
|
+
# timeout is hit.
|
|
267
267
|
#
|
|
268
268
|
# Otherwise, waits until the worker has cleared the queue or timeout is hit.
|
|
269
269
|
# Note: The asynchronous wait polls and can be starved if another thread is
|
|
@@ -274,19 +274,14 @@ module PostHog
|
|
|
274
274
|
# @return [Boolean] +true+ if all pending events were sent, +false+ if the
|
|
275
275
|
# timeout elapsed first.
|
|
276
276
|
def flush(timeout: nil)
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
@sync_lock.synchronize {} # rubocop:disable Lint/EmptyBlock
|
|
280
|
-
return true
|
|
281
|
-
end
|
|
277
|
+
deadline = timeout && (monotonic_time + timeout)
|
|
278
|
+
return synchronized_within?(deadline) {} if @sync_mode # rubocop:disable Lint/EmptyBlock
|
|
282
279
|
|
|
283
280
|
if @worker.is_a?(NoopWorker)
|
|
284
281
|
clear
|
|
285
282
|
return true
|
|
286
283
|
end
|
|
287
284
|
|
|
288
|
-
deadline = timeout && (monotonic_time + timeout)
|
|
289
|
-
|
|
290
285
|
while !@queue.empty? || @worker.is_requesting?
|
|
291
286
|
ensure_worker_running
|
|
292
287
|
@worker.request_flush
|
|
@@ -965,9 +960,11 @@ module PostHog
|
|
|
965
960
|
# sent. After the timeout, this method may wait up to one additional second
|
|
966
961
|
# for worker and transport cleanup, which may continue after it returns.
|
|
967
962
|
#
|
|
963
|
+
# When sync_mode is set and the timeout elapses while a request is in
|
|
964
|
+
# flight, the connection is closed once that request completes.
|
|
965
|
+
#
|
|
968
966
|
# @param timeout [Numeric, nil] Maximum seconds to wait for pending events
|
|
969
|
-
# to be sent, or +nil+ to wait indefinitely.
|
|
970
|
-
# is true.
|
|
967
|
+
# to be sent, or +nil+ to wait indefinitely.
|
|
971
968
|
# @return [Boolean] +true+ if all pending events were sent, +false+ if the
|
|
972
969
|
# timeout elapsed first.
|
|
973
970
|
def shutdown(timeout: nil)
|
|
@@ -1000,8 +997,9 @@ module PostHog
|
|
|
1000
997
|
if @sync_mode
|
|
1001
998
|
# Waiting for @sync_lock lets any in-flight sync send finish before
|
|
1002
999
|
# the connection is closed.
|
|
1003
|
-
|
|
1004
|
-
|
|
1000
|
+
closed = synchronized_within?(deadline) { @transport&.shutdown }
|
|
1001
|
+
Thread.new { @sync_lock.synchronize { @transport&.shutdown } } unless closed
|
|
1002
|
+
closed
|
|
1005
1003
|
else
|
|
1006
1004
|
drained = flush(timeout: timeout)
|
|
1007
1005
|
@worker&.shutdown
|
|
@@ -1316,6 +1314,30 @@ module PostHog
|
|
|
1316
1314
|
end
|
|
1317
1315
|
end
|
|
1318
1316
|
|
|
1317
|
+
# Mutex has no timed lock, so a deadline polls try_lock.
|
|
1318
|
+
def synchronized_within?(deadline, &)
|
|
1319
|
+
unless deadline
|
|
1320
|
+
@sync_lock.synchronize(&)
|
|
1321
|
+
return true
|
|
1322
|
+
end
|
|
1323
|
+
return false if @sync_lock.owned?
|
|
1324
|
+
|
|
1325
|
+
locked = false
|
|
1326
|
+
begin
|
|
1327
|
+
# Deferring interrupts until locked is set keeps the ensure from missing a held lock.
|
|
1328
|
+
until Thread.handle_interrupt(Object => :never) { locked = @sync_lock.try_lock }
|
|
1329
|
+
remaining = deadline - monotonic_time
|
|
1330
|
+
return false if remaining <= 0
|
|
1331
|
+
|
|
1332
|
+
sleep(remaining.clamp(0, 0.01))
|
|
1333
|
+
end
|
|
1334
|
+
yield
|
|
1335
|
+
true
|
|
1336
|
+
ensure
|
|
1337
|
+
@sync_lock.unlock if locked
|
|
1338
|
+
end
|
|
1339
|
+
end
|
|
1340
|
+
|
|
1319
1341
|
def worker_running?
|
|
1320
1342
|
@worker_thread&.alive?
|
|
1321
1343
|
end
|
data/lib/posthog/logging.rb
CHANGED
data/lib/posthog/mcp/README.md
CHANGED
|
@@ -32,8 +32,9 @@ These are the few things that differ from what the docs describe for the other S
|
|
|
32
32
|
* **Composed schemas are left alone.** A tool whose `input_schema` is `oneOf`/`allOf`/`anyOf` or a
|
|
33
33
|
`$ref` has nothing injected into it and nothing stripped from its calls.
|
|
34
34
|
* **stdio servers own `$stdout`.** The integration's own messages go only to the `logger:` you pass
|
|
35
|
-
(default: nowhere)
|
|
36
|
-
core SDK's logger
|
|
35
|
+
(default: nowhere). The experimental notice goes to stderr, and outside Rails so do misconfiguration
|
|
36
|
+
warnings and the core SDK's default logger. Under Rails, warnings and SDK errors go to `Rails.logger`,
|
|
37
|
+
so keep it (and any custom `PostHog::Logging.logger`) off stdout.
|
|
37
38
|
|
|
38
39
|
## Layout
|
|
39
40
|
|
data/lib/posthog/mcp/log.rb
CHANGED
|
@@ -5,8 +5,8 @@ module PostHog
|
|
|
5
5
|
# Logging for the MCP integration.
|
|
6
6
|
#
|
|
7
7
|
# Debug-level chatter goes only to the `logger:` option (a no-op by default),
|
|
8
|
-
# because a stdio MCP server owns `$stdout` for the protocol and
|
|
9
|
-
#
|
|
8
|
+
# because a stdio MCP server owns `$stdout` for the protocol and an
|
|
9
|
+
# app-configured logger may write there. Warnings additionally reach the app's
|
|
10
10
|
# logger when Rails is loaded (where {PostHog::Logging.logger} wraps
|
|
11
11
|
# `Rails.logger`) and stderr otherwise, so misconfiguration is never silent
|
|
12
12
|
# and never corrupts a stdio transport.
|
data/lib/posthog/version.rb
CHANGED