In-line Analytics

PR for internal review purposes as prelude for PR to upstream
    PR'd against copy of upstream master.

Known issues to be fixed later:
- Styling is embedded in html file as prelude to re-styling
- No tests
- pep8 and pylint not looked at yet.

@jbau @jrbl @stvstnfrd @caesar2164 if you please.
On further thought, this may not apply here because you're in an exception handler and the concomitant rearrangement of the code to try to build in single-return in this function might be a net decrease in readability. So pretend I didn't say all that just then.