<commit_before>$ = require 'jquery'

module.exports =
  eventLog: {}
  commandLoggerView: null
  originalTrigger: null

  activate: (state) ->
    @eventLog = state.eventLog ? {}
    rootView.command 'command-logger:clear-data', => @eventLog = {}
    rootView.command 'command-logger:toggle', => @createView().toggle(@eventLog)

    registerTriggeredEvent = (eventName) =>
      eventNameLog = @eventLog[eventName]
      unless eventNameLog
        eventNameLog =
          count: 0
          name: eventName
        @eventLog[eventName] = eventNameLog
      eventNameLog.count++
      eventNameLog.lastRun = new Date().getTime()
    trigger = $.fn.trigger
    @originalTrigger = trigger
    $.fn.trigger = (event) ->
      eventName = event.type ? event
      registerTriggeredEvent(eventName) if $(this).events()[eventName]
      trigger.apply(this, arguments)

  deactivate: ->
    $.fn.trigger = @originalTrigger if @originalTrigger?
    @commandLoggerView = null
    @eventLog = {}

  serialize: ->
    {@eventLog}

  createView: ->
    unless @commandLoggerView
      CommandLoggerView = require './command-logger-view'
      @commandLoggerView = new CommandLoggerView<commit_msg>Always return created view<commit_after>$ = require 'jquery'

module.exports =
  eventLog: {}
  commandLoggerView: null
  originalTrigger: null

  activate: (state) ->
    @eventLog = state.eventLog ? {}
    rootView.command 'command-logger:clear-data', => @eventLog = {}
    rootView.command 'command-logger:toggle', => @createView().toggle(@eventLog)

    registerTriggeredEvent = (eventName) =>
      eventNameLog = @eventLog[eventName]
      unless eventNameLog
        eventNameLog =
          count: 0
          name: eventName
        @eventLog[eventName] = eventNameLog
      eventNameLog.count++
      eventNameLog.lastRun = new Date().getTime()
    trigger = $.fn.trigger
    @originalTrigger = trigger
    $.fn.trigger = (event) ->
      eventName = event.type ? event
      registerTriggeredEvent(eventName) if $(this).events()[eventName]
      trigger.apply(this, arguments)

  deactivate: ->
    $.fn.trigger = @originalTrigger if @originalTrigger?
    @commandLoggerView = null
    @eventLog = {}

  serialize: ->
    {@eventLog}

  createView: ->
    unless @commandLoggerView?
      CommandLoggerView = require './command-logger-view'
      @commandLoggerView = new CommandLoggerView
    @commandLoggerView
{'fraction_non_alphanumeric': 0.12121212121212122, 'fraction_numerical': 0.0008302200083022001, 'mean_word_length': 3.1337907375643224, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2270772', 'n_tokens_mistral': 700, 'n_tokens_neox': 688, 'n_words': 141}