Made basic service to send analytics to kawanime

This commit is contained in:
Kylart 2019-06-18 15:37:20 +02:00
parent 5c5ccb2ba5
commit 9883cd3a83
3 changed files with 28 additions and 2 deletions

View File

@ -0,0 +1,23 @@
import { eventsList } from '../../../../vendor'
import { Logger, https } from '../../utils'
const events = eventsList.analytics
const ANALYTICS_URL = 'https://kawanime.com/api/v1/analytics'
const logger = new Logger('Analytics')
async function send (event, { eventName, data }) {
https.post(ANALYTICS_URL, {
eventName,
data
})
.catch(() => {
// We ignore errors
logger.error(`Could not send ${eventName} analytics event.`)
})
}
export default {
eventName: events.main,
handler: send
}

View File

@ -13,6 +13,7 @@ import isOnline from './isOnline'
import vault from './vault'
import watchLists from './watchLists'
import registerService from './registerService'
import analytics from './analytics'
const services = [
...config,
@ -29,7 +30,8 @@ const services = [
news,
seasons,
episodes,
isOnline
isOnline,
analytics
]
// auto update

View File

@ -19,7 +19,8 @@ const getOnly = [
// Internal
'env',
'isOnline',
'externalOpen'
'externalOpen',
'analytics'
]
const updatable = [