visionary-sdk 0.9.0 → 0.10.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: bccaa8c65dbda6b555e653d7d96b61630d1dd8e307673594a78f41574c41292a
4
- data.tar.gz: a0c55edf0aa86b7dada1aadf472c7303dd192ce76274e5230b6ede649e9740b5
3
+ metadata.gz: d7630e61ac28975c342c573744fcf10efc46da8ba67458ff32ba0a647754254c
4
+ data.tar.gz: 0de62f0a84b32998b74933fabbd1ec69bb70ca358e0e43c974c86dad73e7cac8
5
5
  SHA512:
6
- metadata.gz: 29eb17da02207863eda8558cbd0be9cd4ac050fed2b166284c3057d5d4e922fca60f0f137c8b13f4d258c75642ccdbe509ad75c610969f05b0b01986c2a09599
7
- data.tar.gz: 55649c90bcf0a35a02cac846f7e20ff5d484e4d2b1001544debfa3e39bc01776477bdebda5db7e3c6e719757b8c67f1c7f7a758b5a48be3f7871f0dff08ccc9e
6
+ metadata.gz: 9463fc0d7556b2282704f0ea61a7459443672bf80fd176e2753c3e2116f661d823d5b5a28d8da786f3071d9ce4085e27cc59453133a6784de819079b3c9af982
7
+ data.tar.gz: c714e4b18951537ef203db2d7cf25d56f295508bba15a0ef60b58b2969d3d341e7868e0f059987f3e0d206f39b3f80e92351c5a8d335ebb76937db662a945bf0
data/LICENSE CHANGED
@@ -1,202 +1,208 @@
1
+ Visionary Non-Commercial License (VNCL) v1.0
1
2
 
