Module: Datadog::AppSec::Contrib::Devise::Tracking
- Defined in:
- lib/datadog/appsec/contrib/devise/tracking.rb
Overview
Internal module to track user events
Constant Summary collapse
- LOGIN_SUCCESS_EVENT =
'users.login.success'
- LOGIN_FAILURE_EVENT =
'users.login.failure'
- SIGNUP_EVENT =
'users.signup'
Class Method Summary collapse
- .track(event, trace, span, **others) ⇒ Object
- .track_login_failure(trace, span, user_id:, user_exists:, **others) ⇒ Object
- .track_login_success(trace, span, user_id:, **others) ⇒ Object
- .track_signup(trace, span, user_id:, **others) ⇒ Object
Class Method Details
.track(event, trace, span, **others) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/datadog/appsec/contrib/devise/tracking.rb', line 39 def self.track(event, trace, span, **others) return if trace.nil? || span.nil? span.set_tag("appsec.events.#{event}.track", 'true') span.set_tag("_dd.appsec.events.#{event}.auto.mode", Datadog.configuration.appsec.track_user_events.mode) others.each do |k, v| raise ArgumentError, 'key cannot be :track' if k.to_sym == :track span.set_tag("appsec.events.#{event}.#{k}", v) unless v.nil? end trace.keep! end |
.track_login_failure(trace, span, user_id:, user_exists:, **others) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/datadog/appsec/contrib/devise/tracking.rb', line 23 def self.track_login_failure(trace, span, user_id:, user_exists:, **others) return if trace.nil? || span.nil? track(LOGIN_FAILURE_EVENT, trace, span, **others) span.set_tag('appsec.events.users.login.failure.usr.id', user_id) if user_id span.set_tag('appsec.events.users.login.failure.usr.exists', user_exists) end |
.track_login_success(trace, span, user_id:, **others) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/datadog/appsec/contrib/devise/tracking.rb', line 15 def self.track_login_success(trace, span, user_id:, **others) return if trace.nil? || span.nil? track(LOGIN_SUCCESS_EVENT, trace, span, **others) Kit::Identity.set_user(trace, span, id: user_id.to_s, **others) if user_id end |
.track_signup(trace, span, user_id:, **others) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/datadog/appsec/contrib/devise/tracking.rb', line 32 def self.track_signup(trace, span, user_id:, **others) return if trace.nil? || span.nil? track(SIGNUP_EVENT, trace, span, **others) Kit::Identity.set_user(trace, id: user_id.to_s, **others) if user_id end |