diff --git a/.env.example b/.env.example index 2bf4a5b..78b4096 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ +VUE_APP_KAWANIME_API_URL= VUE_APP_KAWANIME_SECRET= VUE_APP_ANILIST_CLIENT_ID= diff --git a/src/background/server/services/analytics/index.js b/src/background/server/services/analytics/index.js index 2fc493e..31764d3 100644 --- a/src/background/server/services/analytics/index.js +++ b/src/background/server/services/analytics/index.js @@ -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 diff --git a/vue.config.js b/vue.config.js index 4838c4a..a0f55de 100644 --- a/vue.config.js +++ b/vue.config.js @@ -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 *