Last updated

Sending usage stats to Campfire

Estimated reading time: 2 minutes

Table of contents

Automate all the things

We use Campfire heavily at pebble {code}. After a brief flirtation with IRC we found it was the easiest way to get everyone in the team involved. We post quite a few things to Campfire:

As everyone is in Campfire is makes lots of sense for us to do this. We don’t waste time having to ask people in the team what they are doing since it is all there.

How are our apps doing?

We have recently created a couple of web applications in Tricklr and Vistazo. Every now and again people ask ‘How many users do we have?’ or 'How many projects are there’. Typically questions like this result in

About the fourth time of doing this it became obvious this is a job for automation!

First pass

A first pass at this resulted in a quick rake task after about 20 minutes from start to deploy. The rake task uses tinder a neat little gem for interacting with Campfire from Ruby.

task "campfire:stats" => :environment do
  campfire = '[YOUR_ACCOUNT_NAME]', :token => '[YOUR_TOKEN]'
  room = campfire.find_room_by_id([YOUR_ROOM_ID])
  # Get the data you want with ActiveRecord
  users = User.count
  room.speak "OHAI! Stats from YOUR APP"
  room.paste "Users: #{users}"

For a quick and dirty solution not bad. This is added to a cron job run on the server at 9.30 each day, just after everyone gets/logs in.

Feature requests

Some things that would be good to have:

Have an update or suggestion for this article? You can edit it here and send me a pull request.


Recent Posts