Blip is the internal name for Tidepool for Web, a tool for seeing diabetes data in one place.
JavaScript CSS Other
Switch branches/tags
webpack-1 v99.99.99-alpha.99 v1.11.9-cbg-tooltips.4 v1.11.8 v1.11.7 v1.11.7-care-team-infustion-site.1 v1.11.6 v1.11.6-casper.3 v1.11.6-casper.2 v1.11.6-casper.1 v1.11.6-care-team-infustion-site.1 v1.11.5 v1.11.5-suspend-count-fix.1 v1.11.5-daily-print-view-tick-formatting.1 v1.11.5-bolus-rounding.1 v1.11.5-1i8n.1 v1.11.4 v1.11.4-calib-message.1 v1.11.3 v1.11.3-cbg-tooltips.3 v1.11.3-auto-target.5 v1.11.3-auto-target.4 v1.11.3-add-careteam-upload-link.1 v1.11.2 v1.11.2-auto-target.1 v1.11.1 v1.11.1-weekly-range-fix.1 v1.11.1-print-date.3 v1.11.1-print-date.2 v1.11.1-cbg-tooltips.2 v1.11.1-cbg-tooltips.1 v1.11.1-casper.2 v1.11.1-casper.1 v1.11.1-automated-basal-add-basal-bolus.1 v1.11.0 v1.11.0-automated-basal.9 v1.11.0-automated-basal.8 v1.11.0-automated-basal.7 v1.11.0-automated-basal.6 v1.11.0-automated-basal.5 v1.11.0-automated-basal.4 v1.11.0-automated-basal.3 v1.11.0-automated-basal.2 v1.11.0-automated-basal.1 v1.11.0-automated-basal v1.11.0-automated-basal-suspend-fix.1 v1.11.0-600-series-beta.5 v1.11.0-600-series-beta.4 v1.11.0-600-series-beta.3 v1.11.0-600-series-beta.2 v1.11.0-600-series-beta.1 v1.10.10-dismiss-launch-uploader.3 v1.10.10-dismiss-launch-uploader.2 v1.10.10-dismiss-launch-uploader v1.10.9 v1.10.9-jellyfish-fix.3 v1.10.9-jellyfish-fix.2 v1.10.9-jellyfish-fix.1 v1.10.9-bg-defaults-daily-ticks-fix.1 v1.10.8 v1.10.8-standardbgdefaultsfix.7 v1.10.8-standardbgdefaultsfix.6 v1.10.8-standardbgdefaultsfix.5 v1.10.8-standardbgdefaultsfix.4 v1.10.8-standardbgdefaultsfix.3 v1.10.8-standardbgdefaultsfix.2 v1.10.8-standardbgdefaultsfix.1 v1.10.8-smbg-tooltips.6 v1.10.8-smbg-tooltips.5 v1.10.8-smbg-tooltips.4 v1.10.8-smbg-tooltips.3 v1.10.7 v1.10.7-smbg-tooltips.3 v1.10.7-smbg-tooltips.2 v1.10.7-smbg-tooltips.1 v1.10.7-addaade.3 v1.10.7-addaade.2 v1.10.7-addaade.1 v1.10.7-aade-donation-partner.1 v1.10.6 v1.10.6-web-security-helmet v1.10.5 v1.10.5-email-signup-format-fix.1 v1.10.4 v1.10.4-trends-time-fix.1 v1.10.3 v1.10.3-email-address-verification v1.10.2 v1.10.2-daily-print-time-fix.1 v1.10.1 v1.10.1-chart-selection-fix v1.10.0 v1.10.0-data-paging.13 v1.10.0-data-paging.12 v1.10.0-data-paging.11 v1.10.0-data-paging.10 v1.10.0-data-paging.9 v1.10.0-data-paging.8 v1.10.0-data-paging.7 v1.10.0-data-paging.6
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
config
docs
integration
static
test
.artifactignore
.babelrc
.bookignore
.dockerignore
.editorconfig
.eslintrc
.gitignore
.travis.yml
Dockerfile
LICENSE
README.md
SUMMARY.md
artifact.sh
build.sh
buildapp.js
buildconfig.js
config.app.js
config.server.js
config.webpack.js
favicon.ico
index.ejs
karma.conf.js
loadtests.js
nightwatch-globals.js
nightwatch.json
package.json
postcss.config.js
server.js
start.sh
test.config.js
update-gh-pages.sh
version.sh
webpack.config.js
yarn.lock

README.md

Blip

Build Status

Blip is a web app for type 1 diabetes (T1D) built on top of the Tidepool platform. It allows patients and their "care team" (family, doctors) to visualize their diabetes device data (from insulin pumps, BGMs, and/or CGMs) and message each other.

This README is focused on just the details of getting blip running locally. For more detailed information aimed at those working on the development of blip, please see the developer guide.


Table of contents


Install

Requirements:

Clone this repo from GitHub, then install the dependencies:

After cloning this repository to your local machine, first make sure that you have node 6.x and npm 4.x installed. If you have a different major version of node installed, consider using nvm to manage and switch between multiple node (& npm) installations. If you have npm 3.x installed (as it is by default with node 6.x), then you can update to the latest npm 4.x with npm install -g npm@4.

