Skip to content

Commit

Permalink
replace OpenStruct with Datadog::AppSec::Instrumentation::Gateway::User
Browse files Browse the repository at this point in the history
  • Loading branch information
GustavoCaso committed Feb 27, 2023
1 parent 7bf099c commit 9a64baa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/datadog/kit/identity.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../appsec/instrumentation/gateway/argument'

module Datadog
module Kit
# Tracking identity via traces
Expand Down Expand Up @@ -57,7 +59,7 @@ def self.set_user(trace, id:, email: nil, name: nil, session_id: nil, role: nil,
end

if Datadog.configuration.appsec.enabled
user = OpenStruct.new(id: id)
user = ::Datadog::AppSec::Instrumentation::Gateway::User.new(id)
::Datadog::AppSec::Instrumentation.gateway.push('identity.set_user', user)
end
end
Expand Down
3 changes: 1 addition & 2 deletions spec/datadog/kit/identity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,9 @@
context 'when is enabled' do
it 'instruments the user information to appsec' do
Datadog.configuration.appsec.enabled = true
user = OpenStruct.new(id: '42')
expect_any_instance_of(Datadog::AppSec::Instrumentation::Gateway).to receive(:push).with(
'identity.set_user',
user
instance_of(Datadog::AppSec::Instrumentation::Gateway::User)
)
described_class.set_user(trace_op, id: '42')
end
Expand Down

0 comments on commit 9a64baa

Please sign in to comment.