Minor nit / coding style: I would probably `if ( !(email && ip && agent && action) ) {` and then do the error bit with a return, and provide no else here. Mainly so that it's a "guard and get the hell out if something wrong", then leave the rest of the nice regular code one step less indented and an if-else which isn't as long (does that make sense?). Totally up to you. :)