mirror of https://github.com/Kylart/KawAnime.git
Added KawAnime secret to authenticate on analytics server
This commit is contained in:
parent
6bb49934f3
commit
2caf50c4ef
|
@ -1,3 +1,5 @@
|
|||
VUE_APP_KAWANIME_SECRET=
|
||||
|
||||
VUE_APP_ANILIST_CLIENT_ID=
|
||||
VUE_APP_ANILIST_CLIENT_SECRET=
|
||||
|
||||
|
|
|
@ -1,16 +1,22 @@
|
|||
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 = 'https://kawanime.com/api/v1/analytics'
|
||||
const userToken = readFileSync(localFiles.getPath('_token'))
|
||||
|
||||
const logger = new Logger('Analytics')
|
||||
|
||||
async function send (event, { eventName, data }) {
|
||||
https.post(ANALYTICS_URL, {
|
||||
eventName,
|
||||
data
|
||||
})
|
||||
data,
|
||||
userToken
|
||||
}, [], { Authorization: secretKey })
|
||||
.catch(() => {
|
||||
// We ignore errors
|
||||
logger.error(`Could not send ${eventName} analytics event.`)
|
||||
|
|
Loading…
Reference in New Issue