Skip to content

Instantly share code, notes, and snippets.

@mberman84
mberman84 / gist:7158727
Created October 25, 2013 17:40
Load Mixpanel
def load_mixpanel
@mixpanel ||= Mixpanel::Tracker.new "#{mixpanel_key}", { :env => request.env }
if current_user
@mixpanel.append_people_identify mixpanel_distinct_id
mixpanel_set(mixpanel_distinct_id, current_user.mixpanel_properties)
@mixpanel.append("name_tag", current_user.email)
end
end
module MixpanelHelper
def mixpanel_track_with_super_properties(event_name, properties = {})
properties = properties.merge(get_super_properties) unless get_super_properties.nil?
properties = properties.merge(:distinct_id => mixpanel_distinct_id)
@mixpanel.track(event_name, properties)
end
def mixpanel_set(distinct_id, properties = {})
@mixpanel.set(distinct_id, properties)
module MixpanelHelper
def mixpanel_track_with_super_properties(event_name, properties = {})
properties = properties.merge(get_super_properties) unless get_super_properties.nil?
properties = properties.merge(:distinct_id => mixpanel_distinct_id)
@mixpanel.track(event_name, properties)
end
def mixpanel_set(distinct_id, properties = {})
:javascript
var readyFunc = function() {
if(typeof(pubnub) == "undefined"){
var pubnub = PUBNUB.init({
subscribe_key : "#{CONFIG['pubnub_subscribe_key']}"
})
}
:javascript
var readyFunc;
readyFunc = function() {
if(typeof(pubnub) == "undefined"){
var pubnub = PUBNUB.init({
subscribe_key : "#{CONFIG['pubnub_subscribe_key']}"
})
}
module MixpanelHelper
def mixpanel_track_with_super_properties(event_name, properties = {})
properties = properties.merge(get_super_properties) unless get_super_properties.nil?
properties = properties.merge(:distinct_id => mixpanel_distinct_id)
@mixpanel.track(event_name, properties)
end
def mixpanel_set(distinct_id, properties = {})
@mixpanel.set(distinct_id, properties)
#customer-info{'data-message-channel' => "#{current_user.company.channel if user_signed_in?}", 'data-customer-id' => "#{@customer.id if @customer}", 'data-customer-first-name' => "#{@customer.first_name if @customer}"}
#key-info{'data-subscribe-key' => "#{ENV['PUBNUB_SUBSCRIBE_KEY'] || CONFIG['pubnub_subscribe_key']}"}
:javascript
if(pubnub == undefined){
var pubnub = PUBNUB.init({
subscribe_key : $('#key-info').data('subscribe-key')
})
}
module MixpanelHelper
def mixpanel_key
Rails.env.production? ? 'xxx' : 'yyy'
end
def mixpanel_track_with_super_properties(event_name, properties = {})
properties = properties.merge(get_super_properties) unless get_super_properties.nil?
properties = properties.merge(:distinct_id => mixpanel_distinct_id)
@mixpanel.track(event_name, properties)
Sep 01 17:18:01 texthub app/web.1: Parameters: {"text"=>"Hey Joshua, welcome to StudySoup! Upload a note sample to StudySoup.com for verification and I’ll get back to you in a few days! - Sieva", "to"=>"(805)794-3264", "token"=>"6csuucmW1-iF8CJpPne1iQbexZaJjfoo"}
Sep 01 17:18:01 texthub app/web.1: Parameters: {"text"=>"Hey Joshua, welcome to StudySoup! Upload a note sample to StudySoup.com for verification and I’ll get back to you in a few days! - Sieva", "to"=>"(805)794-3264", "token"=>"6csuucmW1-iF8CJpPne1iQbexZaJjfoo"}
Sep 01 17:18:01 texthub app/web.1: Parameters: {"text"=>"Joshua, don’t forget to tell your classmates that your notes are posted for sale on StudySoup.com. Share your link = $$$!", "to"=>"(805)794-3264", "token"=>"6csuucmW1-iF8CJpPne1iQbexZaJjfoo"}
Sep 01 17:18:01 texthub app/web.1: Parameters: {"text"=>"Joshua, don’t forget to tell your classmates that your notes are posted for sale on StudySoup.com. Share your link = $$$!", "to"=>"(805)794-3264", "token"=>"6csuucmW1-iF8CJpPn
# PostgreSQL. Versions 8.2 and up are supported.
#
# Install the pg driver:
# gem install pg
# On OS X with Homebrew:
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
# On OS X with MacPorts:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg