diff --git a/README.md b/README.md
index 7231d588a0..a19df67acc 100644
--- a/README.md
+++ b/README.md
@@ -54,14 +54,7 @@ For ease of development we have several debug features that developers can turn
The environment variable `DEBUG_ERROR` (boolean) controls whether or not errors sourced in device drivers are caught and an error message displayed in the UI (the production setting) or whether they are thrown in the console (much more useful for local development because then the file name and line number of the error are easily accessible, along with a stack trace). `DEBUG_ERROR` mode is turned on by default in `config/device-debug.sh`.
-#### `REDUX_LOG`
-
-The environment variable `REDUX_LOG` (boolean) controls whether or not the [redux logger middleware](https://github.com/fcomb/redux-logger/blob/master/README.md) is included. This middleware logs all redux actions in the Chrome developer console, including the (entire) previous and following app state trees. It is primarily useful when working on the UI of the app, and in fact can be quite performance-expensive (especially when uploading a device, due to the fact that every update to the progress bar constitutes an action), so it is not recommended to turn it on while working on device code.
-
-
-`REDUX_LOG` is turned on by default in `config/ui-debug.sh`.
-
-As an alternative to using `REDUX_LOG`, the Electron uploader now includes the Redux DevTools. See [DevTools](#devtools) below for more details.
+This can also be toggled internally in the running Electron app via a right-click context menu available on the login screen, much like the menu for switching environments.
### Local Development w/o Debug Mode(s)
diff --git a/app/components/Upload.js b/app/components/Upload.js
index ab96c7f5ad..55352c82e5 100644
--- a/app/components/Upload.js
+++ b/app/components/Upload.js
@@ -15,8 +15,6 @@
* == BSD2 LICENSE ==
*/
-/* global __DEBUG__ */
-
import _ from 'lodash';
import cx from 'classnames';
import React, { Component, PropTypes } from 'react';
@@ -26,6 +24,7 @@ import keytar from 'keytar';
import LoadingBar from './LoadingBar';
import ProgressBar from './ProgressBar';
+import debugMode from '../utils/debugMode';
import styles from '../../styles/components/Upload.module.less';
@@ -562,7 +561,7 @@ export default class Upload extends Component {
if (upload.successful) {
let dataDownloadLink = null;
- if (__DEBUG__ && !_.isEmpty(this.props.upload.data)) {
+ if (debugMode.isDebug && !_.isEmpty(this.props.upload.data)) {
dataDownloadLink = this.getDebugLinks(this.props.upload.data);
}
return
{this.props.text.UPLOAD_COMPLETE} {dataDownloadLink}
;
@@ -570,7 +569,7 @@ export default class Upload extends Component {
if(upload.failed) {
let dataDownloadLink = null;
- if (__DEBUG__ && this.props.upload.error.data) {
+ if (debugMode.isDebug && this.props.upload.error.data) {
dataDownloadLink = this.getDebugLinks(this.props.upload.error.data);
}
return {dataDownloadLink}
;
diff --git a/app/containers/App.js b/app/containers/App.js
index a07d38cfa0..fd22ecd0d2 100644
--- a/app/containers/App.js
+++ b/app/containers/App.js
@@ -22,7 +22,7 @@ import { bindActionCreators } from 'redux';
import { remote } from 'electron';
import * as metrics from '../constants/metrics';
-const {Menu} = remote;
+const { Menu } = remote;
import bows from 'bows';
@@ -39,6 +39,7 @@ const syncActions = actions.sync;
import * as actionSources from '../constants/actionSources';
import { pages, urls, pagesMap } from '../constants/otherConstants';
import { checkVersion } from '../utils/drivers';
+import debugMode from '../utils/debugMode';
import UpdatePlease from '../components/UpdatePlease';
import VersionCheckError from '../components/VersionCheckError';
@@ -49,6 +50,39 @@ import UpdateDriverModal from '../components/UpdateDriverModal';
import styles from '../../styles/components/App.module.less';
+const serverdata = {
+ Local: {
+ API_URL: 'http://localhost:8009',
+ UPLOAD_URL: 'http://localhost:9122',
+ DATA_URL: 'http://localhost:8077',
+ BLIP_URL: 'http://localhost:3000'
+ },
+ Development: {
+ API_URL: 'https://dev-api.tidepool.org',
+ UPLOAD_URL: 'https://dev-uploads.tidepool.org',
+ DATA_URL: 'https://dev-api.tidepool.org/dataservices',
+ BLIP_URL: 'https://dev-blip.tidepool.org'
+ },
+ Staging: {
+ API_URL: 'https://stg-api.tidepool.org',
+ UPLOAD_URL: 'https://stg-uploads.tidepool.org',
+ DATA_URL: 'https://stg-api.tidepool.org/dataservices',
+ BLIP_URL: 'https://stg-blip.tidepool.org'
+ },
+ Integration: {
+ API_URL: 'https://int-api.tidepool.org',
+ UPLOAD_URL: 'https://int-uploads.tidepool.org',
+ DATA_URL: 'https://int-api.tidepool.org/dataservices',
+ BLIP_URL: 'https://int-blip.tidepool.org'
+ },
+ Production: {
+ API_URL: 'https://api.tidepool.org',
+ UPLOAD_URL: 'https://uploads.tidepool.org',
+ DATA_URL: 'https://api.tidepool.org/dataservices',
+ BLIP_URL: 'https://blip.tidepool.org'
+ }
+};
+
export class App extends Component {
static propTypes = {
route: PropTypes.shape({
@@ -62,6 +96,10 @@ export class App extends Component {
this.handleDismissDropdown = this.handleDismissDropdown.bind(this);
this.handleContextMenu = this.handleContextMenu.bind(this);
this.setServer = this.setServer.bind(this);
+ const initial_server = _.findKey(serverdata, (key) => key.API_URL === config.API_URL);
+ this.state = {
+ server: initial_server
+ };
}
componentWillMount(){
@@ -79,42 +117,10 @@ export class App extends Component {
}
setServer(info) {
- var serverdata = {
- Local: {
- API_URL: 'http://localhost:8009',
- UPLOAD_URL: 'http://localhost:9122',
- DATA_URL: 'http://localhost:8077',
- BLIP_URL: 'http://localhost:3000'
- },
- Development: {
- API_URL: 'https://dev-api.tidepool.org',
- UPLOAD_URL: 'https://dev-uploads.tidepool.org',
- DATA_URL: 'https://dev-api.tidepool.org/dataservices',
- BLIP_URL: 'https://dev-blip.tidepool.org'
- },
- Staging: {
- API_URL: 'https://stg-api.tidepool.org',
- UPLOAD_URL: 'https://stg-uploads.tidepool.org',
- DATA_URL: 'https://stg-api.tidepool.org/dataservices',
- BLIP_URL: 'https://stg-blip.tidepool.org'
- },
- Integration: {
- API_URL: 'https://int-api.tidepool.org',
- UPLOAD_URL: 'https://int-uploads.tidepool.org',
- DATA_URL: 'https://int-api.tidepool.org/dataservices',
- BLIP_URL: 'https://int-blip.tidepool.org'
- },
- Production: {
- API_URL: 'https://api.tidepool.org',
- UPLOAD_URL: 'https://uploads.tidepool.org',
- DATA_URL: 'https://api.tidepool.org/dataservices',
- BLIP_URL: 'https://blip.tidepool.org'
- }
- };
-
console.log('will use', info.label, 'server');
var serverinfo = serverdata[info.label];
this.props.route.api.setHosts(serverinfo);
+ this.setState({server: info.label});
}
render() {
@@ -135,7 +141,7 @@ export class App extends Component {
e.preventDefault();
const { clientX, clientY } = e;
let template = [];
- if (process.env.NODE_ENV === 'development' || process.env.BUILD === 'dev' ) {
+ if (process.env.NODE_ENV === 'development') {
template.push({
label: 'Inspect element',
click() {
@@ -152,26 +158,44 @@ export class App extends Component {
submenu: [
{
label: 'Local',
- click: this.setServer
+ click: this.setServer,
+ type: 'radio',
+ checked: this.state.server === 'Local'
},
{
label: 'Development',
- click: this.setServer
+ click: this.setServer,
+ type: 'radio',
+ checked: this.state.server === 'Development'
},
{
label: 'Staging',
- click: this.setServer
+ click: this.setServer,
+ type: 'radio',
+ checked: this.state.server === 'Staging'
},
{
label: 'Integration',
- click: this.setServer
+ click: this.setServer,
+ type: 'radio',
+ checked: this.state.server === 'Integration'
},
{
label: 'Production',
- click: this.setServer
+ click: this.setServer,
+ type: 'radio',
+ checked: this.state.server === 'Production'
}
]
});
+ template.push({
+ label: 'Toggle Debug Mode',
+ type: 'checkbox',
+ checked: debugMode.isDebug,
+ click() {
+ debugMode.setDebug(!debugMode.isDebug);
+ }
+ });
}
const menu = Menu.buildFromTemplate(template);
menu.popup(remote.getCurrentWindow());
diff --git a/app/main.development.js b/app/main.development.js
index a593e069cc..a1033e0d93 100755
--- a/app/main.development.js
+++ b/app/main.development.js
@@ -4,6 +4,7 @@ import open from 'open';
import { autoUpdater } from 'electron-updater';
import * as chromeFinder from 'chrome-launcher/chrome-finder';
import { sync as syncActions } from './actions';
+import debugMode from '../app/utils/debugMode';
let menu;
let template;
@@ -47,7 +48,7 @@ const installExtensions = async () => {
app.on('ready', async () => {
await installExtensions();
- const resizable = (process.env.NODE_ENV === 'development' || process.env.BUILD === 'dev');
+ const resizable = (process.env.NODE_ENV === 'development');
mainWindow = new BrowserWindow({
show: false,
@@ -88,7 +89,7 @@ app.on('ready', async () => {
mainWindow = null;
});
- if (process.env.NODE_ENV === 'development' || process.env.BUILD === 'dev') {
+ if (process.env.NODE_ENV === 'development') {
mainWindow.openDevTools();
mainWindow.webContents.on('context-menu', (e, props) => {
const { x, y } = props;
@@ -167,7 +168,7 @@ app.on('ready', async () => {
}]
}, {
label: 'View',
- submenu: (process.env.NODE_ENV === 'development' || process.env.BUILD === 'dev') ?
+ submenu: (process.env.NODE_ENV === 'development') ?
[
{
label: 'Reload',
@@ -256,7 +257,7 @@ app.on('ready', async () => {
}]
}, {
label: '&View',
- submenu: (process.env.NODE_ENV === 'development' || process.env.BUILD === 'dev') ? [{
+ submenu: (process.env.NODE_ENV === 'development') ? [{
label: '&Reload',
accelerator: 'Ctrl+R',
click() {
@@ -318,10 +319,9 @@ app.on('ready', async () => {
});
function checkUpdates(){
- // in production NODE_ENV or *any* type of BUILD (including BUILD === 'dev')
- // we check for updates, but not if NODE_ENV is 'development' and BUILD is unset
+ // in production NODE_ENV we check for updates, but not if NODE_ENV is 'development'
// this prevents a Webpack build error that masks other build errors during local development
- if (process.env.NODE_ENV === 'production' || process.env.BUILD) {
+ if (process.env.NODE_ENV === 'production') {
autoUpdater.checkForUpdates();
}
}
diff --git a/app/package.json b/app/package.json
index 0b490469e5..765635e676 100755
--- a/app/package.json
+++ b/app/package.json
@@ -1,7 +1,7 @@
{
"name": "tidepool-uploader",
"productName": "tidepool-uploader",
- "version": "2.0.2",
+ "version": "2.0.3",
"description": "Tidepool Project Universal Uploader",
"main": "./main.js",
"author": {
diff --git a/app/store/configureStore.development.js b/app/store/configureStore.development.js
index 50e6f9c0c2..abbe3807e5 100644
--- a/app/store/configureStore.development.js
+++ b/app/store/configureStore.development.js
@@ -1,10 +1,7 @@
-/* global __REDUX_LOG__ */
-
import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import { hashHistory } from 'react-router';
import { routerMiddleware, push } from 'react-router-redux';
-import { createLogger } from 'redux-logger';
import rootReducer from '../reducers';
import { async, sync } from '../actions';
import api from '../../lib/core/api';
@@ -12,7 +9,6 @@ import config from '../../lib/config';
import { createErrorLogger } from '../utils/errors';
import { createMetricsTracker } from '../utils/metrics';
-
api.create({
apiUrl: config.API_URL,
uploadUrl: config.UPLOAD_URL,
@@ -20,25 +16,12 @@ api.create({
version: config.version
});
-const noop = function(middlewareAPI){
- return function(next){
- return function(action){
- return next(action);
- };
- };
-};
-
const actionCreators = {
...async,
...sync,
push,
};
-const logger = __REDUX_LOG__ ? createLogger({
- level: 'info',
- collapsed: true
-}) : noop;
-
const router = routerMiddleware(hashHistory);
// If Redux DevTools Extension is installed use it, otherwise use Redux compose
@@ -54,7 +37,6 @@ const enhancer = composeEnhancers(
applyMiddleware(
thunk,
router,
- logger,
createErrorLogger(api),
createMetricsTracker(api)
)
diff --git a/app/utils/debugMode.js b/app/utils/debugMode.js
new file mode 100644
index 0000000000..e35b1214ca
--- /dev/null
+++ b/app/utils/debugMode.js
@@ -0,0 +1,49 @@
+/*
+ * == BSD2 LICENSE ==
+ * Copyright (c) 2017, Tidepool Project
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the associated License, which is identical to the BSD 2-Clause
+ * License as published by the Open Source Initiative at opensource.org.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the License for more details.
+ *
+ * You should have received a copy of the License along with this program; if
+ * not, you can obtain one from Tidepool Project at tidepool.org.
+ * == BSD2 LICENSE ==
+ */
+
+import { ipcRenderer, ipcMain } from 'electron';
+let isRenderer = (process && process.type === 'renderer');
+
+if (isRenderer) {
+ let isDebug = process.env.DEBUG_ERROR ||
+ JSON.parse(localStorage.getItem('isDebug')) ||
+ false;
+
+ const debugMode = module.exports = {
+ isDebug,
+ setDebug: function(isDebug) {
+ ipcRenderer.send('setDebug', isDebug);
+ localStorage.setItem('isDebug', JSON.stringify(isDebug));
+ debugMode.isDebug = isDebug;
+ return debugMode.isDebug;
+ }
+ };
+} else {
+ let isDebug = process.env.DEBUG_ERROR || false;
+
+ ipcMain.on('setDebug', (event, arg) => {
+ debugMode.isDebug = arg;
+ });
+
+ const debugMode = module.exports = {
+ isDebug,
+ setDebug: function(isDebug) {
+ debugMode.isDebug = isDebug;
+ return debugMode.isDebug;
+ }
+ };
+}
diff --git a/appveyor.yml b/appveyor.yml
index 1205d72592..5a8bd29c83 100755
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -34,9 +34,9 @@ test_script:
- yarn lint
- yarn test
# - yarn test-e2e
- - yarn package-dev
+# - yarn package-dev
# - 7z a development.zip release
- - rmdir /S /Q release
+# - rmdir /S /Q release
- yarn package
# - 7z a production.zip release
diff --git a/circle.yml b/circle.yml
index 5d7bdc3baf..a070f9083b 100644
--- a/circle.yml
+++ b/circle.yml
@@ -19,9 +19,9 @@ test:
- yarn lint
- yarn test
post:
- - yarn package-dev
+# - yarn package-dev
# - zip -r -X development.zip release
- - rm -rf release
+# - rm -rf release
- yarn package
# - zip -r -X production.zip release
diff --git a/lib/core/carelink.js b/lib/core/carelink.js
index d530407d65..e66345d1f5 100644
--- a/lib/core/carelink.js
+++ b/lib/core/carelink.js
@@ -15,10 +15,9 @@
* == BSD2 LICENSE ==
*/
-/* global __DEBUG__ */
-
var _ = require('lodash');
+var debugMode = require('../../app/utils/debugMode');
var driverManager = require('../driverManager');
var pwdSimulator = require('../drivers/carelink/carelinkSimulator.js');
var carelinkDriver = require('../drivers/carelink/carelinkDriver');
@@ -47,7 +46,7 @@ carelink._createDriverManager = function(data, options) {
version: options.version,
groupId: options.targetId
},
- debug: __DEBUG__ || false
+ debug: debugMode.isDebug
};
return driverManager(drivers, configs);
diff --git a/lib/core/device.js b/lib/core/device.js
index f1b4070c46..c464c78993 100644
--- a/lib/core/device.js
+++ b/lib/core/device.js
@@ -15,13 +15,12 @@
* == BSD2 LICENSE ==
*/
-/* global __DEBUG__ */
-
var os = require('os');
var _ = require('lodash');
var async = require('async');
+var debugMode = require('../../app/utils/debugMode');
var serialDevice = require('../serialDevice');
var hidDevice = require('../hidDevice');
var driverManager = require('../driverManager');
@@ -153,7 +152,7 @@ device._createDriverManager = function(driverId, options) {
drivers[driverId] = this._deviceDrivers[driverId];
var configs = {};
configs[driverId] = this._createDriverConfig(driverId, options);
- configs.debug = __DEBUG__ || false;
+ configs.debug = debugMode.isDebug;
return driverManager(drivers, configs);
};
diff --git a/lib/drivers/animas/animasDriver.js b/lib/drivers/animas/animasDriver.js
index 0a9af05d9e..087dd6bdec 100644
--- a/lib/drivers/animas/animasDriver.js
+++ b/lib/drivers/animas/animasDriver.js
@@ -15,13 +15,12 @@
* == BSD2 LICENSE ==
*/
-/* global __DEBUG__ */
-
var _ = require('lodash');
var async = require('async');
var sundial = require('sundial');
var annotate = require('../../eventAnnotations');
var util = require('util');
+var debugMode = require('../../../app/utils/debugMode');
var crcCalculator = require('../../crc.js');
var struct = require('../../struct.js')();
@@ -33,7 +32,7 @@ var animasSimulator = require('./animasSimulator');
var TZOUtil = require('../../TimezoneOffsetUtil');
var debug = require('bows')('AnimasDriver');
-var verbose = (typeof __DEBUG__ === 'undefined') ? false : __DEBUG__;
+var verbose = debugMode.isDebug;
module.exports = function (config) {
var cfg = _.clone(config);
diff --git a/lib/drivers/medtronic/medtronicDriver.js b/lib/drivers/medtronic/medtronicDriver.js
index 5eeb360c92..ad54346f9f 100644
--- a/lib/drivers/medtronic/medtronicDriver.js
+++ b/lib/drivers/medtronic/medtronicDriver.js
@@ -15,8 +15,6 @@
* == BSD2 LICENSE ==
*/
-/* global chrome, __DEBUG__ */
-
var _ = require('lodash');
var async = require('async');
var sundial = require('sundial');
@@ -26,6 +24,7 @@ var proc = require('./processData');
var common = require('../../commonFunctions');
var medtronicSimulator = require('./medtronicSimulator');
var crcCalculator = require('../../crc.js');
+var debugMode = require('../../../app/utils/debugMode');
var isBrowser = typeof window !== 'undefined';
var debug = isBrowser ? require('bows')('MedtronicDriver') : console.log;
@@ -215,7 +214,7 @@ module.exports = function (config) {
ctr += struct.pack(bytes, ctr, 'b', checksum);
ctr += struct.copyBytes(bytes, ctr, payload, payload.length);
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('Sending bytes:', common.bytes2hex(bytes));
}
return buf;
@@ -449,7 +448,7 @@ module.exports = function (config) {
if (bytes_len < packet_len) {
packet_len = bytes_len;
}
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('Packet length:', packet_len);
}
@@ -474,7 +473,7 @@ module.exports = function (config) {
var ctr = struct.pack(bytes, 0, 'bbbb', 0x00, 0x00, 0x00, cmdlength);
ctr += struct.copyBytes(bytes, ctr, command, cmdlength);
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('Sending bytes:', common.bytes2hex(bytes));
}
return {
@@ -509,7 +508,7 @@ module.exports = function (config) {
if (err) {
return cb(err, null);
} else {
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('Record:', record);
}
return cb(null,record);
@@ -531,7 +530,7 @@ module.exports = function (config) {
if (err) {
return cb(err, null);
} else {
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('Record:', record);
}
return cb(null,record);
@@ -597,14 +596,14 @@ module.exports = function (config) {
};
if(decoded.message.length === 2 && decoded.message[0] === ASCII_CONTROL.NAK) {
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('nak received');
}
nak = true;
} else {
page.set(decoded.message, length);
length += decoded.message.length;
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('Part', count, 'of page (length: ', decoded.message.length ,'):', common.bytes2hex(decoded.message));
}
@@ -647,7 +646,7 @@ module.exports = function (config) {
return cb(new Error('Fewer packets received than expected.'));
}
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('Read', count, 'parts per page.');
}
return cb(null, { page : page, nak: nak });
@@ -660,7 +659,7 @@ module.exports = function (config) {
var bcnCommandResponse = function (commandpacket, waitForENQ, howManyPackets, checkNAK, callback) {
hidDevice.send(commandpacket.command, function () {
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('Sent ', common.bytes2hex(commandpacket.command));
}
@@ -704,7 +703,7 @@ module.exports = function (config) {
if(finished) {
// we have finished flushing, this packet should be
// saved for getMessage()
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('Found packet we were still waiting for');
}
rawPacket = raw;
@@ -715,7 +714,7 @@ module.exports = function (config) {
if ( packet.length === 0 ) {
return callback(true);
}
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('Flushing', common.bytes2hex(packet));
}
return callback(false);
@@ -761,7 +760,7 @@ module.exports = function (config) {
return callback(false);
}
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('Raw packet received:', common.bytes2hex(packet));
}
@@ -786,12 +785,12 @@ module.exports = function (config) {
var payloadLength = null;
if(struct.extractByte(header,0) == 0x51 && _.isEqual(struct.extractString(header,2,6), serial)) {
payloadLength = struct.extractInt(packet,32);
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('Payload length:', payloadLength);
}
}
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('Message length:', message.messageLength);
}
@@ -1344,7 +1343,7 @@ module.exports = function (config) {
if(results == null) {
next(null, {valid:false});
}
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('Page', n, 're-read as', results[0]);
}
next(err,results[0]);
diff --git a/lib/drivers/medtronic/medtronicSimulator.js b/lib/drivers/medtronic/medtronicSimulator.js
index 1bc5498fba..7bbd1a5e4d 100644
--- a/lib/drivers/medtronic/medtronicSimulator.js
+++ b/lib/drivers/medtronic/medtronicSimulator.js
@@ -15,7 +15,6 @@
* == BSD2 LICENSE ==
*/
- /* global __DEBUG__ */
var _ = require('lodash');
var sundial = require('sundial');
@@ -26,7 +25,8 @@ var common = require('../../commonFunctions');
var isBrowser = typeof window !== 'undefined';
var debug = isBrowser ? require('bows')('MedtronicDriver') : console.log;
-var __DEBUG__ = __DEBUG__ || true;
+var debugMode = require('../../../app/utils/debugMode');
+var __DEBUG__ = debugMode.isDebug || true;
/**
* Creates a new "simulator" for Medtronic pump data.
diff --git a/lib/drivers/medtronic/processData.js b/lib/drivers/medtronic/processData.js
index 014929bea6..a67643bb82 100644
--- a/lib/drivers/medtronic/processData.js
+++ b/lib/drivers/medtronic/processData.js
@@ -15,8 +15,6 @@
* == BSD2 LICENSE ==
*/
-/* globals chrome, __DEBUG__ */
-
var _ = require('lodash');
var sundial = require('sundial');
@@ -24,10 +22,10 @@ var struct = require('../../struct.js')();
var common = require('../../commonFunctions');
var annotate = require('../../eventAnnotations');
var TZOUtil = require('../../TimezoneOffsetUtil');
+var debugMode = require('../../../app/utils/debugMode');
var isBrowser = typeof window !== 'undefined';
var debug = isBrowser ? require('bows')('MedtronicDriver') : console.log;
-var __DEBUG__ = __DEBUG__ || false;
var RECORD_TYPES = {
BOLUS: { value: 0x01, head_length: 8, name: 'BOLUS'},
@@ -463,7 +461,7 @@ function buildCGMRecords(events) {
var event = events[i];
if (event.jsDate != false) {
- if (__DEBUG__) {
+ if (debugMode.isDebug) {
debug('CGM event:',sundial.formatDeviceTime(event.jsDate), event.type.name, common.bytes2hex([event.head]),common.bytes2hex(event.date),common.bytes2hex(event.body),common.bytes2hex(event.descriptor) );
}
@@ -498,7 +496,7 @@ function buildCGMRecords(events) {
var date = sundial.applyOffset(start, -(recordsSinceTimestamp * 5));
recordsSinceTimestamp += 1;
- if (__DEBUG__) {
+ if (debugMode.isDebug) {
debug('CBG:', sundial.formatDeviceTime(date), common.bytes2hex(struct.extractBytes(event.descriptor, offset * 2, 2)), ',', common.bytes2hex([struct.extractByte(event.body, offset)]), ',', cbg, ',', (descriptor & 0xFFFE) / 100.0);
}
@@ -538,7 +536,7 @@ function buildCGMRecords(events) {
} else {
var type = getType(event.body[offset],CBG_RECORD_TYPES);
if( (descriptor < 20 || descriptor > 200) && type != null) {
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('CBG type:', type.name);
}
recordsSinceTimestamp += 1;
@@ -1311,7 +1309,7 @@ var processPages = function(data, callback) {
index += record.type.body_length;
record.jsDate = decodeDate(record.date);
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug(record.jsDate, record.type.name, common.bytes2hex(record.head),common.bytes2hex(record.date),common.bytes2hex(record.body));
}
@@ -1319,7 +1317,7 @@ var processPages = function(data, callback) {
if(record.jsDate && record.jsDate.valueOf() !== RESET_DATE.valueOf()) {
records.push(record);
} else {
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('Dropping event with incorrect date');
}
}
diff --git a/lib/drivers/tandem/tandemDriver.js b/lib/drivers/tandem/tandemDriver.js
index 0c32ace824..12127cecab 100644
--- a/lib/drivers/tandem/tandemDriver.js
+++ b/lib/drivers/tandem/tandemDriver.js
@@ -15,8 +15,6 @@
* == BSD2 LICENSE ==
*/
-/* globals __DEBUG__ */
-
var _ = require('lodash');
var struct = require('../../struct.js')();
var sundial = require('sundial');
@@ -26,6 +24,7 @@ var tandemSimulatorMaker = require('../tandem/tandemSimulator');
var TZOUtil = require('../../TimezoneOffsetUtil');
var annotate = require('../../eventAnnotations');
var debug = require('bows')('TandemDriver');
+var debugMode = require('../../../app/utils/debugMode');
module.exports = function (config) {
var cfg = config;
@@ -937,7 +936,7 @@ module.exports = function (config) {
};
var tandemLogRequester = function (start, end, progress, callback) {
- if (__DEBUG__) {
+ if (debugMode.isDebug) {
debug('tandemLogRequester', start, end);
var startExec = Date.now();
}
@@ -1003,7 +1002,7 @@ module.exports = function (config) {
debug('received ', receiveSeq, ' of ', end);
}
if (receiveSeq > end) {
- if (__DEBUG__) {
+ if (debugMode.isDebug) {
var endExec = Date.now();
var time = endExec - startExec;
debug('Execution time of tandemLogRequester: ' + time);
@@ -1040,7 +1039,7 @@ module.exports = function (config) {
};
var multiLogRequester = function (start, end, progress, callback) {
- if (__DEBUG__) {
+ if (debugMode.isDebug) {
debug('multiLogRequester', start, end);
var startExec = Date.now();
}
@@ -1096,7 +1095,7 @@ module.exports = function (config) {
debug('received ', receiveSeq, ' of ', end);
}
if (receiveSeq > end) {
- if (__DEBUG__) {
+ if (debugMode.isDebug) {
var endExec = Date.now();
var time = endExec - startExec;
debug('Execution time of multiLogRequester: ' + time);
@@ -1208,7 +1207,7 @@ module.exports = function (config) {
}
if (headerIdFilter.indexOf(pkt.payload.header_id) === -1 || pkt.payload.name === undefined) {
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('skipping record in search for newest: ', pkt.payload ? pkt.payload.name : '', pkt);
}
end_seq--;
@@ -1217,7 +1216,7 @@ module.exports = function (config) {
clearInterval(sendTimer);
clearInterval(listenTimer);
cfg.deviceComms.flush(); // making sure we flush the buffers
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('Found newest event: ',pkt);
}
progress(5);
@@ -1392,7 +1391,7 @@ module.exports = function (config) {
var tandemFetch = function (progress, data, callback) {
- if (__DEBUG__) {
+ if (debugMode.isDebug) {
var startExec = Date.now();
}
debug('getting event ranges');
@@ -1420,7 +1419,7 @@ module.exports = function (config) {
maxIndex = result.payload.header_log_seq_no;
data.end_seq = result.payload.header_log_seq_no;
- if(__DEBUG__) {
+ if(debugMode.isDebug) {
debug('oldest event seq: ', start_seq);
}
minIndex = start_seq;
@@ -1435,7 +1434,7 @@ module.exports = function (config) {
debug('start_seq: ', currentIndex);
data.start_seq = currentIndex;
- if (__DEBUG__) {
+ if (debugMode.isDebug) {
var endExec = Date.now();
var time = endExec - startExec;
debug('Execution time for binary search: ' + time);
@@ -2279,7 +2278,7 @@ module.exports = function (config) {
we only attempt to process and upload the data following
the most recent device shut-down.
*/
- if (!__DEBUG__) {
+ if (!debugMode.isDebug) {
data.log_records = _.takeRightWhile(data.log_records, function(rec) {
if (rec.change_types &&
_.includes(rec.change_types,'pump_shut_down')) {
diff --git a/package.json b/package.json
index ef35168876..ab4ed355c4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "tidepool-uploader",
- "version": "2.0.2",
+ "version": "2.0.3",
"description": "Tidepool Project Universal Uploader",
"private": true,
"main": "main.js",
@@ -19,17 +19,13 @@
"hot-server": "cross-env NODE_ENV=development node --max_old_space_size=2096 -r babel-register server.js",
"build-main": "cross-env NODE_ENV=production node -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.electron.js --progress --profile --colors",
"build-renderer": "cross-env NODE_ENV=production node -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.production.js --progress --profile --colors",
- "build-main-dev": "cross-env BUILD=dev DEBUG_ERROR=true NODE_ENV=production node -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.electron.js --progress --profile --colors",
- "build-renderer-dev": "cross-env BUILD=dev DEBUG_ERROR=true NODE_ENV=production node -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.production.js --progress --profile --colors",
"build": "npm run build-main && npm run build-renderer",
- "build-dev": "npm run build-main-dev && npm run build-renderer-dev",
"start": "cross-env NODE_ENV=production electron ./app/",
"start-hot": "cross-env HOT=1 NODE_ENV=development electron -r babel-register -r babel-polyfill ./app/main.development",
"postinstall": "concurrently \"install-app-deps\" \"node node_modules/fbjs-scripts/node/check-dev-engines.js package.json\" && electron-rebuild --force --module-dir app",
"dev": "npm run hot-server -- --start-hot",
"prepare-qa-build": "node -r babel-register scripts/prepare-qa-build.js",
"package": "npm run build && build -p onTagOrDraft",
- "package-dev": "npm run build-dev && build -p onTagOrDraft --config.artifactName='${productName}-${version}-dev.${ext}' --config.nsis.artifactName='${productName}-Setup-${version}-dev.${ext}' --extraMetadata.name='tidepool-uploader-dev'",
"package-win": "npm run build && build --win --x64",
"package-mac": "npm run build && build --mac",
"package-linux": "npm run build && build --linux",
@@ -224,7 +220,6 @@
"proxyquire": "1.7.11",
"react-addons-test-utils": "15.5.1",
"react-hot-loader": "1.3.1",
- "redux-logger": "3.0.1",
"redux-mock-store": "1.2.3",
"salinity": "0.0.8",
"serialport": "4.0.7",