2
- Apache License
3
- Version 2.0, January 2004
4
- http://www.apache.org/licenses/
5
-
6
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
-
8
- 1. Definitions.
9
-
10
- "License" shall mean the terms and conditions for use, reproduction,
11
- and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by
14
- the copyright owner that is granting the License.
15
-
16
- "Legal Entity" shall mean the union of the acting entity and all
17
- other entities that control, are controlled by, or are under common
18
- control with that entity. For the purposes of this definition,
19
- "control" means (i) the power, direct or indirect, to cause the
20
- direction or management of such entity, whether by contract or
21
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
- outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
- "You" (or "Your") shall mean an individual or Legal Entity
25
- exercising permissions granted by this License.
26
-
27
- "Source" form shall mean the preferred form for making modifications,
28
- including but not limited to software source code, documentation
29
- source, and configuration files.
30
-
31
- "Object" form shall mean any form resulting from mechanical
32
- transformation or translation of a Source form, including but
33
- not limited to compiled object code, generated documentation,
34
- and conversions to other media types.
35
-
36
- "Work" shall mean the work of authorship, whether in Source or
37
- Object form, made available under the License, as indicated by a
38
- copyright notice that is included in or attached to the work
39
- (an example is provided in the Appendix below).
40
-
41
- "Derivative Works" shall mean any work, whether in Source or Object
42
- form, that is based on (or derived from) the Work and for which the
43
- editorial revisions, annotations, elaborations, or other modifications
44
- represent, as a whole, an original work of authorship. For the purposes
45
- of this License, Derivative Works shall not include works that remain
46
- separable from, or merely link (or bind by name) to the interfaces of,
47
- the Work and Derivative Works thereof.
48
-
49
- "Contribution" shall mean any work of authorship, including
50
- the original version of the Work and any modifications or additions
51
- to that Work or Derivative Works thereof, that is intentionally
52
- submitted to Licensor for inclusion in the Work by the copyright owner
53
- or by an individual or Legal Entity authorized to submit on behalf of
54
- the copyright owner. For the purposes of this definition, "submitted"
55
- means any form of electronic, verbal, or written communication sent
56
- to the Licensor or its representatives, including but not limited to
57
- communication on electronic mailing lists, source code control systems,
58
- and issue tracking systems that are managed by, or on behalf of, the
59
- Licensor for the purpose of discussing and improving the Work, but
60
- excluding communication that is conspicuously marked or otherwise
61
- designated in writing by the copyright owner as "Not a Contribution."
62
-
63
- "Contributor" shall mean Licensor and any individual or Legal Entity
64
- on behalf of whom a Contribution has been received by Licensor and
65
- subsequently incorporated within the Work.
66
-
67
- 2. Grant of Copyright License. Subject to the terms and conditions of
68
- this License, each Contributor hereby grants to You a perpetual,
69
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
- copyright license to reproduce, prepare Derivative Works of,
71
- publicly display, publicly perform, sublicense, and distribute the
72
- Work and such Derivative Works in Source or Object form.
73
-
74
- 3. Grant of Patent License. Subject to the terms and conditions of
75
- this License, each Contributor hereby grants to You a perpetual,
76
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
- (except as stated in this section) patent license to make, have made,
78
- use, offer to sell, sell, import, and otherwise transfer the Work,
79
- where such license applies only to those patent claims licensable
80
- by such Contributor that are necessarily infringed by their
81
- Contribution(s) alone or by combination of their Contribution(s)
82
- with the Work to which such Contribution(s) was submitted. If You
83
- institute patent litigation against any entity (including a
84
- cross-claim or counterclaim in a lawsuit) alleging that the Work
85
- or a Contribution incorporated within the Work constitutes direct
86
- or contributory patent infringement, then any patent licenses
87
- granted to You under this License for that Work shall terminate
88
- as of the date such litigation is filed.
89
-
90
- 4. Redistribution. You may reproduce and distribute copies of the
91
- Work or Derivative Works thereof in any medium, with or without
92
- modifications, and in Source or Object form, provided that You
93
- meet the following conditions:
94
-
95
- (a) You must give any other recipients of the Work or
96
- Derivative Works a copy of this License; and
97
-
98
- (b) You must cause any modified files to carry prominent notices
99
- stating that You changed the files; and
100
-
101
- (c) You must retain, in the Source form of any Derivative Works
102
- that You distribute, all copyright, patent, trademark, and
103
- attribution notices from the Source form of the Work,
104
- excluding those notices that do not pertain to any part of
105
- the Derivative Works; and
106
-
107
- (d) If the Work includes a "NOTICE" text file as part of its
108
- distribution, then any Derivative Works that You distribute must
109
- include a readable copy of the attribution notices contained
110
- within such NOTICE file, excluding those notices that do not
111
- pertain to any part of the Derivative Works, in at least one
112
- of the following places: within a NOTICE text file distributed
113
- as part of the Derivative Works; within the Source form or
114
- documentation, if provided along with the Derivative Works; or,
115
- within a display generated by the Derivative Works, if and
116
- wherever such third-party notices normally appear. The contents
117
- of the NOTICE file are for informational purposes only and
118
- do not modify the License. You may add Your own attribution
119
- notices within Derivative Works that You distribute, alongside
120
- or as an addendum to the NOTICE text from the Work, provided
121
- that such additional attribution notices cannot be construed
122
- as modifying the License.
123
-
124
- You may add Your own copyright statement to Your modifications and
125
- may provide additional or different license terms and conditions
126
- for use, reproduction, or distribution of Your modifications, or
127
- for any such Derivative Works as a whole, provided Your use,
128
- reproduction, and distribution of the Work otherwise complies with
129
- the conditions stated in this License.
130
-
131
- 5. Submission of Contributions. Unless You explicitly state otherwise,
132
- any Contribution intentionally submitted for inclusion in the Work
133
- by You to the Licensor shall be under the terms and conditions of
134
- this License, without any additional terms or conditions.
135
- Notwithstanding the above, nothing herein shall supersede or modify
136
- the terms of any separate license agreement you may have executed
137
- with Licensor regarding such Contributions.
138
-
139
- 6. Trademarks. This License does not grant permission to use the trade
140
- names, trademarks, service marks, or product names of the Licensor,
141
- except as required for reasonable and customary use in describing the
142
- origin of the Work and reproducing the content of the NOTICE file.
143
-
144
- 7. Disclaimer of Warranty. Unless required by applicable law or
145
- agreed to in writing, Licensor provides the Work (and each
146
- Contributor provides its Contributions) on an "AS IS" BASIS,
147
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
- implied, including, without limitation, any warranties or conditions
149
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
- PARTICULAR PURPOSE. You are solely responsible for determining the
151
- appropriateness of using or redistributing the Work and assume any
152
- risks associated with Your exercise of permissions under this License.
153
-
154
- 8. Limitation of Liability. In no event and under no legal theory,
155
- whether in tort (including negligence), contract, or otherwise,
156
- unless required by applicable law (such as deliberate and grossly
157
- negligent acts) or agreed to in writing, shall any Contributor be
158
- liable to You for damages, including any direct, indirect, special,
159
- incidental, or consequential damages of any character arising as a
160
- result of this License or out of the use or inability to use the
161
- Work (including but not limited to damages for loss of goodwill,
162
- work stoppage, computer failure or malfunction, or any and all
163
- other commercial damages or losses), even if such Contributor
164
- has been advised of the possibility of such damages.
165
-
166
- 9. Accepting Warranty or Additional Liability. While redistributing
167
- the Work or Derivative Works thereof, You may choose to offer,
168
- and charge a fee for, acceptance of support, warranty, indemnity,
169
- or other liability obligations and/or rights consistent with this
170
- License. However, in accepting such obligations, You may act only
171
- on Your own behalf and on Your sole responsibility, not on behalf
172
- of any other Contributor, and only if You agree to indemnify,
173
- defend, and hold each Contributor harmless for any liability
174
- incurred by, or claims asserted against, such Contributor by reason
175
- of your accepting any such warranty or additional liability.
176
-
177
- END OF TERMS AND CONDITIONS
178
-
179
- APPENDIX: How to apply the Apache License to your work.
180
-
181
- To apply the Apache License to your work, attach the following
182
- boilerplate notice, with the fields enclosed by brackets "[]"
183
- replaced with your own identifying information. (Don't include
184
- the brackets!) The text should be enclosed in the appropriate
185
- comment syntax for the file format. We also recommend that a
186
- file or class name and description of purpose be included on the
187
- same "printed page" as the copyright notice for easier
188
- identification within third-party archives.
189
-
190
- Copyright [yyyy] [name of copyright owner]
191
-
192
- Licensed under the Apache License, Version 2.0 (the "License");
193
- you may not use this file except in compliance with the License.
194
- You may obtain a copy of the License at
195
-
196
- http://www.apache.org/licenses/LICENSE-2.0
197
-
198
- Unless required by applicable law or agreed to in writing, software
199
- distributed under the License is distributed on an "AS IS" BASIS,
200
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
- See the License for the specific language governing permissions and
202
- limitations under the License.
3
+ Copyright (c) 2026 Saurav Sajeev. All rights reserved, except as expressly
4
+ permitted below.
5
+
6
+
7
+ 1. Definitions
8
+
9
+ "Software" means Visionary, including its source code, object code, server,
10
+ host agent, SDKs, libraries, documentation, and associated materials
11
+ distributed under this License.
12
+
13
+ "Author" means Saurav Sajeev, the original author and copyright holder of the
14
+ Software, to the extent of their ownership of the relevant material.
15
+
16
+ "Commercial Use" means using the Software, in whole or in part, to sell,
17
+ license, sublicense, rent, lease, monetize, commercially distribute, or provide
18
+ a paid product or service. It also includes offering the Software as a hosted
19
+ service to third parties for compensation, or incorporating it into a product
20
+ or service distributed commercially.
21
+
22
+ "Redistribution" means making the Software, or a modified or derivative version
23
+ of it, available to another person or entity by distribution, publication,
24
+ hosting for download, sublicensing, or other transfer.
25
+
26
+ "Internal Use" means use by an individual or an organization solely for its
27
+ own internal operations, without providing the Software or its functionality
28
+ as a product or service to external customers or third parties.
29
+
30
+
31
+ 2. Grant of Permission
32
+
33
+ Subject to the terms of this License, the Author grants you a limited,
34
+ worldwide, non-exclusive, royalty-free, revocable only as permitted by
35
+ applicable law, and non-transferable license to:
36
+
37
+ a. Access, view, and study the Software's source code.
38
+
39
+ b. Download and run the Software for personal, non-commercial purposes.
40
+
41
+ c. Install and deploy the Software in development, testing, staging, and
42
+ production environments for Internal Use.
43
+
44
+ d. Modify the Software for personal use or Internal Use, including within
45
+ commercial organizations, provided such modifications are not
46
+ redistributed or commercially exploited.
47
+
48
+ e. Make reasonable backup copies for permitted use.
49
+
50
+ These permissions do not transfer ownership of the Software or grant any rights
51
+ beyond those expressly stated in this License.
52
+
53
+
54
+ 3. Non-Commercial Restriction
55
+
56
+ You must not, without the Author's prior written permission:
57
+
58
+ a. Sell, license, sublicense, rent, lease, or otherwise commercially exploit
59
+ the Software.
60
+
61
+ b. Offer the Software or a modified version as a paid product, subscription,
62
+ managed service, or hosted monitoring service.
63
+
64
+ c. Incorporate the Software or a substantial portion of it into a product or
65
+ service that is sold, licensed, distributed, or otherwise commercially
66
+ offered to third parties.
67
+
68
+ d. Use the Software to provide monitoring, observability, analytics, or other
69
+ functionality to external customers as a commercial service.
70
+
71
+ e. Monetize access to the Software or charge third parties for access to its
72
+ functionality.
73
+
74
+ Internal production use by a commercial organization is permitted under
75
+ Section 2, provided that the organization does not commercially exploit or
76
+ redistribute the Software in a manner prohibited by this License.
77
+
78
+
79
+ 4. Redistribution and Publication
80
+
81
+ Without the Author's prior written permission, you must not:
82
+
83
+ a. Redistribute or republish the original Software, in source or binary
84
+ form.
85
+
86
+ b. Publish, distribute, or make publicly available a modified version, fork,
87
+ or derivative work of the Software.
88
+
89
+ c. Upload the Software or modified versions to public package registries,
90
+ software marketplaces, application stores, repositories, or download
91
+ platforms for redistribution.
92
+
93
+ d. Sublicense, transfer, or grant others rights to use the Software beyond
94
+ the permissions expressly provided in this License.
95
+
96
+ e. Remove or misrepresent the Software's authorship, copyright notices, or
97
+ license information.
98
+
99
+ Private modifications and internal deployments permitted by Section 2 are not
100
+ prohibited merely because they exist within a commercial organization's
101
+ infrastructure.
102
+
103
+
104
+ 5. Commercial Licensing
105
+
106
+ The Author may separately grant commercial licenses, redistribution rights, or
107
+ other permissions under different terms.
108
+
109
+ Anyone wishing to sell, redistribute, sublicense, incorporate, or commercially
110
+ exploit the Software beyond the permissions granted here must obtain prior
111
+ written authorization from the Author.
112
+
113
+ A separate commercial agreement may specify fees, attribution requirements,
114
+ support terms, distribution rights, and other conditions.
115
+
116
+
117
+ 6. Ownership and Intellectual Property
118
+
119
+ The Software remains the property of its respective copyright holders.
120
+
121
+ This License does not transfer ownership of the Software, its name, branding,
122
+ trademarks, or logos. No trademark license is granted except as necessary to
123
+ identify the unmodified Software truthfully.
124
+
125
+ You retain ownership of your independently created contributions to the extent
126
+ provided by applicable law, but this does not grant you permission to
127
+ distribute or commercially exploit the Software or derivative works in
128
+ violation of this License.
129
+
130
+
131
+ 7. Third-Party Components
132
+
133
+ This License applies only to material the Author has the legal right to
134
+ license under these terms.
135
+
136
+ Third-party components, dependencies, and contributions remain subject to their
137
+ respective licenses. Where another license grants rights that cannot legally
138
+ be restricted by this License, those rights remain unaffected.
139
+
140
+ You are responsible for complying with applicable third-party license
141
+ obligations when using or distributing such components.
142
+
143
+
144
+ 8. Termination
145
+
146
+ Your permissions under this License terminate automatically if you materially
147
+ violate its terms.
148
+
149
+ Upon termination, you must cease activities that are no longer authorized by
150
+ this License, including prohibited redistribution or commercial exploitation,
151
+ subject to any rights or remedies provided by applicable law.
152
+
153
+ Permissions may be reinstated by the Author in writing.
154
+
155
+ Termination does not eliminate rights that applicable law makes irrevocable,
156
+ nor does it automatically revoke separate licenses granted by third-party
157
+ copyright holders.
158
+
159
+
160
+ 9. Disclaimer of Warranty
161
+
162
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
163
+ IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS
164
+ FOR A PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT.
165
+
166
+ YOU ASSUME ALL RISKS ARISING FROM THE USE OF THE SOFTWARE, TO THE MAXIMUM
167
+ EXTENT PERMITTED BY APPLICABLE LAW.
168
+
169
+
170
+ 10. Limitation of Liability
171
+
172
+ TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE AUTHOR SHALL NOT BE
173
+ LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT,
174
+ OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR ITS
175
+ USE, DISTRIBUTION, OR OTHER DEALINGS.
176
+
177
+ Nothing in this License excludes liability that cannot lawfully be excluded
178
+ under applicable law.
179
+
180
+
181
+ 11. No Additional Rights
182
+
183
+ No rights are granted by implication, estoppel, or otherwise beyond those
184
+ expressly stated in this License.
185
+
186
+ Any use, distribution, or commercialization not expressly permitted requires
187
+ the Author's prior written permission, unless applicable law provides
188
+ otherwise.
189
+
190
+
191
+ 12. Governing Law
192
+
193
+ The governing law and jurisdiction applicable to this License shall be
194
+ determined by a separate written agreement between the relevant parties or, in
195
+ the absence of such an agreement, by applicable law and conflict-of-law rules.
196
+
197
+
198
+ 13. Entire Agreement
199
+
200
+ This License governs the permissions granted by the Author for the Software
201
+ covered by it. If any provision is held unenforceable, the remaining provisions
202
+ shall continue to apply to the extent permitted by law.
203
+
204
+
205
+ License: Visionary Non-Commercial License (VNCL) v1.0
206
+ Copyright holder: Saurav Sajeev
207
+ Project: Visionary
208
+ Commercial licensing: Requires separate written authorization.
data/README.md CHANGED
@@ -158,6 +158,27 @@ handle or role.
158
158
  **Records:** `user_id`, `user_handle`, `user_role` on the request row and on
