diff --git a/lib/browser/app.js b/lib/browser/app.js index 7ea28088..e74106ff 100644 --- a/lib/browser/app.js +++ b/lib/browser/app.js @@ -27,6 +27,7 @@ const shell = electron.remote.require('shell'); const dialog = electron.remote.require('./src/dialog'); require('angular-ui-bootstrap'); +require('./browser/modules/track'); require('./browser/modules/selection-state'); require('./browser/modules/drive-scanner'); require('./browser/modules/image-writer'); @@ -34,6 +35,7 @@ require('./browser/modules/path'); const app = angular.module('ResinEtcher', [ 'ui.bootstrap', + 'TrackJS', // Resin Etcher modules 'ResinEtcher.path', @@ -42,31 +44,6 @@ const app = angular.module('ResinEtcher', [ '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) { let self = this; this.selection = SelectionStateService; diff --git a/lib/browser/modules/track.js b/lib/browser/modules/track.js new file mode 100644 index 00000000..515d5501 --- /dev/null +++ b/lib/browser/modules/track.js @@ -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; + }); +});