Refactor & add error reporing

This commit is contained in:
Thomas Nordquist
2019-01-19 16:48:36 +01:00
parent f3a686b23f
commit b23ffd334d
13 changed files with 1161 additions and 272 deletions

View File

@@ -3,6 +3,8 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<title>MQTT-Explorer</title> <title>MQTT-Explorer</title>
<script src="./build/bugtracking.bundle.js"></script>
<style> <style>
body, html { body, html {
margin: 0; margin: 0;
@@ -66,7 +68,7 @@
<script> <script>
function onLoad() { function onLoad() {
var script = document.createElement("script"); var script = document.createElement("script");
script.src = "./build/bundle.js" script.src = "./build/app.bundle.js"
document.head.appendChild(script); document.head.appendChild(script);
} }
document.addEventListener('DOMContentLoaded', onLoad(), false); document.addEventListener('DOMContentLoaded', onLoad(), false);

1005
app/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -15,6 +15,7 @@
"@types/react-dom": "^16.0.11", "@types/react-dom": "^16.0.11",
"@types/react-redux": "^6.0.12", "@types/react-redux": "^6.0.12",
"electron-nucleus": "^1.11.0", "electron-nucleus": "^1.11.0",
"electron-telemetry": "git+https://github.com/thomasnordquist/electron-telemetry.git",
"react": "^16.7.0", "react": "^16.7.0",
"react-dom": "^16.7.0", "react-dom": "^16.7.0",
"react-redux": "^6.0.0", "react-redux": "^6.0.0",

View File

@@ -1,4 +1,5 @@
import * as React from 'react' import * as React from 'react'
import { electronRendererTelementry } from 'electron-telemetry'
import { import {
Button, Button,
Modal, Modal,
@@ -27,6 +28,7 @@ class ErrorBoundary extends React.Component<Props, State> {
} }
public componentDidCatch(error: Error, errorInfo: any) { public componentDidCatch(error: Error, errorInfo: any) {
electronRendererTelementry.trackError(error)
console.log('did catch', error) console.log('did catch', error)
} }

View File

@@ -1,3 +1,4 @@
import { electronRendererTelementry } from 'electron-telemetry' import { electronRendererTelementry } from 'electron-telemetry'
const spareMeFromGc = electronRendererTelementry const spareMeFromGc = electronRendererTelementry
electronRendererTelementry.registerErrorHandler()

View File

@@ -3,8 +3,8 @@ import * as q from '../../../backend/src/Model'
import { AppBar, Button, IconButton, InputBase, Toolbar, Typography } from '@material-ui/core' import { AppBar, Button, IconButton, InputBase, Toolbar, Typography } from '@material-ui/core'
import { StyleRulesCallback, withStyles } from '@material-ui/core/styles' import { StyleRulesCallback, withStyles } from '@material-ui/core/styles'
import CloudOff from '@material-ui/icons/CloudOff'
import CloudOff from '@material-ui/icons/CloudOff'
import Menu from '@material-ui/icons/Menu' import Menu from '@material-ui/icons/Menu'
import Search from '@material-ui/icons/Search' import Search from '@material-ui/icons/Search'
import { bindActionCreators } from 'redux' import { bindActionCreators } from 'redux'
@@ -106,18 +106,17 @@ class TitleBar extends React.Component<Props, State> {
private renderSearch() { private renderSearch() {
const { classes } = this.props const { classes } = this.props
return <div className={classes.search}> return (
<div className={classes.searchIcon}> <div className={classes.search}>
<Search /> <div className={classes.searchIcon}>
<Search />
</div>
<InputBase
placeholder="Search…"
classes={{ root: classes.inputRoot, input: classes.inputInput }}
/>
</div> </div>
<InputBase )
placeholder="Search…"
classes={{
root: classes.inputRoot,
input: classes.inputInput,
}}
/>
</div>
} }
} }

View File

@@ -90,7 +90,6 @@ class Tree extends React.Component<Props, TreeState> {
} }
private handleNewData = (msg: any) => { private handleNewData = (msg: any) => {
console.log('new data')
const edges = msg.topic.split('/') const edges = msg.topic.split('/')
const node = q.TreeNodeFactory.fromEdgesAndValue(edges, Buffer.from(msg.payload, 'base64').toString()) const node = q.TreeNodeFactory.fromEdgesAndValue(edges, Buffer.from(msg.payload, 'base64').toString())
this.state.tree.updateWithNode(node.firstNode()) this.state.tree.updateWithNode(node.firstNode())

View File

@@ -148,7 +148,6 @@ const reducer: Reducer<AppState | undefined, CustomAction> = (state = initialApp
if (!action.connectionId) { if (!action.connectionId) {
return state return state
} }
return { return {
...state, ...state,
connected: false, connected: false,
@@ -165,7 +164,6 @@ const reducer: Reducer<AppState | undefined, CustomAction> = (state = initialApp
} }
case ActionTypes.connected: case ActionTypes.connected:
return { return {
...state, ...state,
connected: true, connected: true,

View File

@@ -1,6 +1,7 @@
import { rendererEvents, trackError, trackUserInteraction } from '../../events' import { rendererEvents } from '../../events'
let userId = window.localStorage.getItem('userId') let userId = window.localStorage.getItem('userId')
const sha1 = require('sha1') const sha1 = require('sha1')
import { electronRendererTelementry } from 'electron-telemetry'
if (!userId) { if (!userId) {
userId = sha1(sha1(Math.random()) + sha1(performance.now()) + sha1(Date.now())).slice(0, 8) as string userId = sha1(sha1(Math.random()) + sha1(performance.now()) + sha1(Date.now())).slice(0, 8) as string
@@ -19,4 +20,5 @@ export function trackEvent(name: string) {
return return
} }
Nucleus.track(name) Nucleus.track(name)
electronRendererTelementry.trackEvent(name)
} }

View File

@@ -1,15 +1,24 @@
var LiveReloadPlugin = require('webpack-livereload-plugin'); var LiveReloadPlugin = require('webpack-livereload-plugin');
module.exports = { module.exports = {
entry: "./src/index.tsx", entry: {
app: "./src/index.tsx",
bugtracking: "./src/bugtracking.ts",
},
output: { output: {
filename: "bundle.js", filename: "[name].bundle.js",
path: __dirname + "/build" path: __dirname + "/build"
}, },
optimization: { optimization: {
removeAvailableModules: false, removeAvailableModules: false,
removeEmptyChunks: false, removeEmptyChunks: false,
splitChunks: false, splitChunks: {
cacheGroups: {
vendors: {
filename: '[name].bundle.js'
}
}
}
}, },
target: 'electron-renderer', target: 'electron-renderer',

371
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -67,6 +67,7 @@
"dependencies": { "dependencies": {
"electron-debug": "^2.0.0", "electron-debug": "^2.0.0",
"electron-log": "^2.2.17", "electron-log": "^2.2.17",
"electron-telemetry": "git+https://github.com/thomasnordquist/electron-telemetry.git",
"electron-updater": "^4.0.6", "electron-updater": "^4.0.6",
"mqtt": "^2.18.8", "mqtt": "^2.18.8",
"sha1": "^1.1.1" "sha1": "^1.1.1"

View File

@@ -5,6 +5,9 @@ import { menuTemplate } from './MenuTemplate'
import { autoUpdater } from 'electron-updater' import { autoUpdater } from 'electron-updater'
import * as log from 'electron-log' import * as log from 'electron-log'
import { ConnectionManager, updateNotifier } from '../backend/src/index' import { ConnectionManager, updateNotifier } from '../backend/src/index'
import { electronTelemetryFactory } from 'electron-telemetry'
const electronTelemetry = electronTelemetryFactory('9b0c8ca04a361eb8160d98c5')
const isDebugEnabled = Boolean(process.argv.find(arg => arg === 'debug')) const isDebugEnabled = Boolean(process.argv.find(arg => arg === 'debug'))
require('electron-debug')({ enabled: isDebugEnabled }) require('electron-debug')({ enabled: isDebugEnabled })