Skip to content

Commit

Permalink
Merge pull request #3645 from DataDog/make-appsec-devise-work-without…
Browse files Browse the repository at this point in the history
…-tracing

Make appsec work without tracing
  • Loading branch information
lloeki committed May 15, 2024
2 parents c989b96 + 0a9d812 commit 7ca3042
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 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
4 changes: 2 additions & 2 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
pkgs ? import <nixpkgs> {},

# use a pinned package state
pinned ? import(fetchTarball("https://github.com/NixOS/nixpkgs/archive/31b322916ae1.tar.gz")) {},
pinned ? import(fetchTarball("https://github.com/NixOS/nixpkgs/archive/25865a40d14b.tar.gz")) {},
}:
let
# specify ruby version to use
ruby = pinned.ruby_3_2;
ruby = pinned.ruby_3_3;

# control llvm/clang version (e.g for packages built from source)
llvm = pinned.llvmPackages_16;
Expand Down

0 comments on commit 7ca3042

Please sign in to comment.