Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
reader.onload = () => {
try {
if (_.isEmpty(reader.result)) {
this.setState({
error: true,
errorMessages: ['Your stats.json file is empty'],
})
logToGa({
category: 'error',
action: 'upload-stats',
label: 'empty stats.json file',
})
return
}
const resultTrimmed = trimJsonString(reader.result)
const fileAsBinaryString = JSON.parse(resultTrimmed)
const report = this.getReport(fileAsBinaryString)
if (report.error) {
this.setState({
error: report.error,
errorMessages: report.errorMessages,
})
logToGa(report.ga)
} else {
this.setState({
error: report.error,
errorMessages: report.errorMessages,
help: report.help,
})
logToGa(report.ga)