Merge pull request #134 from resin-io/refactor/track

Move TrackJS integration to a separate Angular module
This commit is contained in:
Juan Cruz Viotti 2016-01-26 12:04:13 -04:00
commit 826710950d
2 changed files with 51 additions and 25 deletions

View File

@ -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;

View 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;
});
});