Replace use of lodash's assign with destructuring assignment in image-writer

Change-type: patch
This commit is contained in:
Alexis Svinartchouk 2020-01-27 11:51:53 +01:00
parent f6b7b0d3d2
commit 4d53002e5c

View File

@ -58,14 +58,12 @@ function handleErrorLogging(
error: Error & { code: string }, error: Error & { code: string },
analyticsData: any, analyticsData: any,
) { ) {
const eventData = _.assign( const eventData = {
{ ...analyticsData,
applicationSessionUuid: store.getState().toJS().applicationSessionUuid, applicationSessionUuid: store.getState().toJS().applicationSessionUuid,
flashingWorkflowUuid: store.getState().toJS().flashingWorkflowUuid, flashingWorkflowUuid: store.getState().toJS().flashingWorkflowUuid,
flashInstanceUuid: flashState.getFlashUuid(), flashInstanceUuid: flashState.getFlashUuid(),
}, };
analyticsData,
);
if (error.code === 'EVALIDATION') { if (error.code === 'EVALIDATION') {
analytics.logEvent('Validation error', eventData); analytics.logEvent('Validation error', eventData);
@ -78,15 +76,10 @@ function handleErrorLogging(
} else if (error.code === 'ECHILDDIED') { } else if (error.code === 'ECHILDDIED') {
analytics.logEvent('Child died unexpectedly', eventData); analytics.logEvent('Child died unexpectedly', eventData);
} else { } else {
analytics.logEvent( analytics.logEvent('Flash error', {
'Flash error', ...eventData,
_.merge( error: errors.toJSON(error),
{ });
error: errors.toJSON(error),
},
eventData,
),
);
} }
} }
@ -305,18 +298,19 @@ export async function flash(
} }
windowProgress.clear(); windowProgress.clear();
if (flashState.wasLastFlashCancelled()) { if (flashState.wasLastFlashCancelled()) {
const eventData = _.assign({ status: 'cancel' }, analyticsData); const eventData = {
...analyticsData,
status: 'cancel',
};
analytics.logEvent('Elevation cancelled', eventData); analytics.logEvent('Elevation cancelled', eventData);
} else { } else {
const { results } = flashState.getFlashResults(); const { results } = flashState.getFlashResults();
const eventData = _.assign( const eventData = {
{ ...analyticsData,
errors: results.errors, errors: results.errors,
devices: results.devices, devices: results.devices,
status: 'finished', status: 'finished',
}, };
analyticsData,
);
analytics.logEvent('Done', eventData); analytics.logEvent('Done', eventData);
} }
} }