Axeman
The Chop-Happy Rails Plugin
Axeman is a plugin to monitor usage of your application. Its primary purpose is to encourage you aggressively cull parts of your application which are unused. It gives you feedback on what users are really using, not just what they say they are using.
It could also be used as a really crappy traffic analyzer, but it is not recommended for use in this way.
Install
script/plugin install http://opensource.bitscribe.net/svn/axeman
Dependencies
You must have the SQLite3 Ruby library installed. On Ubuntu:
sudo apt-get install libsqlite3-ruby1.8
On OS X, if you have DarwinPorts:
sudo port install rb-sqlite3
Application Hooks
To begin tracking all page views on your app, add the following line to your ApplicationController:
include AxemanTracker
To display the tracked data as a report, you need to make a method on one of your controllers. This might be something like /admin/axeman, or you can give it its own controller, like so:
class AxemanController < ApplicationController
before_filter :login_required
def index
render_text AxemanReport.new.index(params)
end
end
Replace the before_filter parameter with your app’s login authorization method name.
With this in place, you can visit (your application’s URL)/axeman to view the report.
But Why?
The lefthand column, Hits, gives some interesting information on how frequently traveled each page in your app is. But the righthand column is really where the action is at, because these are unused pages.
This tool makes the most sense when used over time: a page which is commonly used at one time may fall out of use as other pages provide similar functionality.
For more on the subject, including a screenshot: adam.blogs.bitscribe.net/2007/03/16/getting-chop-happy-with-axeman/
How Does It Work?
The code is scary, with inline HTML and other awfulness, due to the lack of a good components architecture for Rails. Don’t look at it if you want to avoid trauma. It’s short, though, so should you want to modify it for your own needs it shouldn’t be hard to find what you’re looking for.
The hits are recorded in log/axeman.db, should you wish to nuke the database, or tinker with it using the sqlite3 command line sql shell.
Credits
Axeman is written by Adam Wiggins: adam.blogs.bitscribe.net
Patches can be directed to opensource at bitscribe dot net.
