Skip to content

Instantly share code, notes, and snippets.

@justinko
Created November 16, 2012 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinko/4090050 to your computer and use it in GitHub Desktop.
Save justinko/4090050 to your computer and use it in GitHub Desktop.
class SyncToAnalyticsService
ConnectionFailure = Class.new(StandardError)
def self.perform(data)
new(data).perform
end
def initialize(data)
@data = data.symbolize_keys
@account = Account.find(@data[:account_id])
@analytics_client = Analytics::Client.new(CC.config[:analytics_api_key])
end
def perform
@account.users.each do |user|
@analytics_client.upsert(@account, user)
end
# OR
@account.add_analytics(@analytics_client)
# OR
AnalyticsRecorder.record(@account, @analytics_client)
rescue SocketError => ex
raise ConnectionFailure.new(ex.message)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment