                 return resp.send 500, error: 'Error trying to find tool'
               else
                 code = if isNew then 201 else 200
+                if isNew
+                  code = 201
+                  action = 'created'
+                else
+                  code = 200
+                  action = 'updated'
+                na.trackEvent 'tools', action, body.name
                 return resp.send code, tool
 
 updateUser = (req, resp) ->


_ = require 'underscore'
express = require 'express'
assets = require 'connect-assets'
ejs = require 'ejs'
passport = require 'passport'

  User.findByShortName req.user.effective.shortName, (err, user) ->
    resp.send 200, user.sshKeys

googleAnalytics = (req, resp, next) ->
  na.trackPage "#{req.method} #{req.url}", req.url, ->
    return true
  next()

app.all '*', ensureAuthenticated

app.get '/logout', logout

# API!
app.get '/api/tools/?', listTools
app.post '/api/tools/?', googleAnalytics, postTool

app.put '/api/user/?', updateUser

