Method: LaunchDarkly::LDClient#identify

Defined in:
lib/ldclient-rb/ldclient.rb

#identify(context) ⇒ void

This method returns an undefined value.

Registers the context. This method simply creates an analytics event containing the context properties, so that LaunchDarkly will know about that context if it does not already.

Calling #variation or #variation_detail also sends the context information to LaunchDarkly (if events are enabled), so you only need to use #identify if you want to identify the context without evaluating a flag.

Note that event delivery is asynchronous, so the event may not actually be sent until later; see #flush.

Parameters:

  • context (Hash, LDContext)

    a hash or object describing the context to register



503
504
505
506
507
508
509
510
511
512
513
514
515
516
# File 'lib/ldclient-rb/ldclient.rb', line 503

def identify(context)
  context = LaunchDarkly::Impl::Context.make_context(context)
  unless context.valid?
    @config.logger.warn("Identify called with invalid context: #{context.error}")
    return
  end

  if context.key == ""
    @config.logger.warn("Identify called with empty key")
    return
  end

  @event_processor.record_identify_event(context)
end