feat: telemetry module
This commit is contained in:
parent
b11a90cc06
commit
784b48680c
@ -17,7 +17,6 @@ import store from './store'
|
|||||||
// ====================================
|
// ====================================
|
||||||
|
|
||||||
import localization from './modules/localization'
|
import localization from './modules/localization'
|
||||||
import telemetry from './modules/telemetry'
|
|
||||||
|
|
||||||
// ====================================
|
// ====================================
|
||||||
// Load Helpers
|
// Load Helpers
|
||||||
|
@ -121,7 +121,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.$helpers._.delay(() => {
|
this.$helpers._.delay(() => {
|
||||||
axios.post('/syscheck').then(resp => {
|
axios.post('/syscheck', self.conf).then(resp => {
|
||||||
if (resp.data.ok === true) {
|
if (resp.data.ok === true) {
|
||||||
self.syscheck.ok = true
|
self.syscheck.ok = true
|
||||||
self.syscheck.results = resp.data.results
|
self.syscheck.results = resp.data.results
|
||||||
|
@ -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)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
@ -43,6 +43,7 @@
|
|||||||
"bcryptjs-then": "1.0.1",
|
"bcryptjs-then": "1.0.1",
|
||||||
"bluebird": "3.5.1",
|
"bluebird": "3.5.1",
|
||||||
"body-parser": "1.18.2",
|
"body-parser": "1.18.2",
|
||||||
|
"bugsnag": "2.0.0",
|
||||||
"bull": "3.3.0",
|
"bull": "3.3.0",
|
||||||
"bunyan": "1.8.12",
|
"bunyan": "1.8.12",
|
||||||
"cheerio": "1.0.0-rc.2",
|
"cheerio": "1.0.0-rc.2",
|
||||||
|
@ -39,6 +39,11 @@ configNamespaces:
|
|||||||
queues:
|
queues:
|
||||||
- gitSync
|
- gitSync
|
||||||
- uplClearTemp
|
- uplClearTemp
|
||||||
|
telemetry:
|
||||||
|
BUGSNAG_ID: 'bb4b324d0675bcbba10025617fd2cec8'
|
||||||
|
BUGSNAG_REMOTE: 'https://notify.bugsnag.com'
|
||||||
|
GA_ID: 'UA-9094100-7'
|
||||||
|
GA_REMOTE: 'https://www.google-analytics.com/collect'
|
||||||
authProviders:
|
authProviders:
|
||||||
- local
|
- local
|
||||||
- microsoft
|
- microsoft
|
||||||
|
@ -22,6 +22,7 @@ module.exports = () => {
|
|||||||
const yaml = require('js-yaml')
|
const yaml = require('js-yaml')
|
||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const cfgHelper = require('./helpers/config')
|
const cfgHelper = require('./helpers/config')
|
||||||
|
const filesize = require('filesize.js')
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
// Define Express App
|
// Define Express App
|
||||||
@ -59,7 +60,10 @@ module.exports = () => {
|
|||||||
|
|
||||||
app.get('*', (req, res) => {
|
app.get('*', (req, res) => {
|
||||||
fs.readJsonAsync(path.join(wiki.ROOTPATH, 'package.json')).then(packageObj => {
|
fs.readJsonAsync(path.join(wiki.ROOTPATH, 'package.json')).then(packageObj => {
|
||||||
res.render('configure/index', { packageObj })
|
res.render('configure/index', {
|
||||||
|
packageObj,
|
||||||
|
telemetryClientID: wiki.telemetry.cid
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -67,6 +71,9 @@ module.exports = () => {
|
|||||||
* Perform basic system checks
|
* Perform basic system checks
|
||||||
*/
|
*/
|
||||||
app.post('/syscheck', (req, res) => {
|
app.post('/syscheck', (req, res) => {
|
||||||
|
wiki.telemetry.enabled = (req.body.telemetry === true)
|
||||||
|
wiki.telemetry.sendEvent('setup', 'start')
|
||||||
|
|
||||||
Promise.mapSeries([
|
Promise.mapSeries([
|
||||||
() => {
|
() => {
|
||||||
const semver = require('semver')
|
const semver = require('semver')
|
||||||
@ -103,7 +110,7 @@ module.exports = () => {
|
|||||||
if (os.totalmem() < 1000 * 1000 * 512) {
|
if (os.totalmem() < 1000 * 1000 * 512) {
|
||||||
throw new Error('Not enough memory. Minimum is 512 MB.')
|
throw new Error('Not enough memory. Minimum is 512 MB.')
|
||||||
}
|
}
|
||||||
return _.round(os.totalmem() / (1024 * 1024)) + ' MB of system memory available. Minimum is 512 MB.'
|
return filesize(os.totalmem()) + ' of system memory available. Minimum is 512 MB.'
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
let fs = require('fs')
|
let fs = require('fs')
|
||||||
@ -124,6 +131,8 @@ module.exports = () => {
|
|||||||
* Check the Git connection
|
* Check the Git connection
|
||||||
*/
|
*/
|
||||||
app.post('/gitcheck', (req, res) => {
|
app.post('/gitcheck', (req, res) => {
|
||||||
|
wiki.telemetry.sendEvent('setup', 'gitcheck')
|
||||||
|
|
||||||
const exec = require('execa')
|
const exec = require('execa')
|
||||||
const url = require('url')
|
const url = require('url')
|
||||||
|
|
||||||
@ -212,6 +221,8 @@ module.exports = () => {
|
|||||||
* Finalize
|
* Finalize
|
||||||
*/
|
*/
|
||||||
app.post('/finalize', (req, res) => {
|
app.post('/finalize', (req, res) => {
|
||||||
|
wiki.telemetry.sendEvent('setup', 'finalize')
|
||||||
|
|
||||||
const bcrypt = require('bcryptjs-then')
|
const bcrypt = require('bcryptjs-then')
|
||||||
const crypto = Promise.promisifyAll(require('crypto'))
|
const crypto = Promise.promisifyAll(require('crypto'))
|
||||||
let mongo = require('mongodb').MongoClient
|
let mongo = require('mongodb').MongoClient
|
||||||
@ -359,6 +370,7 @@ module.exports = () => {
|
|||||||
error: wiki.IS_DEBUG ? err : {}
|
error: wiki.IS_DEBUG ? err : {}
|
||||||
})
|
})
|
||||||
wiki.logger.error(err.message)
|
wiki.logger.error(err.message)
|
||||||
|
wiki.telemetry.sendError(err)
|
||||||
})
|
})
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
/* global wiki */
|
/* global wiki */
|
||||||
|
|
||||||
module.exports = false
|
|
||||||
return
|
|
||||||
|
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
|
|
||||||
|
@ -30,6 +30,12 @@ wiki.configSvc.init()
|
|||||||
|
|
||||||
wiki.logger = require('./modules/logger').init()
|
wiki.logger = require('./modules/logger').init()
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
// Init Telemetry
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
|
wiki.telemetry = require('./modules/telemetry').init()
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
// Init DB
|
// Init DB
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
@ -37,19 +37,15 @@ module.exports = {
|
|||||||
|
|
||||||
appconfig = _.defaultsDeep(appconfig, appdata.defaults.config)
|
appconfig = _.defaultsDeep(appconfig, appdata.defaults.config)
|
||||||
|
|
||||||
// Check port
|
|
||||||
|
|
||||||
if (appconfig.port < 1) {
|
if (appconfig.port < 1) {
|
||||||
appconfig.port = process.env.PORT || 80
|
appconfig.port = process.env.PORT || 80
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert booleans
|
|
||||||
|
|
||||||
appconfig.public = (appconfig.public === true || _.toLower(appconfig.public) === 'true')
|
appconfig.public = (appconfig.public === true || _.toLower(appconfig.public) === 'true')
|
||||||
|
|
||||||
// List authentication strategies
|
|
||||||
wiki.config = appconfig
|
wiki.config = appconfig
|
||||||
wiki.data = appdata
|
wiki.data = appdata
|
||||||
|
wiki.version = require(path.join(wiki.ROOTPATH, 'package.json')).version
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
63
server/modules/telemetry.js
Normal file
63
server/modules/telemetry.js
Normal file
@ -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.')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ block body
|
|||||||
body
|
body
|
||||||
#app.config-manager
|
#app.config-manager
|
||||||
config-manager(inline-template)
|
config-manager(inline-template)
|
||||||
|
div
|
||||||
.container
|
.container
|
||||||
transition(name='tst-welcome')
|
transition(name='tst-welcome')
|
||||||
.welcome(v-if='state === "welcome" || state === "restart"')
|
.welcome(v-if='state === "welcome" || state === "restart"')
|
||||||
@ -302,3 +303,7 @@ block body
|
|||||||
p You'll automatically be redirected to the homepage when ready. This usually takes about 30 seconds.
|
p You'll automatically be redirected to the homepage when ready. This usually takes about 30 seconds.
|
||||||
.panel-footer
|
.panel-footer
|
||||||
button.button.is-small.is-green(disabled='disabled') Start
|
button.button.is-small.is-green(disabled='disabled') Start
|
||||||
|
|
||||||
|
.footer
|
||||||
|
small Wiki.js Configuration Manager
|
||||||
|
small(v-if='conf.telemetry') Telemetry Client ID: !{telemetryClientID}
|
13
yarn.lock
13
yarn.lock
@ -1519,6 +1519,15 @@ buffer-writer@1.0.1:
|
|||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/buffer-writer/-/buffer-writer-1.0.1.tgz#22a936901e3029afcd7547eb4487ceb697a3bf08"
|
resolved "https://registry.yarnpkg.com/buffer-writer/-/buffer-writer-1.0.1.tgz#22a936901e3029afcd7547eb4487ceb697a3bf08"
|
||||||
|
|
||||||
|
bugsnag@2.0.0:
|
||||||
|
version "2.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/bugsnag/-/bugsnag-2.0.0.tgz#6d30f74aa504bf0fd507abd5537b933c381bcb6b"
|
||||||
|
dependencies:
|
||||||
|
json-stringify-safe "~5.0.1"
|
||||||
|
promise "7.x"
|
||||||
|
request "^2.81.0"
|
||||||
|
stack-trace "~0.0.9"
|
||||||
|
|
||||||
builtin-modules@^1.0.0, builtin-modules@^1.1.1:
|
builtin-modules@^1.0.0, builtin-modules@^1.1.1:
|
||||||
version "1.1.1"
|
version "1.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
|
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
|
||||||
@ -6148,7 +6157,7 @@ promise-polyfill@^6.0.1:
|
|||||||
version "6.0.2"
|
version "6.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/promise-polyfill/-/promise-polyfill-6.0.2.tgz#d9c86d3dc4dc2df9016e88946defd69b49b41162"
|
resolved "https://registry.yarnpkg.com/promise-polyfill/-/promise-polyfill-6.0.2.tgz#d9c86d3dc4dc2df9016e88946defd69b49b41162"
|
||||||
|
|
||||||
promise@^7.0.1:
|
promise@7.x, promise@^7.0.1:
|
||||||
version "7.3.1"
|
version "7.3.1"
|
||||||
resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
|
resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -7110,7 +7119,7 @@ sshpk@^1.7.0:
|
|||||||
jsbn "~0.1.0"
|
jsbn "~0.1.0"
|
||||||
tweetnacl "~0.14.0"
|
tweetnacl "~0.14.0"
|
||||||
|
|
||||||
stack-trace@0.0.x:
|
stack-trace@0.0.x, stack-trace@~0.0.9:
|
||||||
version "0.0.10"
|
version "0.0.10"
|
||||||
resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0"
|
resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user