AppReports/README.md

85 lines
1.8 KiB
Markdown
Raw Normal View History

2019-07-04 12:21:37 +02:00
# AppReports
Collects error reports from http capable apps over http-post requests. Reports
are stored in a postgresql database and can be viewed by accessing the server
using a browser.
## Installation
### Setting up the server
```bash
git clone https://git.scode.ovh/timo/appreports
cd appreports
npm i
```
### Setting up the database
run the following sql script:
```sql
-- create user and database
create database appreports;
create user appreports with encrypted password '12345';
grant all privileges on database appreports to appreports;
```
### Configuration
- make a copy of the template:
`cp config.template.json config.json`
- edit the config.json to your preferences
## Usage
### Starting the server
run the following command in the server folder
```bash
nodejs index.js
```
### Sending an error report
Example in js:
```js
const appClientId = 'abcdefg';
window.onerror = async function(msg, source, lineno, colno, error) {
let data;
if (error) {
data = {
2019-10-21 10:16:32 +02:00
app: 'app1',
type: 'error',
client: appClientId,
2019-07-04 12:21:37 +02:00
message: msg,
stack: error.stack,
misc: `v: ${appVersion} src: ${source} ln: ${lineno} col: ${colno}`
};
} else {
2019-10-21 10:16:32 +02:00
data = { app: 'app1', type: 'error', client: appClientId, message: msg };
2019-07-04 12:21:37 +02:00
}
/*
* the first 4 characters of the client will be displayed as app
* the remaining characters (up to 64) will be displayed as client
*/
2019-10-21 10:16:32 +02:00
fetch('http://localhost:8080', {
2019-07-04 12:21:37 +02:00
method: 'POST',
body: JSON.stringify(data),
mode: 'no-cors'
});
};
```
to view the reports open http://localhost:8080 with a browser (in case of the
default config)
## License
[GNU General Public License v3.0 or later © Timo Hocker](./LICENSE)