Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
76 lines (50 sloc) 2.53 KB


Ruby gem providing a client for the Pwnalytics REST API.


First, create a PwnalyticsClient pointing to your Pwnalytics instance:

client = :host => 'localhost', :port => 3000,
                              :user => 'config', :password => 'vars'

Or, if you're using SSL:

client = :host => 'localhost', :port => 3000,
                              :user => 'config', :password => 'vars',
                              :ssl => true,
                              :net_http => { :ca_path => '/etc/ssl/certs' }

Get the site that you want data for:

site ='AA123456')

Or, if you don't know the site's UID, you can list all of them.

sites = client.sites

Finally, get the logged events for that site:

# Get everything.
events =

# Restrict query to events with certain names.
events = :names => ['page', 'unload']

# Avoid a data flood.
events = :limit => 200

Events have the same data as in the JSON output.        # "page"
event.visitor     # "12f49459540.11faa9b963f5c4f0"
event.ip          # ""
event.browser_ua  # "Mozilla/5.0 ..."
event.url         # <URI::HTTP:0x7f6750505078 URL:http://localhost>
event.ref         # <URI::HTTP:0x7f6750505078 URL:>  # "your_value"
event.pixels.document.width  # 1680

The RSpec tests cover the entire API.


Clone the Pwnalytics repository and run the Rails server locally.

git clone git://
cd pwnalytics
rake db:create db:migrate db:seed
rails s

The specs assume a local server for integration testing.

Contributing to pwnalytics_client

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet

  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.


Copyright © 2011 Victor Costan. See LICENSE.txt for further details.

Something went wrong with that request. Please try again.