It's not an absolute requirement, but it is preferable to have Yarn installed, as it provides dependency management features above and beyond what npm provides. Just follow Yarn's installation instructions (hint: for Mac users with Homebrew installed, it's just brew install yarn).

Once your environment is setup with node 6.x and npm 3.x install the dependencies with Yarn:

$ yarn install

Or with npm if you're choosing not to use Yarn:

$ npm install

Running locally

If you're running the entire Tidepool platform locally as per starting services, you can start blip using your local platform with:

$ source config/local.sh
$ npm start

Open your web browser and navigate to http://localhost:3000/.

(See also: recipe for running blip locally with hot module replacement.)

The npm start command runs the Webpack dev server which includes hot module reloading (HMR) capabilities. Essentially changes within React components should be updated "hot" in your browser without a page refresh. Sometimes this doesn't work, but in such cases the dev console will include a message from the Webpack dev server indicating that you need to do a full refresh to see your changes.

Redux dev tools

Blip includes several Redux developer tools: the original time-travel dev tools UI, a console action logger, and a mutation tracker for catching mutations to the state tree (which should be immutable). The last of these in particular is a performance killer (though none of them could even be said to have a negligible effect on performance). By default when running for local development with npm start (which means NODE_ENV is development), the DEV_TOOLS flag will be true, and all of these dev tools will be active. Because they affect performance profoundly, this may not always be desirable. To turn off the dev tools in development, kill the Webpack dev server (i.e, the npm start process), run export DEV_TOOLS=false, then start up blip again with npm start.

NB: Due to differences in the development versus production builds of React itself (most notably PropTypes validation), performance of the app whenever NODE_ENV is development will never be as good as it is in the production build under a NODE_ENV of production. If you're concerned about the performance of a particular feature, the only way to test with good fidelity is with the production build, which you can do locally according to these instructions below.

Getting past e-mail verification for a user created locally

When running locally with runservers or with the docker-based setup, no e-mail will be sent to a sign-up e-mail address, and so a workaround is needed to get past the e-mail verification step for a newly created local account being used for development. What you need to do is construct the login URL that is provided in a link in the verification e-mail manually by finding the correct key for the e-mail confirmation.

If you're developing locally, you can find the key by looking in the local server.log (located at the root level of where you've cloned all the Tidepool repositories).

If you're developing with the docker setup, you can find the key in the logs of the hydrophone container. It will look something like

2018/06/07 16:17:17 Sending email confirmation to foo@bar.com with key aSuzGcwq4kPRyb6pwQnTcSKVTt_V6CtL

Kitematic is an easy-to-use tool for inspecting the logs of your docker containers. You can find the link to it's installer in Docker's menu.

You can also find the key in your Mongo database. The steps for the latter are:

  • start a Mongo shell in a fresh Terminal window with mongo
  • switch to the confirm database with use confirm
  • find the pending account with db.confirmations.find({status: 'pending'});
  • copy the _id from the pending confirmation record with an email matching the account you've just created

After you've found the key, you can provide it as a signupKey parameter in the login URL: http://localhost:3000/login?signupKey=<key>

Creating a user without e-mail verification

When running locally, there is also workaround so you don't have to verify the e-mail address of a new user: if you create a new user and add the localhost secret +skip to the e-mail address - e.g. me+skip@something.org - this will then allow you to login straightaway, skipping the e-mail verification step.

NB: The UI is not guaranteed to display correctly for +skip-created users on all pages, and so 💣 THIS WORKFLOW IS NOT CURRENTLY RECOMMENDED 💣. For now, you must create a normal account (without +skip) if you want to work on the sign-up flow, although we have plans to fix the way the +skip workaround operates on the platform to address this.

Running against dev

By default—that is, if you don't source a different configuration, such as the local.sh configuration for local development with runservers referenced above—if you simply run npm start in this repository after installing the dependencies, blip will start up running against Tidepool's "dev" server environment.

Config

Configuration values are set with environment variables (see config/local.sh).

You can set environment variables manually using export VAR=value, or use a bash script. For example:

$ source config/local.sh

Ask the project owners to provide you with config scripts for different environments, or you can create one of your own if you have a custom environment. It is recommended to put all config scripts in the config/ directory, where they will be ignored by Git.

Debugging

The app uses the bows library to log debugging messages to the browser's console. It is disabled by default (which makes it production-friendly). To see the messages type localStorage.debug = true in the browser console and refresh the page. Create a logger for a particular app module by giving it a name, such as:

app.foo = {
  log: bows('Foo'),
  bar: function() {
    this.log('Walked into a bar');
  }
};

Running the tests

We use Mocha with Chai for our test framework inside Karma as our test runner, as well as Sinon.JS and Sinon-Chai for spies and stubs. Our tests currently run on PhantomJS, a headless WebKit browser, or Chrome (locally only).

To run the unit tests, use:

$ npm test

To run the unit tests in Chrome, use:

$ npm run browser-tests

To run the unit tests in watch mode, use:

$ npm run test-watch

Build and deployment

The app is built as a static site in the dist/ directory.

We use Shio to deploy, so we separate the build in two.

Shio's build.sh script will take care of building the app itself with:

$ npm run build-app

Shio's start.sh script then builds the config from environment variables as a separate file with:

$ source config/env.sh
$ npm run build-config

After that, the app is ready to be served using the static web server included in this repo:

$ npm run server

Testing the production build locally

You can also build everything at once locally to test the production build by simply running:

$ source config/local.sh
$ npm run build
$ npm run server