znyx-sdk 1.2.1 → 1.2.2

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: 816193b73770d4949028adf8359e4e402aa8cdd2fc9a2f39235ea9bc47acc946
4
- data.tar.gz: 4cff940a92b4b7905422405a09a70e6f08864d08f318adb8e20c58e2ce5e3a8f
3
+ metadata.gz: 5fd9be653cf74c03cdf4c2bfa14b6b1b68d8e66f61e1b74fe2c728c171f08772
4
+ data.tar.gz: 96f53a1fe2ee7d1acd9366bc12a1622bddc734c1e1c63091230bfd31371360d6
5
5
  SHA512:
6
- metadata.gz: 71e56c056f15328e7f7cb1a83177906755f6fbb8e5279700b593673f09a49b04ab7754a611fc5f660e47bde51975491f35155377270f51da190942f3286ea3ad
7
- data.tar.gz: fb7938b04ed59c4b2b3d51c6245b25f1a0ca58b0b5329fff2096a96b732d2f31c76f48dee14cfa3f72958791114e7af6b5bbb709b30b519e3c40474429324d53
6
+ metadata.gz: 3be73e2f490347a9eb925da15e70cbb3b1fad9688c2c25b2fe37e42099803e24248d9288f400a99151b291f68c3eb227a63aa3ad320cecabac3d3a5596c4a157
7
+ data.tar.gz: 66b85bb0a0eb2d4d1adfa7ab4e077a0727818c82e39246bcf46b358f70282e21e4c55f4cd9ff1278223de9cacb509d0bc1ab3fdc224b527a99ab66e177c9a1c0
@@ -79,6 +79,15 @@ module ZnyxSdk
79
79
  }.merge(kwargs.compact)
80
80
  end
81
81
 
82
+ # Resolved defensively: `post` runs on the request hot path and
83
+ # znyx_sdk.rb defines VERSION *after* requiring this file, so a partial
84
+ # require (`require "znyx_sdk/client"` alone) would otherwise raise
85
+ # NameError mid-request. A missing version is metadata we can do without;
86
+ # a broken evaluation call is not.
87
+ def sdk_version
88
+ defined?(ZnyxSdk::VERSION) ? ZnyxSdk::VERSION : "unknown"
89
+ end
90
+
82
91
  def post(path, payload)
83
92
  http = Net::HTTP.new(@uri.host, @uri.port)
84
93
  http.use_ssl = @uri.scheme == "https"
@@ -87,6 +96,16 @@ module ZnyxSdk
87
96
 
88
97
  request = Net::HTTP::Post.new(path)
89
98
  request["Content-Type"] = "application/json"
99
+ # X-Znyx-Sdk/-Version identify the calling SDK. The runtime records the
100
+ # newest pair it sees and forwards it to the control plane with its own
101
+ # heartbeat, which is what lets the console show an operator the SDK
102
+ # version their applications are actually running - anonymous install
103
+ # telemetry cannot answer that, as it carries no org.
104
+ #
105
+ # X-Znyx-Sdk reuses the telemetry `source` vocabulary ("ruby-sdk"), so the
106
+ # console and the admin install table label languages identically.
107
+ request["X-Znyx-Sdk"] = "ruby-sdk"
108
+ request["X-Znyx-Sdk-Version"] = sdk_version
90
109
  request["Authorization"] = "Bearer #{@api_key}" if @api_key
91
110
  request.body = JSON.generate(payload)
92
111
 
@@ -106,8 +125,9 @@ module ZnyxSdk
106
125
  raise ZnyxError, "HTTP request failed: #{e.message}"
107
126
  end
108
127
 
128
+ # 128-bit random id, same shape as the other SDKs.
109
129
  def new_request_id
110
- "req_#{SecureRandom.hex(4)}"
130
+ SecureRandom.uuid
111
131
  end
112
132
  end
113
133
  end
@@ -13,8 +13,10 @@ module ZnyxSdk
13
13
  #
14
14
  # Sends a single fire-and-forget ping when a client is first constructed, then
15
15
  # at most one "heartbeat" ping per 24h. Non-sensitive metadata only:
16
- # install_id (random UUID, persisted to ~/.znyx/sdk-state.json), SDK version,
17
- # source ("ruby-sdk"), OS / arch / Ruby version, run_count.
16
+ # install_id (random UUID, persisted to ~/.znyx/sdk-state-ruby.json), SDK
17
+ # version, source ("ruby-sdk"), OS / arch / Ruby version, run_count. The state
18
+ # file is per language, so this SDK's ping schedule is independent of any other
19
+ # ZNYX SDK installed on the same machine.
18
20
  #
