Method: Datadog::Kit::AppSec::Events.track_signup

Defined in:
lib/datadog/kit/appsec/events.rb

.track_signup(trace = nil, span = nil, user:, **others) ⇒ Object

Attach signup event information to the trace

This method is experimental and may change in the future.

Parameters:

  • trace (TraceOperation) (defaults to: nil)

    Trace to attach data to. Defaults to active trace.

  • span (SpanOperation) (defaults to: nil)

    Span to attach data to. Defaults to active span on trace. Note that this should be a service entry span. When AppSec is enabled, the expected span and trace are automatically used as defaults.

  • user (Hash<Symbol, String>)

    User information to pass to Datadog::Kit::Identity.set_user. Must contain at least :id as key.

  • others (Hash<String || Symbol, String>)

    Additional free-form event information to attach to the trace.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/datadog/kit/appsec/events.rb', line 85

def (trace = nil, span = nil, user:, **others)
  set_trace_and_span_context('track_signup', trace, span) do |active_trace, active_span|
    user_options = user.dup
    user_id = user_options.delete(:id)
     = user_options[:login] || others[:'usr.login'] || others['usr.login'] || user_id

    raise ArgumentError, 'missing required key: :user => { :id }' if user_id.nil?

    others = others.reject { |key, _| USER_LOGIN_KEYS.include?(key) }
    others[:'usr.login'] = 
    track(SIGNUP_EVENT, active_trace, active_span, **others)

    user_options[:login] = 
    Kit::Identity.set_user(trace, id: user_id, **user_options)
  end
end