<commit_before>faker    = require('faker')

dogapi = require 'dogapi'

options =
  api_key: 'da163c47df4e1bdec0645604a129846c'
  app_key: 'eb916d4dd0b7101b8e5b00a73b405cae5d804b8e'

doglog = new dogapi options

module.exports = client = do ()->

  user = faker.Helpers.createCard()

  getTerminalInput = ->
    x =Math.floor(Math.random()*110000)
    y =Math.floor(Math.random()*110000)
    input  = "echo $((#{x}*#{y}))"
    result = (x*y)
    return [input,result]

  getPost = ->
    lastPost = faker.Lorem.sentence()

  postActivity = (data) ->
    $("[testpath='ActivityInputView'] div[contenteditable='true']").html(data)


  tests =
    beforeEach: (browser, done)->
      browser.globals.time = new Date()
      done()

    afterEach: (done)->
      browser = this.client;

      duration = (new Date()) - browser.globals.time

      metric =
        metric : browser.currentTest.name
        points : [[Date.now(), duration]]
        host   : "load.koding.com"
        type   : "counter"

      gs = new (require("google-spreadsheet"))("1rG-ZRmhiIiM6h6oorG90cGofDhbW67bO_ZUHfO6zW-k")
      gs.setAuth "<EMAIL>", "raj5cos6op6owt3", (err) ->
        gs.addRow 1,
          testName : browser.currentTest.name
          startDate: Date.now()-browser.globals.time
          endDate  : Date.now()

      doglog.add_metrics series:[metric], ()->
        done()


    "Registration": (browser) ->
      koding_username = "ktu-#{user.name.replace(/[^A-Za-z0-9]/g, '')}"

      browser
        # .url                    "http://koding:1q2w3e4r@sandbox.koding.com/"
        # .url                    "http://sandbox.koding.com/"
        .url                    "http://lvh.me:8090"<commit_msg>Tests: send metrics in a proper way<commit_after>faker    = require('faker')

dogapi = require 'dogapi'

options =
  api_key: 'da163c47df4e1bdec0645604a129846c'
  app_key: 'eb916d4dd0b7101b8e5b00a73b405cae5d804b8e'

doglog = new dogapi options

module.exports = client = do ()->

  user = faker.Helpers.createCard()

  getTerminalInput = ->
    x =Math.floor(Math.random()*110000)
    y =Math.floor(Math.random()*110000)
    input  = "echo $((#{x}*#{y}))"
    result = (x*y)
    return [input,result]

  getPost = ->
    lastPost = faker.Lorem.sentence()

  postActivity = (data) ->
    $("[testpath='ActivityInputView'] div[contenteditable='true']").html(data)


  tests =
    beforeEach: (browser, done)->
      browser.globals.time = new Date()
      done()

    afterEach: (done)->
      browser = this.client;

      duration = (new Date()) - browser.globals.time

      replaceAllRegex = new RegExp(" ", 'g')
      metricName = browser.currentTest.name.replace(replaceAllRegex, "_")
      metricName = metricName.toLowerCase()
      metricName = "load_test."+metricName

      metric =
        metric : metricName
        points : [[Date.now()/1000, duration]]
        host   : "load.koding.com"
        type   : "gauge"


      gs = new (require("google-spreadsheet"))("1rG-ZRmhiIiM6h6oorG90cGofDhbW67bO_ZUHfO6zW-k")
      gs.setAuth "<EMAIL>", "<PASSWORD>", (err) ->
        gs.addRow 1,
          testName : browser.currentTest.name
          startDate: Date.now()-browser.globals.time
          endDate  : Date.now()

      doglog.add_metrics series:[metric], ()->
        done()


    "Registration": (browser) ->
      koding_username = "ktu-#{user.name.replace(/[^A-Za-z0-9]/g, '')}"

      browser
        # .url                    "http://koding:1q2w3e4r@sandbox.koding.com/"
        # .url                    "http://sandbox.koding.com/"
        .url                    "http://lvh.me:8090"
{'fraction_non_alphanumeric': 0.15619788771539744, 'fraction_numerical': 0.0433574207893274, 'mean_word_length': 2.444019138755981, 'pattern_counts': {'":': 2, '<': 6, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7039797', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1272, 'n_words': 201}