19
21
  # No PII, no request content, no tenant data. Opt out with
20
22
  # ZNYX_TELEMETRY=false (on by default). Disclosed once to stderr on the first
@@ -25,13 +27,20 @@ module ZnyxSdk
25
27
  # install telemetry is on out of the box (opt-out, fully transparent).
26
28
  # Override with ZNYX_TELEMETRY_URL (or ZNYX_HEARTBEAT_URL), or opt out with
27
29
  # ZNYX_TELEMETRY=false.
28
- ENDPOINT = (
29
- (ENV["ZNYX_TELEMETRY_URL"] || "").empty? ? nil : ENV["ZNYX_TELEMETRY_URL"]
30
- ) || (
31
- (ENV["ZNYX_HEARTBEAT_URL"] || "").empty? ? nil : ENV["ZNYX_HEARTBEAT_URL"]
32
- ) || "https://cp.znyx.ai/v1/install-telemetry"
33
-
34
- STATE_FILE = File.join(Dir.home, ".znyx", "sdk-state.json")
30
+ #
31
+ # Defaults to the ZNYX receiver. An EMPTY value removes the destination, which is
32
+ # distinct from leaving it unset: with no destination nothing is sent even though this
33
+ # SDK is opt-out, giving an air-gapped deployment a verifiable guarantee. Hence the
34
+ # nil? checks rather than empty? — the latter would collapse "" back into the default.
35
+ ENDPOINT = if !ENV["ZNYX_TELEMETRY_URL"].nil?
36
+ ENV["ZNYX_TELEMETRY_URL"].strip
37
+ elsif !ENV["ZNYX_HEARTBEAT_URL"].nil?
38
+ ENV["ZNYX_HEARTBEAT_URL"].strip
39
+ else
40
+ "https://cp.znyx.ai/v1/install-telemetry"
41
+ end
42
+
43
+ STATE_FILE = File.join(Dir.home, ".znyx", "sdk-state-ruby.json")
35
44
  HEARTBEAT_INTERVAL = 86_400 # seconds (24h)
36
45
  SOURCE = "ruby-sdk"
37
46
 
@@ -87,16 +96,18 @@ module ZnyxSdk
87
96
  end
88
97
 
89
98
  payload = {
90
- install_id: install_id,
91
- version: version,
92
- event_type: event_type,
93
- source: SOURCE,
94
- os: RbConfig::CONFIG["host_os"],
95
- os_version: host_os_version,
96
- arch: RbConfig::CONFIG["host_cpu"],
97
- ruby_version: RUBY_VERSION,
98
- run_count: run_count,
99
- timestamp: now_iso
99
+ install_id: install_id,
100
+ version: version,
101
+ event_type: event_type,
102
+ source: SOURCE,
103
+ os: RbConfig::CONFIG["host_os"],
104
+ os_version: host_os_version,
105
+ arch: RbConfig::CONFIG["host_cpu"],
106
+ # The receiver stores every SDK's language runtime version in its
107
+ # python_version field; "source" says which runtime this really is.
108
+ python_version: RUBY_VERSION,
109
+ run_count: run_count,
110
+ timestamp: now_iso
100
111
  }
101
112
 
102
113
  Thread.new { post(payload) }
data/lib/znyx_sdk.rb CHANGED
@@ -3,5 +3,15 @@ require_relative "znyx_sdk/client"
3
3
  require_relative "znyx_sdk/telemetry"
4
4
 
5
5
  module ZnyxSdk
6
- VERSION = "1.0.1"
6
+ # Resolved from the loaded gem spec, never a literal.
7
+ #
8
+ # The publish workflow stamps the release tag into ruby/*.gemspec ONLY, so a
9
+ # literal here is never updated by a release and goes stale - Telemetry#version
10
+ # reads this constant, so every install reported the same frozen number
11
+ # regardless of the gem version actually installed.
12
+ #
13
+ # Gem.loaded_specs is populated for the normal RubyGems/Bundler install path.
14
+ # A vendored source checkout has no spec, and is marked as obviously-unreal
15
+ # rather than guessing a number.
16
+ VERSION = (Gem.loaded_specs["znyx-sdk"]&.version&.to_s || "0.0.0+unknown").freeze
7
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: znyx-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zitrino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-07-22 00:00:00.000000000 Z
11
+ date: 2026-09-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: