Module: Terrestrial::Cli::MixpanelClient
- Defined in:
- lib/terrestrial/cli/mixpanel_client.rb
Constant Summary collapse
- TOKEN =
"47d6a27568a3c842ead24b14907eb04e"
- URL =
"https://api.mixpanel.com/track"
Class Method Summary collapse
- .event_json(event) ⇒ Object
- .fetch_and_save_user_id ⇒ Object
- .format_event(event) ⇒ Object
- .track(event) ⇒ Object
- .user_identifier ⇒ Object
Class Method Details
.event_json(event) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/terrestrial/cli/mixpanel_client.rb', line 30 def event_json(event) { event: event, properties: { distinct_id: user_identifier, token: TOKEN, time: Time.now.to_i } }.to_json end |
.fetch_and_save_user_id ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/terrestrial/cli/mixpanel_client.rb', line 41 def fetch_and_save_user_id response = Web.new.get_profile if response.success? id = response.body["data"]["user"]["id"] Config.load({:user_id => id}) Config.update_global_config id else "unknown" end end |
.format_event(event) ⇒ Object
26 27 28 |
# File 'lib/terrestrial/cli/mixpanel_client.rb', line 26 def format_event(event) Base64.strict_encode64(event_json(event)) end |