lib/simple_segment/client.rb in simple_segment-0.1.0.pre2 vs lib/simple_segment/client.rb in simple_segment-0.1.0
- old
+ new
@@ -19,11 +19,11 @@
# @option :traits [Hash]
# @option :context [Hash]
# @option :integrations [Hash]
# @option :timestamp [#iso8601] (Time.now)
def identify(options)
- Operations::Identify.new(symbolize_keys(options), config).call
+ Operations::Identify.new(self, symbolize_keys(options)).call
end
# @param [Hash] options
# @option :event [String] required
# @option :user_id
@@ -31,11 +31,11 @@
# @option :properties [Hash]
# @option :context [Hash]
# @option :integrations [Hash]
# @option :timestamp [#iso8601] (Time.now)
def track(options)
- Operations::Track.new(symbolize_keys(options), config).call
+ Operations::Track.new(self, symbolize_keys(options)).call
end
# @param [Hash] options
# @option :user_id
# @option :anonymous_id
@@ -43,11 +43,11 @@
# @option :properties [Hash]
# @option :context [Hash]
# @option :integrations [Hash]
# @option :timestamp [#iso8601] (Time.now)
def page(options)
- Operations::Page.new(symbolize_keys(options), config).call
+ Operations::Page.new(self, symbolize_keys(options)).call
end
# @param [Hash] options
# @option :user_id
# @option :anonymous_id
@@ -55,11 +55,11 @@
# @option :traits [Hash]
# @option :context [Hash]
# @option :integrations [Hash]
# @option :timestamp [#iso8601] (Time.now)
def group(options)
- Operations::Group.new(symbolize_keys(options), config).call
+ Operations::Group.new(self, symbolize_keys(options)).call
end
# @param [Hash] options
# @option :user_id
# @option :anonymous_id
@@ -67,14 +67,23 @@
# @option :traits [Hash]
# @option :context [Hash]
# @option :integrations [Hash]
# @option :timestamp [#iso8601] (Time.now)
def alias(options)
- Operations::Alias.new(symbolize_keys(options), config).call
+ Operations::Alias.new(self, symbolize_keys(options)).call
end
+ # @yield [batch] Yields a special batch object that can be used to group
+ # `identify`, `track`, `page` and `group` calls into a
+ # single API request.
+ # @example
+ # client.batch do |analytics|
+ # analytics.context = { 'foo' => 'bar' }
+ # analytics.identify(user_id: 'id')
+ # analytics.track(event: 'Delivered Package', user_id: 'id')
+ # end
def batch
- batch = Batch.new(config)
+ batch = Batch.new(self)
yield(batch)
batch.commit
end
# A no op, added for backwards compatibility with `analytics-ruby`