mirror of https://github.com/requarks/wiki
parent
b11a90cc06
commit
784b48680c
@ -1,7 +1,5 @@
|
|||||||
import GRAPHQL from './graphql'
|
import GRAPHQL from './graphql'
|
||||||
import TELEMETRY from './telemetry'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
GRAPHQL,
|
GRAPHQL
|
||||||
TELEMETRY
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
export default {
|
|
||||||
GA_ID: 'UA-9094100-7',
|
|
||||||
GA_REMOTE: 'http://www.google-analytics.com/collect'
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
import uuid from 'uuid/v4'
|
|
||||||
|
|
||||||
/* global CONSTANTS, wiki */
|
|
||||||
|
|
||||||
export default {
|
|
||||||
cid: '',
|
|
||||||
init() {
|
|
||||||
this.cid = uuid()
|
|
||||||
},
|
|
||||||
sendEvent() {
|
|
||||||
wiki.$http.post(CONSTANTS.TELEMETRY.GA_REMOTE, {
|
|
||||||
v: 1, // API version
|
|
||||||
tid: CONSTANTS.TELEMETRY.GA_ID, // Tracking ID
|
|
||||||
aip: 1, // Anonymize IP
|
|
||||||
ds: 'server', // Data source
|
|
||||||
t: 'event', // Hit Type
|
|
||||||
ec: 'setup', // Event Category
|
|
||||||
ea: 'start', // Event Action
|
|
||||||
el: 'success', // Event Label
|
|
||||||
ev: 1 // Event Value
|
|
||||||
}).then(resp => {
|
|
||||||
|
|
||||||
}, err => {
|
|
||||||
console.error(err)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,63 @@
|
|||||||
|
const axios = require('axios')
|
||||||
|
const bugsnag = require('bugsnag')
|
||||||
|
const path = require('path')
|
||||||
|
const uuid = require('uuid/v4')
|
||||||
|
const _ = require('lodash')
|
||||||
|
|
||||||
|
/* global wiki */
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
cid: '',
|
||||||
|
enabled: false,
|
||||||
|
init() {
|
||||||
|
this.cid = uuid()
|
||||||
|
bugsnag.register(wiki.data.telemetry.BUGSNAG_ID, {
|
||||||
|
appVersion: wiki.version,
|
||||||
|
autoNotify: false,
|
||||||
|
hostname: this.cid,
|
||||||
|
notifyReleaseStages: ['production'],
|
||||||
|
packageJSON: path.join(wiki.ROOTPATH, 'package.json'),
|
||||||
|
projectRoot: wiki.ROOTPATH,
|
||||||
|
useSSL: true
|
||||||
|
})
|
||||||
|
bugsnag.onBeforeNotify((notification, originalError) => {
|
||||||
|
if (!this.enabled) { return false }
|
||||||
|
})
|
||||||
|
|
||||||
|
if (_.get(wiki.config, 'logging.telemetry', false) === true) {
|
||||||
|
this.enabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
return this
|
||||||
|
},
|
||||||
|
sendError(err) {
|
||||||
|
bugsnag.notify(err)
|
||||||
|
},
|
||||||
|
sendEvent(eventCategory, eventAction, eventLabel) {
|
||||||
|
if (!this.enabled) { return false }
|
||||||
|
axios({
|
||||||
|
method: 'post',
|
||||||
|
url: wiki.data.telemetry.GA_REMOTE,
|
||||||
|
headers: {
|
||||||
|
'Content-type': 'application/x-www-form-urlencoded'
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
v: 1, // API version
|
||||||
|
tid: wiki.data.telemetry.GA_ID, // Tracking ID
|
||||||
|
aip: 1, // Anonymize IP
|
||||||
|
ds: 'server', // Data source
|
||||||
|
cid: this.cid, // Client ID
|
||||||
|
t: 'event', // Hit Type
|
||||||
|
ec: eventCategory, // Event Category
|
||||||
|
ea: eventAction, // Event Action
|
||||||
|
el: eventLabel // Event Label
|
||||||
|
}
|
||||||
|
}).then(resp => {
|
||||||
|
if (resp.status !== 200) {
|
||||||
|
wiki.logger.warn('Unable to send analytics telemetry request.')
|
||||||
|
}
|
||||||
|
}, err => {
|
||||||
|
wiki.logger.warn('Unable to send analytics telemetry request.')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue