aikido-zen 1.9.0.beta.2 → 1.9.0.beta.3

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: d41298c1b3dc0135c211b4beade2a723603cef96372b5526447e5a0d792d1bb9
4
- data.tar.gz: 247dea5c7895db42823c445ce7e0f32995ba833cecbcf7430ad09f33c897c179
3
+ metadata.gz: ada1cbea91efe8d3351ac604504ce0153797785e1d054fd33838a26afcb5038b
4
+ data.tar.gz: cedb2ec0153e3604ece81999b7d9c87e32d67554c9544f4e43574fe8f0ea92b0
5
5
  SHA512:
6
- metadata.gz: ada3f8112966d020346b164380a2cbff9e1ba7c68cfdde2ab2a440d41e1c241c6ef73c9214597fd004e408b61c00ecc9b78294bfd73bef0effd1ca91dbdee5b4
7
- data.tar.gz: 7f61d126b05f54339ca7633e8058e36d298dcd0a4b0abf93eebe4abb96a5c66edbf0e56cc3e6457ed92f8cf46231d6f00f60dc5b8487bdd014532db48ef52dba
6
+ metadata.gz: 833b0e13c05805b86e9060ad6061bc574811347d821139683b3cd0f6d73710f2db7449643075946773d7e0779dc0b1a99c9af7e1abd457d747f81e481ce90721
7
+ data.tar.gz: ff86f644f5453d99b8acf72cdf76348c5292fa28df03a84fbf174782f5e1498b8a03da7508d4378ab6ac354495f9bef9f91c3698f5081e4f66ad8299341650d8
@@ -1,6 +1,6 @@
1
1
  # Track custom events
2
2
 
3
- Use `Aikido::Zen.track_custom_event` to report events that only your application knows about, such as failed logins. [Playbooks](https://help.aikido.dev/zen-firewall/zen-features/playbooks) can act when an event occurs repeatedly, for example by blocking an IP after three failed logins in five minutes.
3
+ Use `Aikido::Zen.track` to report events that only your application knows about, such as failed logins. [Playbooks](https://help.aikido.dev/zen-firewall/zen-features/playbooks) can act when an event occurs repeatedly, for example by blocking an IP after three failed logins in five minutes.
4
4
 
5
5
  ```ruby
6
6
  # app/controllers/application_controller.rb
@@ -12,7 +12,7 @@ class ApplicationController < ActionController::Base
12
12
  # ...
13
13
 
14
14
  unless current_user
15
- Aikido::Zen.track_custom_event("user.login_failed")
15
+ Aikido::Zen.track("user.login_failed")
16
16
  return
17
17
  end
18
18
 
@@ -21,13 +21,13 @@ class ApplicationController < ActionController::Base
21
21
  name: current_user.name
22
22
  )
23
23
 
24
- Aikido::Zen.track_custom_event("user.login_succeeded")
24
+ Aikido::Zen.track("user.login_succeeded")
25
25
  end
26
26
  end
27
27
  ```
28
28
 
29
- After adding `Aikido::Zen.track_custom_event`, trigger the event at least once. It will then appear on the Playbooks page in the Aikido dashboard. From there, you can create a playbook and choose what should happen when the event occurs. Calling `Aikido::Zen.track_custom_event` by itself does not create a playbook or block anything.
29
+ After adding `Aikido::Zen.track`, trigger the event at least once. It will then appear on the Playbooks page in the Aikido dashboard. From there, you can create a playbook and choose what should happen when the event occurs. Calling `Aikido::Zen.track` by itself does not create a playbook or block anything.
30
30
 
31
- Call `Aikido::Zen.track_custom_event` while handling an HTTP request. Zen associates the event with the request's IP address. Playbook counts are per IP, not across your whole app. If you call [`Aikido::Zen.set_user`](./rails.md#rate-limiting-and-user-blocking) before tracking the event, Zen also includes the current user. `Aikido::Zen.set_user` is optional. Events without a user are still tracked.
31
+ Call `Aikido::Zen.track` while handling an HTTP request. Zen associates the event with the request's IP address. Playbook counts are per IP, not across your whole app. If you call [`Aikido::Zen.set_user`](./rails.md#rate-limiting-and-user-blocking) before tracking the event, Zen also includes the current user. `Aikido::Zen.set_user` is optional. Events without a user are still tracked.
32
32
 
33
33
  Event names can use any format. We recommend lowercase, dot-separated names such as `user.login_failed`.
@@ -160,7 +160,7 @@ module Aikido::Zen
160
160
  end
161
161
  end
162
162
 
163
- # Reports a custom event tracked via Aikido::Zen.track_custom_event, if
163
+ # Reports a custom event tracked via Aikido::Zen.track, if
164
164
  # reporting is enabled.
165
165
  #
166
166
  # @param event [Aikido::Zen::Events::Custom]
@@ -96,7 +96,7 @@ module Aikido::Zen
96
96
  end
97
97
  end
98
98
 
99
- # Event sent by Aikido::Zen.track_custom_event to record a custom,
99
+ # Event sent by Aikido::Zen.track to record a custom,
100
100
  # user-named event happening during an HTTP request.
101
101
  class Custom < Event
102
102
  # @param name [String] the name of the tracked event.
@@ -112,11 +112,14 @@ module Aikido::Zen
112
112
  end
113
113
 
114
114
  def as_json
115
+ request_json = @request.as_json
116
+ request_json.delete("url")
117
+
115
118
  super.update(
116
119
  {
117
- name: @name,
118
- request: @request.as_json,
119
- user: @user && {id: @user.id, name: @user.name}.compact
120
+ "name" => @name,
121
+ "request" => request_json,
122
+ "user" => @user && {"id" => @user.id, "name" => @user.name}.compact
120
123
  }.compact
121
124
  )
122
125
  end
@@ -2,9 +2,9 @@
2
2
 
3
3
  module Aikido
4
4
  module Zen
5
- VERSION = "1.9.0.beta.2"
5
+ VERSION = "1.9.0.beta.3"
6
6
 
7
7
  # The version of libzen_internals that we build against.
8
- LIBZEN_VERSION = "0.1.61"
8
+ LIBZEN_VERSION = "0.1.74"
9
9
  end
10
10
  end
data/lib/aikido/zen.rb CHANGED
@@ -282,14 +282,14 @@ module Aikido
282
282
  # a password reset request. Zen automatically attaches the IP address, user
283
283
  # agent, and current user (if you called .track_user) from the request.
284
284
  #
285
- # Only works inside an HTTP request; if called from a background job or
286
- # script, nothing gets sent.
285
+ # Only works inside an HTTP request; the custom event is not reported if
286
+ # called from a background job or script, or if the request is bypassed.
287
287
  #
288
288
  # @param name [String]
289
289
  # @return [void]
290
- def self.track_custom_event(name)
290
+ def self.track(name)
291
291
  unless name.is_a?(String) && !name.empty?
292
- config.logger.warn("track_custom_event expects a non-empty String as the event name")
292
+ config.logger.warn("track expects a non-empty String as the event name")
293
293
  return
294
294
  end
295
295
 
@@ -298,6 +298,8 @@ module Aikido
298
298
  context = current_context
299
299
  return unless context
300
300
 
301
+ return if request_bypassed?
302
+
301
303
  event = Events::Custom.new(
302
304
  name: name,
303
305
  request: context.request,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aikido-zen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0.beta.2
4
+ version: 1.9.0.beta.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aikido Security
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-09-24 00:00:00.000000000 Z
11
+ date: 2026-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby