Last active
January 4, 2016 07:29
-
-
Save lexun/8589485 to your computer and use it in GitHub Desktop.
Basic Segment.io example with Resque
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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