<commit_before>/* global Piwik */
import {
  UPLOAD_FILE
} from '../actions'

const CATEGORY = {
  BUTTONS: 'buttons'
}

const piwik = store => next => action => {
  let event = null

  switch (action.type){
    case UPLOAD_FILE:
      event = {
        category: CATEGORY.BUTTONS,
        action: 'upload'
      }
      break;
    default:
      break;
  }

  if (event && event.category && event.action) {
    const tracker = Piwik.getTracker()
    tracker.trackEvent(event.category, event.action, event.name, event.value)
  }

  return next(action)
}

export default piwik
<commit_msg>fix: Added try/catch<commit_after>/* global Piwik */
import {
  UPLOAD_FILE
} from '../actions'

const CATEGORY = {
  BUTTONS: 'buttons'
}

const piwik = store => next => action => {
  let event = null

  switch (action.type){
    case UPLOAD_FILE:
      event = {
        category: CATEGORY.BUTTONS,
        action: 'upload'
      }
      break;
    default:
      break;
  }

  if (event && event.category && event.action) {
    try {
      const tracker = Piwik.getTracker()
      tracker.trackEvent(event.category, event.action, event.name, event.value)
    }
    catch (err) { }
  }

  return next(action)
}

export default piwik

{'fraction_non_alphanumeric': 0.12755519215044972, 'fraction_numerical': 0.0, 'mean_word_length': 2.4871794871794872, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6781481', 'n_tokens_mistral': 422, 'n_tokens_neox': 418, 'n_words': 99}