Module: Datadog::Kit::AppSec::Events
- Defined in:
- lib/datadog/kit/appsec/events.rb
Overview
Tracking events
Constant Summary collapse
- LOGIN_SUCCESS_EVENT =
'users.login.success'- LOGIN_FAILURE_EVENT =
'users.login.failure'
Class Method Summary collapse
-
.track(event, trace, **others) ⇒ Object
Attach custom event information to the trace.
-
.track_login_failure(trace, user_id:, user_exists:, **others) ⇒ Object
Attach login failure event information to the trace.
-
.track_login_success(trace, user:, **others) ⇒ Object
Attach login success event information to the trace.
Class Method Details
.track(event, trace, **others) ⇒ Object
Attach custom event information to the trace
This method is experimental and may change in the future.
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/datadog/kit/appsec/events.rb', line 60 def self.track(event, trace, **others) trace.set_tag("appsec.events.#{event}.track", 'true') others.each do |k, v| raise ArgumentError, 'key cannot be :track' if k.to_sym == :track trace.set_tag("appsec.events.#{event}.#{k}", v) unless v.nil? end trace.keep! end |
.track_login_failure(trace, user_id:, user_exists:, **others) ⇒ Object
Attach login failure event information to the trace
This method is experimental and may change in the future.
42 43 44 45 46 47 48 49 |
# File 'lib/datadog/kit/appsec/events.rb', line 42 def self.track_login_failure(trace, user_id:, user_exists:, **others) track(LOGIN_FAILURE_EVENT, trace, **others) raise ArgumentError, 'user_id cannot be nil' if user_id.nil? trace.set_tag('appsec.events.users.login.failure.usr.id', user_id) trace.set_tag('appsec.events.users.login.failure.usr.exists', user_exists) end |
.track_login_success(trace, user:, **others) ⇒ Object
Attach login success event information to the trace
This method is experimental and may change in the future.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/datadog/kit/appsec/events.rb', line 22 def self.track_login_success(trace, user:, **others) track(LOGIN_SUCCESS_EVENT, trace, **others) = user.dup user_id = .delete(:id) raise ArgumentError, 'missing required key: :user => { :id }' if user_id.nil? Kit::Identity.set_user(trace, id: user_id, **) end |