<commit_before>var HTTP_STATUS_CODES = require('http').STATUS_CODES;

var fs = require('fs');
var os = require('os');
var EventEmitter = require('events').EventEmitter;
var util = require('util');
var request = require('request');
var xmlbuilder = require('xmlbuilder');
var stackTrace = require('stack-trace');
var traverse = require('traverse');
var hashish = require('hashish');
var querystring = require('querystring');

module.exports = Airbrake;
util.inherits(Airbrake, EventEmitter);
function Airbrake() {
  this.key = null;

  this.host = 'http://' + os.hostname();
  this.env = process.env.NODE_ENV || 'development';
  this.projectRoot = null;
  this.appVersion = null;
  this.timeout = 30 * 1000;

  this.protocol = 'http';
  this.serviceHost = 'airbrakeapp.com';
}

Airbrake.PACKAGE = (function() {
  var json = fs.readFileSync(__dirname + '/../package.json', 'utf8');
  return JSON.parse(json);
})();

Airbrake.createClient = function(key, env) {
  var instance = new this();
  instance.key = key;<commit_msg>Add check for valid API key.<commit_after>var HTTP_STATUS_CODES = require('http').STATUS_CODES;

var fs = require('fs');
var os = require('os');
var EventEmitter = require('events').EventEmitter;
var util = require('util');
var request = require('request');
var xmlbuilder = require('xmlbuilder');
var stackTrace = require('stack-trace');
var traverse = require('traverse');
var hashish = require('hashish');
var querystring = require('querystring');

module.exports = Airbrake;
util.inherits(Airbrake, EventEmitter);
function Airbrake() {
  this.key = null;

  this.host = 'http://' + os.hostname();
  this.env = process.env.NODE_ENV || 'development';
  this.projectRoot = null;
  this.appVersion = null;
  this.timeout = 30 * 1000;

  this.protocol = 'http';
  this.serviceHost = 'airbrakeapp.com';
}

Airbrake.PACKAGE = (function() {
  var json = fs.readFileSync(__dirname + '/../package.json', 'utf8');
  return JSON.parse(json);
})();

Airbrake.createClient = function(key, env) {
  if (!key || typeof key !== 'string' || key.length !== 32) {
    throw new Error('You must supply a valid Airbreak API key.');
  }

  var instance = new this();
  instance.key = key;
{'fraction_non_alphanumeric': 0.16940639269406393, 'fraction_numerical': 0.0073059360730593605, 'mean_word_length': 4.811671087533156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3342230', 'n_tokens_mistral': 720, 'n_tokens_neox': 704, 'n_words': 173}