mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-15 15:26:31 +00:00
fix(GUI): fix multi-writes analytics (#2295)
We make the analytics block into a function `handleErrorLogging` and use it in the fail event that happens during multi-writes. Previously error events would be handled when single drives were flashed on Promise rejection, instead we now only handle the Promise rejection when all devices fail as a special event. Change-Type: patch Changelog-Entry: Fix multi-writes analytics by reusing existing logic in multi-write events.
This commit is contained in:
parent
d7211b130b
commit
71064cc760
@ -60,6 +60,35 @@ const getApplicationEntryPoint = () => {
|
|||||||
return path.resolve(PROJECT_ROOT, relativeEntryPoint)
|
return path.resolve(PROJECT_ROOT, relativeEntryPoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @summary Handle a flash error and log it to analytics
|
||||||
|
* @function
|
||||||
|
* @private
|
||||||
|
*
|
||||||
|
* @param {Error} error - error object
|
||||||
|
* @param {Object} analyticsData - analytics object
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* handleErrorLogging({ code: 'EUNPLUGGED' }, { image: 'resin.img' })
|
||||||
|
*/
|
||||||
|
const handleErrorLogging = (error, analyticsData) => {
|
||||||
|
if (error.code === 'EVALIDATION') {
|
||||||
|
analytics.logEvent('Validation error', analyticsData)
|
||||||
|
} else if (error.code === 'EUNPLUGGED') {
|
||||||
|
analytics.logEvent('Drive unplugged', analyticsData)
|
||||||
|
} else if (error.code === 'EIO') {
|
||||||
|
analytics.logEvent('Input/output error', analyticsData)
|
||||||
|
} else if (error.code === 'ENOSPC') {
|
||||||
|
analytics.logEvent('Out of space', analyticsData)
|
||||||
|
} else if (error.code === 'ECHILDDIED') {
|
||||||
|
analytics.logEvent('Child died unexpectedly', analyticsData)
|
||||||
|
} else {
|
||||||
|
analytics.logEvent('Flash error', _.merge({
|
||||||
|
error: errors.toJSON(error)
|
||||||
|
}, analyticsData))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Perform write operation
|
* @summary Perform write operation
|
||||||
* @function
|
* @function
|
||||||
@ -127,9 +156,16 @@ exports.performWrite = (image, drives, onProgress) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const flashResults = {}
|
const flashResults = {}
|
||||||
|
const analyticsData = {
|
||||||
|
image,
|
||||||
|
drives,
|
||||||
|
uuid: flashState.getFlashUuid(),
|
||||||
|
unmountOnSuccess: settings.get('unmountOnSuccess'),
|
||||||
|
validateWriteOnSuccess: settings.get('validateWriteOnSuccess')
|
||||||
|
}
|
||||||
|
|
||||||
ipc.server.on('fail', (error) => {
|
ipc.server.on('fail', ({ device, error }) => {
|
||||||
console.log('Fail:', error)
|
handleErrorLogging(error, analyticsData)
|
||||||
})
|
})
|
||||||
|
|
||||||
ipc.server.on('done', (event) => {
|
ipc.server.on('done', (event) => {
|
||||||
@ -275,20 +311,9 @@ exports.flash = (image, drives) => {
|
|||||||
errorCode: error.code
|
errorCode: error.code
|
||||||
})
|
})
|
||||||
|
|
||||||
if (error.code === 'EVALIDATION') {
|
// eslint-disable-next-line no-magic-numbers
|
||||||
analytics.logEvent('Validation error', analyticsData)
|
if (drives.length > 1) {
|
||||||
} else if (error.code === 'EUNPLUGGED') {
|
analytics.logEvent('Write failed', analyticsData)
|
||||||
analytics.logEvent('Drive unplugged', analyticsData)
|
|
||||||
} else if (error.code === 'EIO') {
|
|
||||||
analytics.logEvent('Input/output error', analyticsData)
|
|
||||||
} else if (error.code === 'ENOSPC') {
|
|
||||||
analytics.logEvent('Out of space', analyticsData)
|
|
||||||
} else if (error.code === 'ECHILDDIED') {
|
|
||||||
analytics.logEvent('Child died unexpectedly', analyticsData)
|
|
||||||
} else {
|
|
||||||
analytics.logEvent('Flash error', _.merge({
|
|
||||||
error: errors.toJSON(error)
|
|
||||||
}, analyticsData))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Bluebird.reject(error)
|
return Bluebird.reject(error)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user