sinaliza 0.2.1 → 0.3.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: 6c2618a6a40d81712da0524d8a74a96abc8632b4c6012644e7c903fa96f23e5e
4
- data.tar.gz: 798a819da36cb69f47e8555f27b8f16663b27518e2aaec4f7549670967cc165e
3
+ metadata.gz: d645f68aef485dbc199b994b47c4f3434e89cb9101615d4b2806d0203033a340
4
+ data.tar.gz: 428eed5415abc8bf3f7866e6e4903162e417c0b6eceee8e7a4e233bc7374fdaa
5
5
  SHA512:
6
- metadata.gz: 5489aed570c83a2522cd8a057c5e343f42c0eb18e42acd455ec245792f842af647ba42572e05a4418bd9fdcab658c712e856b1ffa829a47066ada5ce080951f1
7
- data.tar.gz: de339af08744a9525e67c68d6e8311e360b4a85719345bdbd5c8fe3c40a216c17e55149a116d95ef5d8a75bd07e8bdcbffafb36534b6dd60f66cca692b97daa9
6
+ metadata.gz: d03113b99053374a9b758acc715ed5f370aa7a3bef568d782c5abfaf7b109b7255d3f0586c26fd74d436635bb74132d03d3d9fa525897e739bce8a0be0b5acc5
7
+ data.tar.gz: 5ff4559f655c0e3182f0d7ad4170326bae7cae2b8736f70318bd84f8331dacbf8bdda8616743d2c632ebc0c2c734d203e2a89997c5104bbea151b66d22338938
data/README.md CHANGED
@@ -154,6 +154,61 @@ Events are recorded with `source: "controller"`. Request context (IP address, us
154
154
 
155
155
  The actor is resolved by calling the method defined in `Sinaliza.configuration.actor_method` (default: `current_user`).
156
156
 
157
+ ### Interceptors
158
+
159
+ Interceptors let you automatically record events whenever a specific method is called — without modifying the original code. They are stored in the database and can be managed at runtime through the dashboard or programmatically.
160
+
161
+ ```ruby
162
+ # Create an interceptor that tracks every call to User#send_welcome_email
163
+ Sinaliza::Interceptor.create!(
164
+ target_class: "User",
165
+ method_name: "send_welcome_email",
166
+ method_type: "instance",
167
+ event_name: "user.welcome_email_sent"
168
+ )
169
+
170
+ # Track a class method
171
+ Sinaliza::Interceptor.create!(
172
+ target_class: "Report",
173
+ method_name: "generate_monthly",
174
+ method_type: "class",
175
+ event_name: "report.monthly_generated"
176
+ )
177
+ ```
178
+
179
+ Each interceptor can optionally capture:
180
+
181
+ | Option | Description | Default |
182
+ |--------------------------|------------------------------------------|---------|
183
+ | `capture_args` | Log method arguments in metadata | `false` |
184
+ | `capture_return` | Log the return value in metadata | `false` |
185
+ | `capture_execution_time` | Log execution time (ms) in metadata | `false` |
186
+
187
+ ```ruby
188
+ # Interceptor with full instrumentation
189
+ Sinaliza::Interceptor.create!(
190
+ target_class: "PaymentGateway",
191
+ method_name: "charge",
192
+ method_type: "instance",
193
+ event_name: "payment.charged",
194
+ capture_args: true,
195
+ capture_return: true,
196
+ capture_execution_time: true
197
+ )
198
+ ```
199
+
200
+ Interceptors can be toggled on and off without removing them:
201
+
202
+ ```ruby
203
+ interceptor = Sinaliza::Interceptor.find_by(event_name: "user.welcome_email_sent")
204
+ interceptor.deactivate! # stops recording events
205
+ interceptor.activate! # resumes recording events
206
+ ```
207
+
208
+ Events recorded by interceptors have `source: "interceptor"`.
209
+
210
+ The dashboard includes an **Interceptors** section where you can create, edit, toggle, and delete interceptors through a web interface.
211
+
157
212
  ### Query scopes
158
213
 
159
214
  ```ruby