Class: SimpleSegment::Client

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/simple_segment/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

included, #isoify_dates, #isoify_dates!, #maybe_datetime_in_iso8601, #symbolize_keys

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



14
15
16
# File 'lib/simple_segment/client.rb', line 14

def initialize(options = {})
  @config = Configuration.new(options)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



12
13
14
# File 'lib/simple_segment/client.rb', line 12

def config
  @config
end

Instance Method Details

#alias(options) ⇒ Object



78
79
80
# File 'lib/simple_segment/client.rb', line 78

def alias(options)
  Operations::Alias.new(self, symbolize_keys(options)).call
end

#batch {|batch| ... } ⇒ Object

Examples:

client.batch do |analytics|
  analytics.context = { 'foo' => 'bar' }
  analytics.identify(user_id: 'id')
  analytics.track(event: 'Delivered Package', user_id: 'id')
end

Yields:

  • (batch)

    Yields a special batch object that can be used to group ‘identify`, `track`, `page` and `group` calls into a single API request.



91
92
93
94
95
# File 'lib/simple_segment/client.rb', line 91

def batch
  batch = Batch.new(self)
  yield(batch)
  batch.commit
end

#flushObject

A no op, added for backwards compatibility with ‘analytics-ruby`



98
# File 'lib/simple_segment/client.rb', line 98

def flush; end

#group(options) ⇒ Object



65
66
67
# File 'lib/simple_segment/client.rb', line 65

def group(options)
  Operations::Group.new(self, symbolize_keys(options)).call
end

#identify(options) ⇒ Object



26
27
28
# File 'lib/simple_segment/client.rb', line 26

def identify(options)
  Operations::Identify.new(self, symbolize_keys(options)).call
end

#page(options) ⇒ Object



52
53
54
# File 'lib/simple_segment/client.rb', line 52

def page(options)
  Operations::Page.new(self, symbolize_keys(options)).call
end

#track(options) ⇒ Object



39
40
41
# File 'lib/simple_segment/client.rb', line 39

def track(options)
  Operations::Track.new(self, symbolize_keys(options)).call
end