Skip to content

Instantly share code, notes, and snippets.

@lexun
Last active January 4, 2016 07:29
Show Gist options
  • Save lexun/8589485 to your computer and use it in GitHub Desktop.
Save lexun/8589485 to your computer and use it in GitHub Desktop.
Basic Segment.io example with Resque
module Segment
module Tracking
@queue = :low
def self.perform(action, data)
data.symbolize_keys!
Analytics.send action, data
end
def identify(user = @user)
Resque.enqueue Segment::Tracking, 'identify',
user_id: user.id.to_s,
traits: { email: user.email }
end
def setup_segment(user_id = @user.id)
Resque.enqueue Segment::Tracking, 'track',
user_id: user_id.to_s,
event: 'Setup Segment'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment