fix(GUI): only emit toggle drive event if drive is selectable (#1913)

Right now we emit "Toggle drive" analytics events even when clicking on
disable/unselectable drives.

The fix is to move the `analytics.logEvent` inside the code path that
applies if a drive selection is considered valid.

Change-Type: patch
Changelog-Entry: Don't send analytics events when attempting to toggle a disabled drive.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
This commit is contained in:
Juan Cruz Viotti 2017-12-09 16:57:12 -04:00 committed by GitHub
parent 5432363aa1
commit f8c3faec79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -107,13 +107,13 @@ module.exports = function (
* });
*/
this.toggleDrive = (drive) => {
analytics.logEvent('Toggle drive', {
drive,
previouslySelected: selectionState.isCurrentDrive(drive.device)
})
return shouldChangeDriveSelectionState(drive).then((canChangeDriveSelectionState) => {
if (canChangeDriveSelectionState) {
analytics.logEvent('Toggle drive', {
drive,
previouslySelected: selectionState.isCurrentDrive(drive.device)
})
selectionState.toggleSetDrive(drive.device)
}
})