159
159
  its errors.
160
160
 
161
+ ### Record login attempts
162
+
163
+ **When:** you want the security detectors to spot one IP trying many
164
+ accounts, many IPs trying one account, or a signed-in user trying someone
165
+ else's.
166
+
167
+ ```ruby
168
+ # Rails: app/controllers/sessions_controller.rb
169
+ def create
170
+ Visionary.login_attempt(params[:email])
171
+ user = User.authenticate_by(email: params[:email], password: params[:password])
172
+ user ? sign_in(user) : head(:unauthorized)
173
+ end
174
+ ```
175
+
176
+ Call it in the login handler with the username or email typed, whether or
177
+ not it exists or the password was right. The value is trimmed and clipped to
178
+ 255 characters. No-op outside a request seen by the middleware.
179
+
180
+ **Records:** `login_account` on the request row.
181
+
161
182
  ### Database queries (ActiveRecord)
162
183
 
163
184
  **When:** the app uses ActiveRecord (Rails or standalone). Nothing to add.
@@ -573,6 +594,7 @@ samples of runnable threads:
573
594
  ```ruby
574
595
  Visionary.set_user(id, handle: nil, role: nil) # the signed-in user of the current request
575
596
  Visionary.set_route("/users/:id") # route pattern, for routers Visionary can't see
597
+ Visionary.login_attempt(params[:email]) # the account a sign-in request tried
576
598
  Visionary.span(name, kind: "custom", target: nil, detail: nil) { ... } # a manual span
577
599
  Visionary.background(name) { ... } # a thread that stays with the request
578
600
  Visionary.capture_exception(e) # a handled error (handled = 1)
@@ -23,6 +23,7 @@ module Visionary
23
23
  @db_visible = db_visible
24
24
  @mutex = Mutex.new
25
25
  @user = ["", "", ""]
26
+ @login_account = ""
26
27
  @route = ""
27
28
  @spans = []
28
29
  @errors = []
@@ -40,6 +41,15 @@ module Visionary
40
41
  @mutex.synchronize { @user }
41
42
  end
42
43
 
44
+ # The account a sign-in on this request tried (Visionary.login_attempt).
45
+ def login_account=(account)
46
+ @mutex.synchronize { @login_account = account.to_s }
47
+ end
48
+
49
+ def login_account
50
+ @mutex.synchronize { @login_account }
51
+ end
52
+
43
53
  def route=(pattern)
44
54
  @mutex.synchronize { @route = pattern.to_s }
45
55
  end
@@ -152,7 +152,7 @@ module Visionary
152
152
  request_id: ctx.request_id, started_at: ctx.started_at, method: ctx.method, path: ctx.path,
153
153
  route: route, query: env["QUERY_STRING"].to_s, status: status, duration_ms: duration,
154
154
  ip: client_ip(env), user_agent: env["HTTP_USER_AGENT"].to_s,
155
- user_id: user_id, user_handle: handle, user_role: role, headers: headers,
155
+ user_id: user_id, user_handle: handle, user_role: role, login_account: ctx.login_account, headers: headers,
156
156
  request_content_type: env["CONTENT_TYPE"].to_s, request_body: req_capture.bytes,
157
157
  request_truncated: req_capture.truncated?,
158
158
  request_size: [env["CONTENT_LENGTH"].to_i, req_capture.size].max,
@@ -29,7 +29,8 @@ CREATE TABLE IF NOT EXISTS api_logs (
29
29
  db_count BIGINT,
30
30
  db_ms DOUBLE,
31
31
  http_count BIGINT,
32
- http_ms DOUBLE
32
+ http_ms DOUBLE,
33
+ login_account VARCHAR(255)
33
34
  ) CHARACTER SET utf8mb4;
34
35
  CREATE INDEX idx_api_logs_created_at ON api_logs (created_at);
35
36
  CREATE INDEX idx_api_logs_user_created ON api_logs (user_id, created_at);
@@ -29,7 +29,8 @@ CREATE TABLE IF NOT EXISTS api_logs (
29
29
  db_count BIGINT,
30
30
  db_ms DOUBLE PRECISION,
31
31
  http_count BIGINT,
32
- http_ms DOUBLE PRECISION
32
+ http_ms DOUBLE PRECISION,
33
+ login_account TEXT
33
34
  );
34
35
  CREATE INDEX IF NOT EXISTS idx_api_logs_created_at ON api_logs (created_at);
35
36
  CREATE INDEX IF NOT EXISTS idx_api_logs_user_created ON api_logs (user_id, created_at);
@@ -29,7 +29,8 @@ CREATE TABLE IF NOT EXISTS api_logs (
29
29
  db_count INTEGER,
30
30
  db_ms REAL,
31
31
  http_count INTEGER,
32
- http_ms REAL
32
+ http_ms REAL,
33
+ login_account TEXT
33
34
  );
34
35
  CREATE INDEX IF NOT EXISTS idx_api_logs_created_at ON api_logs (created_at);
35
36
  CREATE INDEX IF NOT EXISTS idx_api_logs_user_created ON api_logs (user_id, created_at);
@@ -16,7 +16,8 @@ module Visionary
16
16
 
17
17
  # api_logs columns added after the first release, in insert order.
18
18
  ADDED_REQUEST_COLUMNS = [
19
- %w[service text], %w[version text], %w[db_count int], %w[db_ms real], %w[http_count int], %w[http_ms real]
19
+ %w[service text], %w[version text], %w[db_count int], %w[db_ms real], %w[http_count int], %w[http_ms real],
20
+ %w[login_account text]
20
21
  ].freeze
21
22
 
22
23
  SYSTEM_BASE_COLUMNS = %w[
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Visionary
4
- VERSION = "0.9.0"
4
+ VERSION = "0.10.0"
5
5
  end
@@ -5,7 +5,7 @@ module Visionary
5
5
  # user lookup happen on the writer thread, off the request path.
6
6
  Entry = Struct.new(
7
7
  :request_id, :started_at, :method, :path, :route, :query, :status, :duration_ms, :ip, :user_agent,
8
- :user_id, :user_handle, :user_role, :headers, :request_content_type, :request_body, :request_truncated,
8
+ :user_id, :user_handle, :user_role, :login_account, :headers, :request_content_type, :request_body, :request_truncated,
9
9
  :request_size, :response_content_type, :response_body, :response_truncated, :response_size,
10
10
  :totals, :span_rows, :error_rows,
11
11
  keyword_init: true
@@ -180,10 +180,16 @@ module Visionary
180
180
  e.status, e.duration_ms, nz(e.ip), nz(e.user_agent), nz(e.user_id), nz(handle), nz(role),
181
181
  nz(@redactor.headers(e.headers)), nz(e.request_content_type), nz(req_body), e.request_truncated ? 1 : 0,
182
182
  e.request_size, nz(e.response_content_type), nz(resp_body), e.response_truncated ? 1 : 0, e.response_size,
183
- nz(code), nz(key), @cfg.service, @cfg.version, db_count, db_ms, http_count, http_ms
183
+ nz(code), nz(key), @cfg.service, @cfg.version, db_count, db_ms, http_count, http_ms,
184
+ nz(clip_login(e.login_account))
184
185
  ]
185
186
  end
186
187
 
188
+ # Trims a login identifier to what the column holds.
189
+ def clip_login(s)
190
+ Visionary.utf8(s).strip[0, 255]
191
+ end
192
+
187
193
  def nz(s)
188
194
  s.nil? || s.empty? ? nil : s
189
195
  end
data/lib/visionary.rb CHANGED
@@ -88,6 +88,17 @@ module Visionary
88
88
  nil
89
89
  end
90
90
 
91
+ # Records the account a sign-in request tried: the username or email
92
+ # typed, whether or not it exists or the password was right. Call it in
93
+ # the login handler; the security detectors use it to tell one IP trying
94
+ # many accounts, many IPs trying one account, and a signed-in user trying
95
+ # someone else's. No-op outside a request seen by Visionary::Middleware.
96
+ def login_attempt(account)
97
+ ctx = RequestContext.current
98
+ ctx.login_account = account if ctx
99
+ nil
100
+ end
101
+
91
102
  # Records the route pattern (e.g. "/users/:id") for routers Visionary
92
103
  # can't see. No-op outside a request.
93
104
  def set_route(pattern)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visionary-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - styropyr0
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-25 00:00:00.000000000 Z
11
+ date: 2026-10-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  The Ruby collector for Visionary. A Rack middleware (with a Railtie for Rails)
@@ -61,7 +61,7 @@ files:
61
61
  - lib/visionary/writer.rb
62
62
  homepage: https://github.com/styropyr0/Visionary
63
63
  licenses:
64
- - Apache-2.0
64
+ - LicenseRef-VNCL-1.0
65
65
  metadata:
66
66
  homepage_uri: https://github.com/styropyr0/Visionary
67
67
  source_code_uri: https://github.com/styropyr0/Visionary/tree/main/sdks/ruby