Added version to send to analytics

This commit is contained in:
Kylart 2019-07-13 15:31:07 +02:00
parent cccfc8db31
commit 0000f9ae66
3 changed files with 8 additions and 3 deletions

View File

@ -1,3 +1,4 @@
VUE_APP_KAWANIME_API_URL=
VUE_APP_KAWANIME_SECRET=
VUE_APP_ANILIST_CLIENT_ID=

View File

@ -6,16 +6,18 @@ import { localFiles } from '../../externals'
const events = eventsList.analytics
const secretKey = process.env.VUE_APP_KAWANIME_SECRET
const ANALYTICS_URL = 'https://api.kawanime.com/v1/analytics'
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, {
https.post(`${ANALYTICS_URL}/analytics`, {
eventName,
data,
userToken
userToken,
version: VERSION
}, [], { Authorization: `Bearer ${secretKey}` })
.catch(() => {
// We ignore errors

View File

@ -1,6 +1,8 @@
const fs = require('fs')
const path = require('path')
process.env.KAWANIME_VERSION = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'package.json'))).version
/**
* Taken from https://gist.github.com/kethinov/6658166#gistcomment-2389484
*