Skip to content

Instantly share code, notes, and snippets.

@Rich86man
Created July 6, 2015 17:26
Show Gist options
  • Save Rich86man/60a89ec8d93c5a16a834 to your computer and use it in GitHub Desktop.
Save Rich86man/60a89ec8d93c5a16a834 to your computer and use it in GitHub Desktop.
bulk upload $signups
require 'rubygems'
require 'mixpanel_client'
client = Mixpanel::Client.new( api_key: '',api_secret: '')
require 'base64' # co-located with the Base64 call below for clarity
User.all.each {|u|
data_to_import = {'event' => 'firstLogin2', 'properties' => {'distinct_id' => "#{u.id}", 'time' => "#{u.created_at}", 'token' => 'a9a9239a31dd7b497d0db66f861f8b33'}}
encoded_data = Base64.encode64(data_to_import.to_json)
data = client.request('import', {:data => encoded_data, :api_key => 'd9ecab080f45bd2d66a7f00cdd7d3c4a'})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment