Class: LogSnag::Identify

Inherits:
EventBase show all
Defined in:
lib/logsnag/identify.rb

Overview

Constructs and validates an “identify” object

Constant Summary collapse

REQUIRED_KEYS =
%i[project user_id properties].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from EventBase

#to_json

Constructor Details

#initialize(data, config) ⇒ LogSnag::Insight

Creates a new Identify object. The data hash must include the following keys:

- :user_id [String] The user ID of the user to be identified.
- :properties [Hash] The properties of the user to be identified.

Parameters:

  • data (Hash)

    The data to be sent to LogSnag.

  • config (LogSnag::Configuration)

    The configuration object.

Raises:

  • (ArgumentError)

    If the hash is missing required keys, has invalid keys, or has values of incorrect types.

See Also:



22
23
24
25
26
27
28
# File 'lib/logsnag/identify.rb', line 22

def initialize(data, config)
  super(data, config)

  append_required_fields!
  compact_properties!
  validate_data
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



11
12
13
# File 'lib/logsnag/identify.rb', line 11

def config
  @config
end

#dataObject (readonly)

Returns the value of attribute data.



11
12
13
# File 'lib/logsnag/identify.rb', line 11

def data
  @data
end