mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-23 19:26:33 +00:00
Move TrackJS integration to a separate Angular module
This commit is contained in:
parent
d5f3b59fb4
commit
fd86807f86
@ -27,6 +27,7 @@ const shell = electron.remote.require('shell');
|
|||||||
const dialog = electron.remote.require('./src/dialog');
|
const dialog = electron.remote.require('./src/dialog');
|
||||||
|
|
||||||
require('angular-ui-bootstrap');
|
require('angular-ui-bootstrap');
|
||||||
|
require('./browser/modules/track');
|
||||||
require('./browser/modules/selection-state');
|
require('./browser/modules/selection-state');
|
||||||
require('./browser/modules/drive-scanner');
|
require('./browser/modules/drive-scanner');
|
||||||
require('./browser/modules/image-writer');
|
require('./browser/modules/image-writer');
|
||||||
@ -34,6 +35,7 @@ require('./browser/modules/path');
|
|||||||
|
|
||||||
const app = angular.module('ResinEtcher', [
|
const app = angular.module('ResinEtcher', [
|
||||||
'ui.bootstrap',
|
'ui.bootstrap',
|
||||||
|
'TrackJS',
|
||||||
|
|
||||||
// Resin Etcher modules
|
// Resin Etcher modules
|
||||||
'ResinEtcher.path',
|
'ResinEtcher.path',
|
||||||
@ -42,31 +44,6 @@ const app = angular.module('ResinEtcher', [
|
|||||||
'ResinEtcher.image-writer'
|
'ResinEtcher.image-writer'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// TrackJS integration
|
|
||||||
// http://docs.trackjs.com/tracker/framework-integrations
|
|
||||||
app.config(function($provide) {
|
|
||||||
$provide.decorator('$exceptionHandler', function($delegate, $window) {
|
|
||||||
return function(exception, cause) {
|
|
||||||
$window.trackJs.track(exception);
|
|
||||||
$delegate(exception, cause);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
$provide.decorator('$log', function($delegate, $window) {
|
|
||||||
|
|
||||||
// Save the original $log.debug()
|
|
||||||
let debugFn = $delegate.debug;
|
|
||||||
|
|
||||||
$delegate.debug = function(message) {
|
|
||||||
message = new Date() + ' ' + message;
|
|
||||||
$window.trackJs.console.debug(message);
|
|
||||||
debugFn.call(null, message);
|
|
||||||
};
|
|
||||||
|
|
||||||
return $delegate;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
app.controller('AppController', function($q, $log, DriveScannerService, SelectionStateService, ImageWriterService) {
|
app.controller('AppController', function($q, $log, DriveScannerService, SelectionStateService, ImageWriterService) {
|
||||||
let self = this;
|
let self = this;
|
||||||
this.selection = SelectionStateService;
|
this.selection = SelectionStateService;
|
||||||
|
49
lib/browser/modules/track.js
Normal file
49
lib/browser/modules/track.js
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Resin.io
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @module TrackJS
|
||||||
|
*/
|
||||||
|
|
||||||
|
const angular = require('angular');
|
||||||
|
const track = angular.module('TrackJS', []);
|
||||||
|
|
||||||
|
// TrackJS integration
|
||||||
|
// http://docs.trackjs.com/tracker/framework-integrations
|
||||||
|
track.config(function($provide) {
|
||||||
|
$provide.decorator('$exceptionHandler', function($delegate, $window) {
|
||||||
|
return function(exception, cause) {
|
||||||
|
$window.trackJs.track(exception);
|
||||||
|
$delegate(exception, cause);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
$provide.decorator('$log', function($delegate, $window) {
|
||||||
|
|
||||||
|
// Save the original $log.debug()
|
||||||
|
let debugFn = $delegate.debug;
|
||||||
|
|
||||||
|
$delegate.debug = function(message) {
|
||||||
|
message = new Date() + ' ' + message;
|
||||||
|
$window.trackJs.console.debug(message);
|
||||||
|
debugFn.call(null, message);
|
||||||
|
};
|
||||||
|
|
||||||
|
return $delegate;
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user