Created
January 31, 2020 18:37
-
-
Save timgl/599cee52740b56af461abe12701e8855 to your computer and use it in GitHub Desktop.
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
# In your time-sensitive process | |
tracker = Mixpanel::Tracker.new(YOUR_POSTHOG_TOKEN) do |type, message| | |
@queue.set('mixpanel_queue', [ type, message ].to_json) | |
end | |
# Track just like you would in any other situation | |
tracker.track(user_id, 'Sent Message') | |
tracker.people.increment(user_id, { | |
'Messages Sent' => 1 | |
}) | |
# In a worker process on another machine | |
mixpanel = Mixpanel::Consumer.new(events_endpoint='https://t.posthog.com/track', update_endpoint='https://t.posthog.com/engage', groups_endpoint='https://t.posthog.com/groups', import_endpoint='https://t.posthog.com/import') | |
loop do | |
job = @queue.get('mixpanel_queue') | |
mixpanel.send!(*JSON.load(job)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment