From 1d75ec02aa6cfdab85cdeb7a16a3aa01f2037384 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 29 Feb 2016 15:54:21 -0400 Subject: [PATCH] Include TrackJS Angular module in Analytics module --- lib/browser/app.js | 2 -- lib/browser/modules/analytics.js | 25 ++++++++++++++++ lib/browser/modules/track.js | 49 -------------------------------- 3 files changed, 25 insertions(+), 51 deletions(-) delete mode 100644 lib/browser/modules/track.js diff --git a/lib/browser/app.js b/lib/browser/app.js index c0367379..4247ab60 100644 --- a/lib/browser/app.js +++ b/lib/browser/app.js @@ -29,7 +29,6 @@ const BrowserWindow = electron.remote.BrowserWindow; const currentWindow = BrowserWindow.fromId(1); require('angular-ui-bootstrap'); -require('./browser/modules/track'); require('./browser/modules/selection-state'); require('./browser/modules/drive-scanner'); require('./browser/modules/image-writer'); @@ -38,7 +37,6 @@ require('./browser/modules/analytics'); const app = angular.module('Etcher', [ 'ui.bootstrap', - 'TrackJS', // Etcher modules 'Etcher.path', diff --git a/lib/browser/modules/analytics.js b/lib/browser/modules/analytics.js index f900cf40..4de40a77 100644 --- a/lib/browser/modules/analytics.js +++ b/lib/browser/modules/analytics.js @@ -45,6 +45,31 @@ analytics.config(function($mixpanelProvider) { }); }); +// TrackJS integration +// http://docs.trackjs.com/tracker/framework-integrations +analytics.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; + }); +}); + analytics.service('AnalyticsService', function($log, $mixpanel) { /** diff --git a/lib/browser/modules/track.js b/lib/browser/modules/track.js deleted file mode 100644 index 515d5501..00000000 --- a/lib/browser/modules/track.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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; - }); -});