feat: remove anonymous analytics (fixes #322)

pull/336/head
Romain 1 year ago
parent 8a43cebc72
commit 0800f2708a

@ -1,35 +0,0 @@
const Insight = require('insight')
const path = require('path')
const pkg = require(path.join(__dirname, '..', 'package.json'))
// Google Analytics tracking code
const TRACKING_CODE = 'UA-110087713-3'
class Analytics {
constructor ({ enabled }) {
this.enabled = enabled
this.insight = new Insight({ trackingCode: TRACKING_CODE, pkg })
this.insight.optOut = !enabled
}
// report that the gallery has started building
start (done) {
this.insight.track('start')
}
// report that the gallery has finished building + some stats
finish (stats, done) {
this.insight.track('finish')
this.insight.trackEvent({ category: 'gallery', action: 'albums', label: 'Album count', value: stats.albums })
this.insight.trackEvent({ category: 'gallery', action: 'photos', label: 'Photo count', value: stats.photos })
this.insight.trackEvent({ category: 'gallery', action: 'videos', label: 'Video count', value: stats.videos })
}
// report that an error happened
// but don't report the contents (might contain file paths etc)
error (done) {
this.insight.track('error')
}
}
module.exports = Analytics

@ -2,7 +2,6 @@
const fs = require('fs-extra')
const moment = require('moment')
const Analytics = require('./analytics')
const dependencies = require('../src/cli/dependencies')
const messages = require('../src/cli/messages')
const options = require('../src/cli/options')
@ -24,12 +23,6 @@ if (firstRun) {
console.log(`${messages.GREETING()}\n`)
}
// Basic usage report (anonymous statistics)
const analytics = new Analytics({
enabled: opts.usageStats
})
analytics.start()
// Catch all exceptions and exit gracefully
process.on('uncaughtException', handleError)
process.on('unhandledRejection', handleError)
@ -59,7 +52,6 @@ index.build(opts, (err, result) => {
photos: result.album.stats.photos,
videos: result.album.stats.videos
}
analytics.finish(stats)
console.log(messages.SUCCESS(stats) + '\n')
exit(0)
}
@ -68,7 +60,6 @@ index.build(opts, (err, result) => {
// Print an error report and exit
// Note: remove "err.context" (entire data model) which can make the output hard to read
function handleError (err) {
analytics.error()
delete err.context
require('debug')('thumbsup:error')(err)
console.error('\nUnexpected error', err.message)
@ -77,12 +68,9 @@ function handleError (err) {
}
// Force a successful or failed exit
// This is required
// - because capturing unhandled errors will make Listr run forever
// - to ensure pending Analytics HTTP requests don't keep the tool running
// This is required because capturing unhandled errors will make Listr run forever
function exit (code) {
// just some time to ensure analytics has time to fire
setTimeout(() => process.exit(code), 10)
process.exit(code)
}
// Count the total number of nested albums

1864
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -47,7 +47,6 @@
"fs-readdir-recursive": "^1.0.0",
"handlebars": "^4.7.7",
"ini": "^3.0.1",
"insight": "^0.11.1",
"JSONStream": "^1.3.5",
"less": "^4.1.3",
"listr": "^0.14.3",

@ -39,14 +39,7 @@ exports.PROBLEMS = (count) => chalk.yellow(`
exports.GREETING = () => box(`
Thanks for using thumbsup!
Don't forget to check out the docs at ${DOCS_URL}.
When building a gallery, thumbsup reports anonymous stats such as the
OS and gallery size. This is used to understand usage patterns & guide
development effort. You can disable this by specifying --no-usage-stats.
This welcome message will not be shown again for this gallery.
Enjoy!
`)

@ -393,13 +393,6 @@ const OPTIONS = {
'default': 'default'
},
'usage-stats': {
group: 'Misc options:',
description: 'Enable anonymous usage statistics',
type: 'boolean',
'default': true
},
'dry-run': {
group: 'Misc options:',
description: "Update the index, but don't create the media files / website",
@ -444,6 +437,12 @@ const OPTIONS = {
group: 'Deprecated:',
description: 'Path or URL prefix for linked downloads',
type: 'string'
},
'usage-stats': {
group: 'Misc options:',
description: 'Enable anonymous usage statistics',
type: 'boolean',
'default': false
}
}

Loading…
Cancel
Save