mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-27 05:06:40 +00:00
refactor(GUI): remove analytics angular dependency (#1387)
We rename `AnalyticsService` to `analytics` and remove its dependency on Angular.
This commit is contained in:
parent
66547c5abd
commit
69a982bf8d
@ -38,6 +38,7 @@ const packageJSON = require('../../package.json');
|
|||||||
const flashState = require('./models/flash-state');
|
const flashState = require('./models/flash-state');
|
||||||
const settings = require('./models/settings');
|
const settings = require('./models/settings');
|
||||||
const windowProgress = require('./os/window-progress');
|
const windowProgress = require('./os/window-progress');
|
||||||
|
const analytics = require('./modules/analytics');
|
||||||
|
|
||||||
const Store = require('./models/store');
|
const Store = require('./models/store');
|
||||||
|
|
||||||
@ -47,7 +48,6 @@ const app = angular.module('Etcher', [
|
|||||||
require('angular-if-state'),
|
require('angular-if-state'),
|
||||||
|
|
||||||
// Etcher modules
|
// Etcher modules
|
||||||
require('./modules/analytics'),
|
|
||||||
require('./modules/error'),
|
require('./modules/error'),
|
||||||
require('./modules/drive-scanner'),
|
require('./modules/drive-scanner'),
|
||||||
|
|
||||||
@ -88,8 +88,8 @@ app.run(() => {
|
|||||||
].join('\n'));
|
].join('\n'));
|
||||||
});
|
});
|
||||||
|
|
||||||
app.run((AnalyticsService, ErrorService, UpdateNotifierService, SelectionStateModel) => {
|
app.run((ErrorService, UpdateNotifierService, SelectionStateModel) => {
|
||||||
AnalyticsService.logEvent('Application start');
|
analytics.logEvent('Application start');
|
||||||
|
|
||||||
const currentVersion = packageJSON.version;
|
const currentVersion = packageJSON.version;
|
||||||
const currentReleaseType = release.getReleaseType(currentVersion);
|
const currentReleaseType = release.getReleaseType(currentVersion);
|
||||||
@ -102,7 +102,7 @@ app.run((AnalyticsService, ErrorService, UpdateNotifierService, SelectionStateMo
|
|||||||
process.env.ETCHER_DISABLE_UPDATES,
|
process.env.ETCHER_DISABLE_UPDATES,
|
||||||
currentReleaseType === release.RELEASE_TYPE.UNKNOWN
|
currentReleaseType === release.RELEASE_TYPE.UNKNOWN
|
||||||
])) {
|
])) {
|
||||||
AnalyticsService.logEvent('Not checking for updates', {
|
analytics.logEvent('Not checking for updates', {
|
||||||
shouldCheckForUpdates,
|
shouldCheckForUpdates,
|
||||||
disableUpdatesEnvironmentVariable: process.env.ETCHER_DISABLE_UPDATES,
|
disableUpdatesEnvironmentVariable: process.env.ETCHER_DISABLE_UPDATES,
|
||||||
releaseType: currentReleaseType
|
releaseType: currentReleaseType
|
||||||
@ -113,7 +113,7 @@ app.run((AnalyticsService, ErrorService, UpdateNotifierService, SelectionStateMo
|
|||||||
const updateSemverRange = packageJSON.updates.semverRange;
|
const updateSemverRange = packageJSON.updates.semverRange;
|
||||||
const includeUnstableChannel = settings.get('includeUnstableUpdateChannel');
|
const includeUnstableChannel = settings.get('includeUnstableUpdateChannel');
|
||||||
|
|
||||||
AnalyticsService.logEvent('Checking for updates', {
|
analytics.logEvent('Checking for updates', {
|
||||||
currentVersion,
|
currentVersion,
|
||||||
releaseType: currentReleaseType,
|
releaseType: currentReleaseType,
|
||||||
updateSemverRange,
|
updateSemverRange,
|
||||||
@ -125,7 +125,7 @@ app.run((AnalyticsService, ErrorService, UpdateNotifierService, SelectionStateMo
|
|||||||
includeUnstableChannel
|
includeUnstableChannel
|
||||||
}).then((latestVersion) => {
|
}).then((latestVersion) => {
|
||||||
if (semver.gte(currentVersion, latestVersion || '0.0.0')) {
|
if (semver.gte(currentVersion, latestVersion || '0.0.0')) {
|
||||||
AnalyticsService.logEvent('Update notification skipped', {
|
analytics.logEvent('Update notification skipped', {
|
||||||
reason: 'Latest version'
|
reason: 'Latest version'
|
||||||
});
|
});
|
||||||
return Bluebird.resolve();
|
return Bluebird.resolve();
|
||||||
@ -137,13 +137,13 @@ app.run((AnalyticsService, ErrorService, UpdateNotifierService, SelectionStateMo
|
|||||||
// process (e.g: selected an image), otherwise such interruption
|
// process (e.g: selected an image), otherwise such interruption
|
||||||
// might be annoying.
|
// might be annoying.
|
||||||
if (SelectionStateModel.hasImage()) {
|
if (SelectionStateModel.hasImage()) {
|
||||||
AnalyticsService.logEvent('Update notification skipped', {
|
analytics.logEvent('Update notification skipped', {
|
||||||
reason: 'Image selected'
|
reason: 'Image selected'
|
||||||
});
|
});
|
||||||
return Bluebird.resolve();
|
return Bluebird.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
AnalyticsService.logEvent('Notifying update', {
|
analytics.logEvent('Notifying update', {
|
||||||
latestVersion
|
latestVersion
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ app.run((AnalyticsService, ErrorService, UpdateNotifierService, SelectionStateMo
|
|||||||
}).catch(ErrorService.reportException);
|
}).catch(ErrorService.reportException);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.run((AnalyticsService) => {
|
app.run(() => {
|
||||||
Store.subscribe(() => {
|
Store.subscribe(() => {
|
||||||
const currentFlashState = flashState.getFlashState();
|
const currentFlashState = flashState.getFlashState();
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ app.run((AnalyticsService) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AnalyticsService.logDebug([
|
analytics.logDebug([
|
||||||
`Progress (${currentFlashState.type}):`,
|
`Progress (${currentFlashState.type}):`,
|
||||||
`${currentFlashState.percentage}% at ${currentFlashState.speed} MB/s`,
|
`${currentFlashState.percentage}% at ${currentFlashState.speed} MB/s`,
|
||||||
`(eta ${currentFlashState.eta}s)`
|
`(eta ${currentFlashState.eta}s)`
|
||||||
@ -204,12 +204,12 @@ app.run(($timeout, DriveScannerService, DrivesModel, ErrorService) => {
|
|||||||
DriveScannerService.start();
|
DriveScannerService.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.run(($window, AnalyticsService, WarningModalService, ErrorService, OSDialogService) => {
|
app.run(($window, WarningModalService, ErrorService, OSDialogService) => {
|
||||||
let popupExists = false;
|
let popupExists = false;
|
||||||
|
|
||||||
$window.addEventListener('beforeunload', (event) => {
|
$window.addEventListener('beforeunload', (event) => {
|
||||||
if (!flashState.isFlashing() || popupExists) {
|
if (!flashState.isFlashing() || popupExists) {
|
||||||
AnalyticsService.logEvent('Close application', {
|
analytics.logEvent('Close application', {
|
||||||
isFlashing: flashState.isFlashing()
|
isFlashing: flashState.isFlashing()
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -221,7 +221,7 @@ app.run(($window, AnalyticsService, WarningModalService, ErrorService, OSDialogS
|
|||||||
// Don't open any more popups
|
// Don't open any more popups
|
||||||
popupExists = true;
|
popupExists = true;
|
||||||
|
|
||||||
AnalyticsService.logEvent('Close attempt while flashing');
|
analytics.logEvent('Close attempt while flashing');
|
||||||
|
|
||||||
OSDialogService.showWarning({
|
OSDialogService.showWarning({
|
||||||
confirmationLabel: 'Yes, quit',
|
confirmationLabel: 'Yes, quit',
|
||||||
@ -230,7 +230,7 @@ app.run(($window, AnalyticsService, WarningModalService, ErrorService, OSDialogS
|
|||||||
description: messages.warning.exitWhileFlashing()
|
description: messages.warning.exitWhileFlashing()
|
||||||
}).then((confirmed) => {
|
}).then((confirmed) => {
|
||||||
if (confirmed) {
|
if (confirmed) {
|
||||||
AnalyticsService.logEvent('Close confirmed while flashing', {
|
analytics.logEvent('Close confirmed while flashing', {
|
||||||
uuid: flashState.getFlashUuid()
|
uuid: flashState.getFlashUuid()
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -240,13 +240,13 @@ app.run(($window, AnalyticsService, WarningModalService, ErrorService, OSDialogS
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AnalyticsService.logEvent('Close rejected while flashing');
|
analytics.logEvent('Close rejected while flashing');
|
||||||
popupExists = false;
|
popupExists = false;
|
||||||
}).catch(ErrorService.reportException);
|
}).catch(ErrorService.reportException);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.run(($rootScope, AnalyticsService) => {
|
app.run(($rootScope) => {
|
||||||
$rootScope.$on('$stateChangeSuccess', (event, toState, toParams, fromState) => {
|
$rootScope.$on('$stateChangeSuccess', (event, toState, toParams, fromState) => {
|
||||||
|
|
||||||
// Ignore first navigation
|
// Ignore first navigation
|
||||||
@ -254,7 +254,7 @@ app.run(($rootScope, AnalyticsService) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AnalyticsService.logEvent('Navigate', {
|
analytics.logEvent('Navigate', {
|
||||||
to: toState.name,
|
to: toState.name,
|
||||||
from: fromState.name
|
from: fromState.name
|
||||||
});
|
});
|
||||||
|
@ -20,14 +20,14 @@ const angular = require('angular');
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const messages = require('../../../../shared/messages');
|
const messages = require('../../../../shared/messages');
|
||||||
const constraints = require('../../../../shared/drive-constraints');
|
const constraints = require('../../../../shared/drive-constraints');
|
||||||
|
const analytics = require('../../../modules/analytics');
|
||||||
|
|
||||||
module.exports = function(
|
module.exports = function(
|
||||||
$q,
|
$q,
|
||||||
$uibModalInstance,
|
$uibModalInstance,
|
||||||
DrivesModel,
|
DrivesModel,
|
||||||
SelectionStateModel,
|
SelectionStateModel,
|
||||||
WarningModalService,
|
WarningModalService
|
||||||
AnalyticsService
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,7 +109,7 @@ module.exports = function(
|
|||||||
*/
|
*/
|
||||||
this.toggleDrive = (drive) => {
|
this.toggleDrive = (drive) => {
|
||||||
|
|
||||||
AnalyticsService.logEvent('Toggle drive', {
|
analytics.logEvent('Toggle drive', {
|
||||||
drive,
|
drive,
|
||||||
previouslySelected: SelectionStateModel.isCurrentDrive(drive.device)
|
previouslySelected: SelectionStateModel.isCurrentDrive(drive.device)
|
||||||
});
|
});
|
||||||
@ -164,7 +164,7 @@ module.exports = function(
|
|||||||
if (canChangeDriveSelectionState) {
|
if (canChangeDriveSelectionState) {
|
||||||
SelectionStateModel.setDrive(drive.device);
|
SelectionStateModel.setDrive(drive.device);
|
||||||
|
|
||||||
AnalyticsService.logEvent('Drive selected (double click)');
|
analytics.logEvent('Drive selected (double click)');
|
||||||
|
|
||||||
this.closeModal();
|
this.closeModal();
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,7 @@ const DriveSelector = angular.module(MODULE_NAME, [
|
|||||||
require('../warning-modal/warning-modal'),
|
require('../warning-modal/warning-modal'),
|
||||||
require('../../models/drives'),
|
require('../../models/drives'),
|
||||||
require('../../models/selection-state'),
|
require('../../models/selection-state'),
|
||||||
require('../../utils/byte-size/byte-size'),
|
require('../../utils/byte-size/byte-size')
|
||||||
require('../../modules/analytics')
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
DriveSelector.controller('DriveSelectorController', require('./controllers/drive-selector'));
|
DriveSelector.controller('DriveSelectorController', require('./controllers/drive-selector'));
|
||||||
|
@ -24,8 +24,7 @@ const angular = require('angular');
|
|||||||
const MODULE_NAME = 'Etcher.Components.FlashErrorModal';
|
const MODULE_NAME = 'Etcher.Components.FlashErrorModal';
|
||||||
const FlashErrorModal = angular.module(MODULE_NAME, [
|
const FlashErrorModal = angular.module(MODULE_NAME, [
|
||||||
require('../warning-modal/warning-modal'),
|
require('../warning-modal/warning-modal'),
|
||||||
require('../../models/selection-state'),
|
require('../../models/selection-state')
|
||||||
require('../../modules/analytics')
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
FlashErrorModal.service('FlashErrorModalService', require('./services/flash-error-modal'));
|
FlashErrorModal.service('FlashErrorModalService', require('./services/flash-error-modal'));
|
||||||
|
@ -17,8 +17,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const flashState = require('../../../models/flash-state');
|
const flashState = require('../../../models/flash-state');
|
||||||
|
const analytics = require('../../../modules/analytics');
|
||||||
|
|
||||||
module.exports = function(WarningModalService, SelectionStateModel, AnalyticsService) {
|
module.exports = function(WarningModalService, SelectionStateModel) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Open the flash error modal
|
* @summary Open the flash error modal
|
||||||
@ -39,7 +40,7 @@ module.exports = function(WarningModalService, SelectionStateModel, AnalyticsSer
|
|||||||
flashState.resetState();
|
flashState.resetState();
|
||||||
|
|
||||||
if (confirmed) {
|
if (confirmed) {
|
||||||
AnalyticsService.logEvent('Restart after failure');
|
analytics.logEvent('Restart after failure');
|
||||||
} else {
|
} else {
|
||||||
SelectionStateModel.clear();
|
SelectionStateModel.clear();
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,7 @@
|
|||||||
const angular = require('angular');
|
const angular = require('angular');
|
||||||
const MODULE_NAME = 'Etcher.Components.Modal';
|
const MODULE_NAME = 'Etcher.Components.Modal';
|
||||||
const Modal = angular.module(MODULE_NAME, [
|
const Modal = angular.module(MODULE_NAME, [
|
||||||
require('angular-ui-bootstrap'),
|
require('angular-ui-bootstrap')
|
||||||
require('../../modules/analytics')
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Modal.service('ModalService', require('./services/modal'));
|
Modal.service('ModalService', require('./services/modal'));
|
||||||
|
@ -17,8 +17,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
const analytics = require('../../../modules/analytics');
|
||||||
|
|
||||||
module.exports = function($uibModal, $q, AnalyticsService) {
|
module.exports = function($uibModal, $q) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Open a modal
|
* @summary Open a modal
|
||||||
@ -44,7 +45,7 @@ module.exports = function($uibModal, $q, AnalyticsService) {
|
|||||||
size: 'sm'
|
size: 'sm'
|
||||||
});
|
});
|
||||||
|
|
||||||
AnalyticsService.logEvent('Open modal', {
|
analytics.logEvent('Open modal', {
|
||||||
template: options.template
|
template: options.template
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ module.exports = function($uibModal, $q, AnalyticsService) {
|
|||||||
close: modal.close,
|
close: modal.close,
|
||||||
result: $q((resolve, reject) => {
|
result: $q((resolve, reject) => {
|
||||||
modal.result.then((value) => {
|
modal.result.then((value) => {
|
||||||
AnalyticsService.logEvent('Modal accepted', {
|
analytics.logEvent('Modal accepted', {
|
||||||
value
|
value
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -69,14 +70,14 @@ module.exports = function($uibModal, $q, AnalyticsService) {
|
|||||||
|
|
||||||
// Bootstrap doesn't 'resolve' these but cancels the dialog
|
// Bootstrap doesn't 'resolve' these but cancels the dialog
|
||||||
if (error === 'escape key press' || error === 'backdrop click') {
|
if (error === 'escape key press' || error === 'backdrop click') {
|
||||||
AnalyticsService.logEvent('Modal rejected', {
|
analytics.logEvent('Modal rejected', {
|
||||||
method: error
|
method: error
|
||||||
});
|
});
|
||||||
|
|
||||||
return resolve();
|
return resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
AnalyticsService.logEvent('Modal rejected', {
|
analytics.logEvent('Modal rejected', {
|
||||||
value: error
|
value: error
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -17,8 +17,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const settings = require('../../../models/settings');
|
const settings = require('../../../models/settings');
|
||||||
|
const analytics = require('../../../modules/analytics');
|
||||||
|
|
||||||
module.exports = function($uibModalInstance, AnalyticsService, UPDATE_NOTIFIER_SLEEP_DAYS, options) {
|
module.exports = function($uibModalInstance, UPDATE_NOTIFIER_SLEEP_DAYS, options) {
|
||||||
|
|
||||||
// We update this value in this controller since its the only place
|
// We update this value in this controller since its the only place
|
||||||
// where we can be sure the modal was really presented to the user.
|
// where we can be sure the modal was really presented to the user.
|
||||||
@ -58,7 +59,7 @@ module.exports = function($uibModalInstance, AnalyticsService, UPDATE_NOTIFIER_S
|
|||||||
* UpdateNotifierController.closeModal();
|
* UpdateNotifierController.closeModal();
|
||||||
*/
|
*/
|
||||||
this.closeModal = () => {
|
this.closeModal = () => {
|
||||||
AnalyticsService.logEvent('Close update modal', {
|
analytics.logEvent('Close update modal', {
|
||||||
sleepUpdateCheck: this.sleepUpdateCheck,
|
sleepUpdateCheck: this.sleepUpdateCheck,
|
||||||
notifyVersion: options.version
|
notifyVersion: options.version
|
||||||
});
|
});
|
||||||
|
@ -24,8 +24,7 @@ const angular = require('angular');
|
|||||||
const MODULE_NAME = 'Etcher.Components.UpdateNotifier';
|
const MODULE_NAME = 'Etcher.Components.UpdateNotifier';
|
||||||
const UpdateNotifier = angular.module(MODULE_NAME, [
|
const UpdateNotifier = angular.module(MODULE_NAME, [
|
||||||
require('../modal/modal'),
|
require('../modal/modal'),
|
||||||
require('../../os/open-external/open-external'),
|
require('../../os/open-external/open-external')
|
||||||
require('../../modules/analytics')
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,21 +16,12 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/**
|
|
||||||
* @module Etcher.Modules.Analytics
|
|
||||||
*/
|
|
||||||
|
|
||||||
const angular = require('angular');
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const resinCorvus = require('resin-corvus/browser');
|
const resinCorvus = require('resin-corvus/browser');
|
||||||
const packageJSON = require('../../../package.json');
|
const packageJSON = require('../../../package.json');
|
||||||
const settings = require('../models/settings');
|
const settings = require('../models/settings');
|
||||||
|
|
||||||
const MODULE_NAME = 'Etcher.Modules.Analytics';
|
resinCorvus.install({
|
||||||
const analytics = angular.module(MODULE_NAME, []);
|
|
||||||
|
|
||||||
analytics.run(() => {
|
|
||||||
resinCorvus.install({
|
|
||||||
services: {
|
services: {
|
||||||
sentry: _.get(packageJSON, [ 'analytics', 'sentry', 'token' ]),
|
sentry: _.get(packageJSON, [ 'analytics', 'sentry', 'token' ]),
|
||||||
mixpanel: _.get(packageJSON, [ 'analytics', 'mixpanel', 'token' ])
|
mixpanel: _.get(packageJSON, [ 'analytics', 'mixpanel', 'token' ])
|
||||||
@ -41,12 +32,9 @@ analytics.run(() => {
|
|||||||
return settings.get('errorReporting');
|
return settings.get('errorReporting');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
analytics.service('AnalyticsService', function() {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @summary Log a debug message
|
* @summary Log a debug message
|
||||||
* @function
|
* @function
|
||||||
* @public
|
* @public
|
||||||
@ -57,11 +45,11 @@ analytics.service('AnalyticsService', function() {
|
|||||||
* @param {String} message - message
|
* @param {String} message - message
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* AnalyticsService.log('Hello World');
|
* analytics.log('Hello World');
|
||||||
*/
|
*/
|
||||||
this.logDebug = resinCorvus.logDebug;
|
exports.logDebug = resinCorvus.logDebug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Log an event
|
* @summary Log an event
|
||||||
* @function
|
* @function
|
||||||
* @public
|
* @public
|
||||||
@ -73,13 +61,13 @@ analytics.service('AnalyticsService', function() {
|
|||||||
* @param {Object} [data] - event data
|
* @param {Object} [data] - event data
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* AnalyticsService.logEvent('Select image', {
|
* analytics.logEvent('Select image', {
|
||||||
* image: '/dev/disk2'
|
* image: '/dev/disk2'
|
||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
this.logEvent = resinCorvus.logEvent;
|
exports.logEvent = resinCorvus.logEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Log an exception
|
* @summary Log an exception
|
||||||
* @function
|
* @function
|
||||||
* @public
|
* @public
|
||||||
@ -90,10 +78,6 @@ analytics.service('AnalyticsService', function() {
|
|||||||
* @param {Error} exception - exception
|
* @param {Error} exception - exception
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* AnalyticsService.logException(new Error('Something happened'));
|
* analytics.logException(new Error('Something happened'));
|
||||||
*/
|
*/
|
||||||
this.logException = resinCorvus.logException;
|
exports.logException = resinCorvus.logException;
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = MODULE_NAME;
|
|
||||||
|
@ -22,14 +22,14 @@
|
|||||||
|
|
||||||
const angular = require('angular');
|
const angular = require('angular');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
const analytics = require('../modules/analytics');
|
||||||
|
|
||||||
const MODULE_NAME = 'Etcher.Modules.Error';
|
const MODULE_NAME = 'Etcher.Modules.Error';
|
||||||
const error = angular.module(MODULE_NAME, [
|
const error = angular.module(MODULE_NAME, [
|
||||||
require('../modules/analytics'),
|
|
||||||
require('../os/dialog/dialog')
|
require('../os/dialog/dialog')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
error.service('ErrorService', function(AnalyticsService, OSDialogService) {
|
error.service('ErrorService', function(OSDialogService) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Report an exception
|
* @summary Report an exception
|
||||||
@ -47,7 +47,7 @@ error.service('ErrorService', function(AnalyticsService, OSDialogService) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OSDialogService.showError(exception);
|
OSDialogService.showError(exception);
|
||||||
AnalyticsService.logException(exception);
|
analytics.logException(exception);
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -26,13 +26,12 @@ const childWriter = require('../../child-writer');
|
|||||||
const settings = require('../models/settings');
|
const settings = require('../models/settings');
|
||||||
const flashState = require('../models/flash-state');
|
const flashState = require('../models/flash-state');
|
||||||
const windowProgress = require('../os/window-progress');
|
const windowProgress = require('../os/window-progress');
|
||||||
|
const analytics = require('../modules/analytics');
|
||||||
|
|
||||||
const MODULE_NAME = 'Etcher.Modules.ImageWriter';
|
const MODULE_NAME = 'Etcher.Modules.ImageWriter';
|
||||||
const imageWriter = angular.module(MODULE_NAME, [
|
const imageWriter = angular.module(MODULE_NAME, []);
|
||||||
require('./analytics')
|
|
||||||
]);
|
|
||||||
|
|
||||||
imageWriter.service('ImageWriterService', function($q, $rootScope, AnalyticsService) {
|
imageWriter.service('ImageWriterService', function($q, $rootScope) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Perform write operation
|
* @summary Perform write operation
|
||||||
@ -102,7 +101,7 @@ imageWriter.service('ImageWriterService', function($q, $rootScope, AnalyticsServ
|
|||||||
validateWriteOnSuccess: settings.get('validateWriteOnSuccess')
|
validateWriteOnSuccess: settings.get('validateWriteOnSuccess')
|
||||||
};
|
};
|
||||||
|
|
||||||
AnalyticsService.logEvent('Flash', analyticsData);
|
analytics.logEvent('Flash', analyticsData);
|
||||||
|
|
||||||
return this.performWrite(image, drive, (state) => {
|
return this.performWrite(image, drive, (state) => {
|
||||||
|
|
||||||
@ -116,9 +115,9 @@ imageWriter.service('ImageWriterService', function($q, $rootScope, AnalyticsServ
|
|||||||
|
|
||||||
}).then(flashState.unsetFlashingFlag).then(() => {
|
}).then(flashState.unsetFlashingFlag).then(() => {
|
||||||
if (flashState.wasLastFlashCancelled()) {
|
if (flashState.wasLastFlashCancelled()) {
|
||||||
AnalyticsService.logEvent('Elevation cancelled', analyticsData);
|
analytics.logEvent('Elevation cancelled', analyticsData);
|
||||||
} else {
|
} else {
|
||||||
AnalyticsService.logEvent('Done', analyticsData);
|
analytics.logEvent('Done', analyticsData);
|
||||||
}
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
flashState.unsetFlashingFlag({
|
flashState.unsetFlashingFlag({
|
||||||
@ -126,15 +125,15 @@ imageWriter.service('ImageWriterService', function($q, $rootScope, AnalyticsServ
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (error.code === 'EVALIDATION') {
|
if (error.code === 'EVALIDATION') {
|
||||||
AnalyticsService.logEvent('Validation error', analyticsData);
|
analytics.logEvent('Validation error', analyticsData);
|
||||||
} else if (error.code === 'EUNPLUGGED') {
|
} else if (error.code === 'EUNPLUGGED') {
|
||||||
AnalyticsService.logEvent('Drive unplugged', analyticsData);
|
analytics.logEvent('Drive unplugged', analyticsData);
|
||||||
} else if (error.code === 'EIO') {
|
} else if (error.code === 'EIO') {
|
||||||
AnalyticsService.logEvent('Input/output error', analyticsData);
|
analytics.logEvent('Input/output error', analyticsData);
|
||||||
} else if (error.code === 'ENOSPC') {
|
} else if (error.code === 'ENOSPC') {
|
||||||
AnalyticsService.logEvent('Out of space', analyticsData);
|
analytics.logEvent('Out of space', analyticsData);
|
||||||
} else {
|
} else {
|
||||||
AnalyticsService.logEvent('Flash error', _.merge({
|
analytics.logEvent('Flash error', _.merge({
|
||||||
error
|
error
|
||||||
}, analyticsData));
|
}, analyticsData));
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,7 @@ const angular = require('angular');
|
|||||||
const url = require('url');
|
const url = require('url');
|
||||||
|
|
||||||
const MODULE_NAME = 'Etcher.OS.OpenExternal';
|
const MODULE_NAME = 'Etcher.OS.OpenExternal';
|
||||||
const OSOpenExternal = angular.module(MODULE_NAME, [
|
const OSOpenExternal = angular.module(MODULE_NAME, []);
|
||||||
require('../../modules/analytics')
|
|
||||||
]);
|
|
||||||
OSOpenExternal.service('OSOpenExternalService', require('./services/open-external'));
|
OSOpenExternal.service('OSOpenExternalService', require('./services/open-external'));
|
||||||
OSOpenExternal.directive('osOpenExternal', require('./directives/open-external'));
|
OSOpenExternal.directive('osOpenExternal', require('./directives/open-external'));
|
||||||
|
|
||||||
|
@ -17,8 +17,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const electron = require('electron');
|
const electron = require('electron');
|
||||||
|
const analytics = require('../../../modules/analytics');
|
||||||
|
|
||||||
module.exports = function(AnalyticsService) {
|
module.exports = function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Open an external resource
|
* @summary Open an external resource
|
||||||
@ -31,7 +32,7 @@ module.exports = function(AnalyticsService) {
|
|||||||
* OSOpenExternalService.open('https://www.google.com');
|
* OSOpenExternalService.open('https://www.google.com');
|
||||||
*/
|
*/
|
||||||
this.open = (url) => {
|
this.open = (url) => {
|
||||||
AnalyticsService.logEvent('Open external link', {
|
analytics.logEvent('Open external link', {
|
||||||
url
|
url
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -18,8 +18,9 @@
|
|||||||
|
|
||||||
const settings = require('../../../models/settings');
|
const settings = require('../../../models/settings');
|
||||||
const flashState = require('../../../models/flash-state');
|
const flashState = require('../../../models/flash-state');
|
||||||
|
const analytics = require('../../../modules/analytics');
|
||||||
|
|
||||||
module.exports = function($state, SelectionStateModel, AnalyticsService) {
|
module.exports = function($state, SelectionStateModel) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Settings model
|
* @summary Settings model
|
||||||
@ -48,7 +49,7 @@ module.exports = function($state, SelectionStateModel, AnalyticsService) {
|
|||||||
*/
|
*/
|
||||||
this.restart = (options) => {
|
this.restart = (options) => {
|
||||||
SelectionStateModel.clear(options);
|
SelectionStateModel.clear(options);
|
||||||
AnalyticsService.logEvent('Restart', options);
|
analytics.logEvent('Restart', options);
|
||||||
$state.go('main');
|
$state.go('main');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ const angular = require('angular');
|
|||||||
const MODULE_NAME = 'Etcher.Pages.Finish';
|
const MODULE_NAME = 'Etcher.Pages.Finish';
|
||||||
const FinishPage = angular.module(MODULE_NAME, [
|
const FinishPage = angular.module(MODULE_NAME, [
|
||||||
require('angular-ui-router'),
|
require('angular-ui-router'),
|
||||||
require('../../modules/analytics'),
|
|
||||||
require('../../models/selection-state')
|
require('../../models/selection-state')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -17,8 +17,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const settings = require('../../../models/settings');
|
const settings = require('../../../models/settings');
|
||||||
|
const analytics = require('../../../modules/analytics');
|
||||||
|
|
||||||
module.exports = function(SelectionStateModel, AnalyticsService, ErrorService, DriveSelectorService) {
|
module.exports = function(SelectionStateModel, ErrorService, DriveSelectorService) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Open drive selector
|
* @summary Open drive selector
|
||||||
@ -36,7 +37,7 @@ module.exports = function(SelectionStateModel, AnalyticsService, ErrorService, D
|
|||||||
|
|
||||||
SelectionStateModel.setDrive(drive.device);
|
SelectionStateModel.setDrive(drive.device);
|
||||||
|
|
||||||
AnalyticsService.logEvent('Select drive', {
|
analytics.logEvent('Select drive', {
|
||||||
device: drive.device,
|
device: drive.device,
|
||||||
unsafeMode: settings.get('unsafeMode')
|
unsafeMode: settings.get('unsafeMode')
|
||||||
});
|
});
|
||||||
@ -53,7 +54,7 @@ module.exports = function(SelectionStateModel, AnalyticsService, ErrorService, D
|
|||||||
*/
|
*/
|
||||||
this.reselectDrive = () => {
|
this.reselectDrive = () => {
|
||||||
this.openDriveSelector();
|
this.openDriveSelector();
|
||||||
AnalyticsService.logEvent('Reselect drive');
|
analytics.logEvent('Reselect drive');
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -23,10 +23,10 @@ const messages = require('../../../../shared/messages');
|
|||||||
const errors = require('../../../../shared/errors');
|
const errors = require('../../../../shared/errors');
|
||||||
const imageStream = require('../../../../image-stream');
|
const imageStream = require('../../../../image-stream');
|
||||||
const supportedFormats = require('../../../../shared/supported-formats');
|
const supportedFormats = require('../../../../shared/supported-formats');
|
||||||
|
const analytics = require('../../../modules/analytics');
|
||||||
|
|
||||||
module.exports = function(
|
module.exports = function(
|
||||||
SelectionStateModel,
|
SelectionStateModel,
|
||||||
AnalyticsService,
|
|
||||||
ErrorService,
|
ErrorService,
|
||||||
OSDialogService,
|
OSDialogService,
|
||||||
WarningModalService
|
WarningModalService
|
||||||
@ -76,7 +76,7 @@ module.exports = function(
|
|||||||
});
|
});
|
||||||
|
|
||||||
OSDialogService.showError(invalidImageError);
|
OSDialogService.showError(invalidImageError);
|
||||||
AnalyticsService.logEvent('Invalid image', image);
|
analytics.logEvent('Invalid image', image);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ module.exports = function(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AnalyticsService.logEvent('Possibly Windows image', image);
|
analytics.logEvent('Possibly Windows image', image);
|
||||||
|
|
||||||
// TODO: `Continue` should be on a red background (dangerous action) instead of `Change`.
|
// TODO: `Continue` should be on a red background (dangerous action) instead of `Change`.
|
||||||
// We want `X` to act as `Continue`, that's why `Continue` is the `rejectionLabel`
|
// We want `X` to act as `Continue`, that's why `Continue` is the `rejectionLabel`
|
||||||
@ -107,7 +107,7 @@ module.exports = function(
|
|||||||
image.logo = Boolean(image.logo);
|
image.logo = Boolean(image.logo);
|
||||||
image.bmap = Boolean(image.bmap);
|
image.bmap = Boolean(image.bmap);
|
||||||
|
|
||||||
return AnalyticsService.logEvent('Select image', image);
|
return analytics.logEvent('Select image', image);
|
||||||
}).catch(ErrorService.reportException);
|
}).catch(ErrorService.reportException);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -136,14 +136,14 @@ module.exports = function(
|
|||||||
* ImageSelectionController.openImageSelector();
|
* ImageSelectionController.openImageSelector();
|
||||||
*/
|
*/
|
||||||
this.openImageSelector = () => {
|
this.openImageSelector = () => {
|
||||||
AnalyticsService.logEvent('Open image selector');
|
analytics.logEvent('Open image selector');
|
||||||
|
|
||||||
OSDialogService.selectImage().then((imagePath) => {
|
OSDialogService.selectImage().then((imagePath) => {
|
||||||
|
|
||||||
// Avoid analytics and selection state changes
|
// Avoid analytics and selection state changes
|
||||||
// if no file was resolved from the dialog.
|
// if no file was resolved from the dialog.
|
||||||
if (!imagePath) {
|
if (!imagePath) {
|
||||||
AnalyticsService.logEvent('Image selector closed');
|
analytics.logEvent('Image selector closed');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ module.exports = function(
|
|||||||
* ImageSelectionController.reselectImage();
|
* ImageSelectionController.reselectImage();
|
||||||
*/
|
*/
|
||||||
this.reselectImage = () => {
|
this.reselectImage = () => {
|
||||||
AnalyticsService.logEvent('Reselect image', {
|
analytics.logEvent('Reselect image', {
|
||||||
previousImage: SelectionStateModel.getImage()
|
previousImage: SelectionStateModel.getImage()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -18,14 +18,14 @@
|
|||||||
|
|
||||||
const settings = require('../../../models/settings');
|
const settings = require('../../../models/settings');
|
||||||
const flashState = require('../../../models/flash-state');
|
const flashState = require('../../../models/flash-state');
|
||||||
|
const analytics = require('../../../modules/analytics');
|
||||||
|
|
||||||
module.exports = function(
|
module.exports = function(
|
||||||
SelectionStateModel,
|
SelectionStateModel,
|
||||||
DrivesModel,
|
DrivesModel,
|
||||||
TooltipModalService,
|
TooltipModalService,
|
||||||
ErrorService,
|
ErrorService,
|
||||||
OSOpenExternalService,
|
OSOpenExternalService
|
||||||
AnalyticsService
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// Expose several modules to the template for convenience
|
// Expose several modules to the template for convenience
|
||||||
@ -78,7 +78,7 @@ module.exports = function(
|
|||||||
* MainController.showSelectedImageDetails()
|
* MainController.showSelectedImageDetails()
|
||||||
*/
|
*/
|
||||||
this.showSelectedImageDetails = () => {
|
this.showSelectedImageDetails = () => {
|
||||||
AnalyticsService.logEvent('Show selected image tooltip', {
|
analytics.logEvent('Show selected image tooltip', {
|
||||||
imagePath: SelectionStateModel.getImagePath()
|
imagePath: SelectionStateModel.getImagePath()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -45,7 +45,6 @@ const MainPage = angular.module(MODULE_NAME, [
|
|||||||
|
|
||||||
require('../../modules/drive-scanner'),
|
require('../../modules/drive-scanner'),
|
||||||
require('../../modules/image-writer'),
|
require('../../modules/image-writer'),
|
||||||
require('../../modules/analytics'),
|
|
||||||
require('../../modules/error'),
|
require('../../modules/error'),
|
||||||
require('../../models/selection-state'),
|
require('../../models/selection-state'),
|
||||||
require('../../models/drives'),
|
require('../../models/drives'),
|
||||||
|
@ -19,8 +19,9 @@
|
|||||||
const os = require('os');
|
const os = require('os');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const settings = require('../../../models/settings');
|
const settings = require('../../../models/settings');
|
||||||
|
const analytics = require('../../../modules/analytics');
|
||||||
|
|
||||||
module.exports = function(WarningModalService, ErrorService, AnalyticsService) {
|
module.exports = function(WarningModalService, ErrorService) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Client platform
|
* @summary Client platform
|
||||||
@ -81,7 +82,7 @@ module.exports = function(WarningModalService, ErrorService, AnalyticsService) {
|
|||||||
const value = this.currentData[setting];
|
const value = this.currentData[setting];
|
||||||
const dangerous = !_.isUndefined(options);
|
const dangerous = !_.isUndefined(options);
|
||||||
|
|
||||||
AnalyticsService.logEvent('Toggle setting', {
|
analytics.logEvent('Toggle setting', {
|
||||||
setting,
|
setting,
|
||||||
value,
|
value,
|
||||||
dangerous
|
dangerous
|
||||||
|
@ -25,8 +25,7 @@ const MODULE_NAME = 'Etcher.Pages.Settings';
|
|||||||
const SettingsPage = angular.module(MODULE_NAME, [
|
const SettingsPage = angular.module(MODULE_NAME, [
|
||||||
require('angular-ui-router'),
|
require('angular-ui-router'),
|
||||||
require('../../components/warning-modal/warning-modal'),
|
require('../../components/warning-modal/warning-modal'),
|
||||||
require('../../modules/error'),
|
require('../../modules/error')
|
||||||
require('../../modules/analytics')
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
SettingsPage.controller('SettingsController', require('./controllers/settings'));
|
SettingsPage.controller('SettingsController', require('./controllers/settings'));
|
||||||
|
@ -20,7 +20,6 @@ describe('Browser: DriveSelector', function() {
|
|||||||
let DrivesModel;
|
let DrivesModel;
|
||||||
let SelectionStateModel;
|
let SelectionStateModel;
|
||||||
let WarningModalService;
|
let WarningModalService;
|
||||||
let AnalyticsService;
|
|
||||||
|
|
||||||
let controller;
|
let controller;
|
||||||
|
|
||||||
@ -29,8 +28,7 @@ describe('Browser: DriveSelector', function() {
|
|||||||
_$rootScope_,
|
_$rootScope_,
|
||||||
_$q_,
|
_$q_,
|
||||||
_DrivesModel_, _SelectionStateModel_,
|
_DrivesModel_, _SelectionStateModel_,
|
||||||
_WarningModalService_,
|
_WarningModalService_
|
||||||
_AnalyticsService_
|
|
||||||
) {
|
) {
|
||||||
$controller = _$controller_;
|
$controller = _$controller_;
|
||||||
$rootScope = _$rootScope_;
|
$rootScope = _$rootScope_;
|
||||||
@ -39,7 +37,6 @@ describe('Browser: DriveSelector', function() {
|
|||||||
DrivesModel = _DrivesModel_;
|
DrivesModel = _DrivesModel_;
|
||||||
SelectionStateModel = _SelectionStateModel_;
|
SelectionStateModel = _SelectionStateModel_;
|
||||||
WarningModalService = _WarningModalService_;
|
WarningModalService = _WarningModalService_;
|
||||||
AnalyticsService = _AnalyticsService_;
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -49,8 +46,7 @@ describe('Browser: DriveSelector', function() {
|
|||||||
$uibModalInstance,
|
$uibModalInstance,
|
||||||
DrivesModel,
|
DrivesModel,
|
||||||
SelectionStateModel,
|
SelectionStateModel,
|
||||||
WarningModalService,
|
WarningModalService
|
||||||
AnalyticsService
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user