<commit_before>import { readFileSync } from 'fs'

import { eventsList } from 'vendor'
import { Logger, https } from '../../utils'
import { localFiles } from '../../externals'

const events = eventsList.analytics
const secretKey = process.env.VUE_APP_KAWANIME_SECRET
const ANALYTICS_URL = process.env.VUE_APP_KAWANIME_API_URL
const VERSION = process.env.KAWANIME_VERSION
const userToken = readFileSync(localFiles.getPath('_token'))

const logger = new Logger('Analytics')

async function send (event, { eventName, data }) {
  https.post(`${ANALYTICS_URL}/analytics`, {
    eventName,
    data,
    userToken,
    version: VERSION
  }, [], { Authorization: `Bearer ${secretKey}` })
    .catch(() => {
      // We ignore errors
      logger.error(`Could not send ${eventName} analytics event.`)
    })
}

export default {
  eventName: events.main,
  handler: send
}
<commit_msg>Fix userToken value retrieval<commit_after>import { readFileSync } from 'fs'

import { eventsList } from 'vendor'
import { Logger, https } from '../../utils'
import { localFiles } from '../../externals'

const events = eventsList.analytics
const secretKey = process.env.VUE_APP_KAWANIME_SECRET
const ANALYTICS_URL = process.env.VUE_APP_KAWANIME_API_URL
const VERSION = process.env.KAWANIME_VERSION
const userToken = readFileSync(localFiles.getPath('_token'), 'utf-8')

const logger = new Logger('Analytics')

async function send (event, { eventName, data }) {
  https.post(`${ANALYTICS_URL}/analytics`, {
    eventName,
    data,
    userToken,
    version: VERSION
  }, [], { Authorization: `Bearer ${secretKey}` })
    .catch(() => {
      // We ignore errors
      logger.error(`Could not send ${eventName} analytics event.`)
    })
}

export default {
  eventName: events.main,
  handler: send
}

{'fraction_non_alphanumeric': 0.1352112676056338, 'fraction_numerical': 0.0005633802816901409, 'mean_word_length': 4.045454545454546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5984593', 'n_tokens_mistral': 577, 'n_tokens_neox': 579, 'n_words': 138}