diff --git a/lib/datadog/kit/identity.rb b/lib/datadog/kit/identity.rb index b2bd8115e50..8f9ccdafe20 100644 --- a/lib/datadog/kit/identity.rb +++ b/lib/datadog/kit/identity.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require_relative '../appsec/instrumentation/gateway/argument' + module Datadog module Kit # Tracking identity via traces @@ -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 diff --git a/spec/datadog/kit/identity_spec.rb b/spec/datadog/kit/identity_spec.rb index b270f7c2755..eef36e492c3 100644 --- a/spec/datadog/kit/identity_spec.rb +++ b/spec/datadog/kit/identity_spec.rb @@ -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