Skip to content

Commit

Permalink
Skip tagging when tracing is unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
lloeki committed May 14, 2024
1 parent 47a6612 commit 0a9d812
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/datadog/appsec/contrib/devise/tracking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,32 @@ module Tracking
SIGNUP_EVENT = 'users.signup'

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

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

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

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)

Expand Down

0 comments on commit 0a9d812

Please sign in to comment.