mirror of https://github.com/Kylart/KawAnime.git
Merge branch 'analytics' into dev
This commit is contained in:
commit
42b51d91df
|
@ -1,3 +1,6 @@
|
|||
VUE_APP_KAWANIME_API_URL=
|
||||
VUE_APP_KAWANIME_SECRET=
|
||||
|
||||
VUE_APP_ANILIST_CLIENT_ID=
|
||||
VUE_APP_ANILIST_CLIENT_SECRET=
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
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
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -32,7 +32,8 @@ export default {
|
|||
darkTheme: true,
|
||||
autoStart: false,
|
||||
toTray: false,
|
||||
center: true
|
||||
center: true,
|
||||
analytics: true
|
||||
},
|
||||
bounds: {
|
||||
height: null,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
v-card-text
|
||||
v-container(grid-list-lg, pa-0, pb-2)
|
||||
v-layout(row, wrap, justify-space-around, align-center)
|
||||
v-flex(xs12, sm4)
|
||||
v-flex(xs12, sm3)
|
||||
v-switch.mt-0(
|
||||
v-model='tray',
|
||||
color='primary',
|
||||
|
@ -14,7 +14,7 @@
|
|||
persistent-hint,
|
||||
hint='*Should KawAnime be in your tray?'
|
||||
)
|
||||
v-flex(xs12, sm4)
|
||||
v-flex(xs12, sm3)
|
||||
v-switch.mt-0(
|
||||
v-model='autoStart',
|
||||
color='primary',
|
||||
|
@ -22,7 +22,7 @@
|
|||
persistent-hint,
|
||||
hint='*Should KawAnime start on boot?'
|
||||
)
|
||||
v-flex(xs12, sm4)
|
||||
v-flex(xs12, sm3)
|
||||
v-switch.mt-0(
|
||||
v-model='darkTheme',
|
||||
color='primary',
|
||||
|
@ -30,6 +30,14 @@
|
|||
persistent-hint,
|
||||
hint='Theme to apply'
|
||||
)
|
||||
v-flex(xs12, sm3)
|
||||
v-switch.mt-0(
|
||||
v-model='analytics',
|
||||
color='primary',
|
||||
:label="analytics ? 'Ok' : 'Nope'"
|
||||
persistent-hint,
|
||||
hint='Allows the app to send events to our server (mainly to know how many users we have)'
|
||||
)
|
||||
|
||||
v-container(grid-list-lg, pa-0, mt-3)
|
||||
v-layout(row, wrap, justify-space-around, align-center)
|
||||
|
@ -144,6 +152,14 @@ export default {
|
|||
this.setDeepValue('system.darkTheme', val)
|
||||
}
|
||||
},
|
||||
analytics: {
|
||||
get () {
|
||||
return this.system.analytics
|
||||
},
|
||||
set (val) {
|
||||
this.setDeepValue('system.analytics', val)
|
||||
}
|
||||
},
|
||||
height: {
|
||||
get () {
|
||||
return this.bounds.height
|
||||
|
|
|
@ -32,6 +32,14 @@ export default {
|
|||
checkOnlineStatus () {
|
||||
ipcRenderer.send(eventsList.isOnline.main)
|
||||
},
|
||||
analytics ({ state }, args) {
|
||||
const { config: { system: { analytics } } } = state.config
|
||||
|
||||
if (analytics) {
|
||||
ipcRenderer.send(eventsList.analytics.main, args)
|
||||
}
|
||||
},
|
||||
|
||||
setEvents ({ state, commit, dispatch }) {
|
||||
ipcRenderer.on(eventsList.isOnline.success, (e) => {
|
||||
const isConnected = state.isConnected
|
||||
|
|
|
@ -4,6 +4,8 @@ export const get = {
|
|||
success ({ commit, dispatch }, data) {
|
||||
commit('set', data.config)
|
||||
|
||||
dispatch('analytics', { eventName: 'appOpen' }, isRoot)
|
||||
|
||||
// Setting defaults
|
||||
dispatch('player/setUp', null, isRoot)
|
||||
commit('localFiles/setDir', data.config.localPath, isRoot)
|
||||
|
|
|
@ -19,7 +19,8 @@ const getOnly = [
|
|||
// Internal
|
||||
'env',
|
||||
'isOnline',
|
||||
'externalOpen'
|
||||
'externalOpen',
|
||||
'analytics'
|
||||
]
|
||||
|
||||
const updatable = [
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue