1.8 KiB
1.8 KiB
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
git clone https://git.scode.ovh/timo/appreports
cd appreports
npm i
Setting up the database
run the following sql script:
-- 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
nodejs index.js
Sending an error report
Example in js:
const appClientId = 'abcdefg';
window.onerror = async function(msg, source, lineno, colno, error) {
let data;
if (error) {
data = {
app: 'app1',
type: 'error',
client: appClientId,
message: msg,
stack: error.stack,
misc: `v: ${appVersion} src: ${source} ln: ${lineno} col: ${colno}`
};
} else {
data = { app: 'app1', type: 'error', client: appClientId, message: msg };
}
/*
* the first 4 characters of the client will be displayed as app
* the remaining characters (up to 64) will be displayed as client
*/
fetch('http://localhost:8080', {
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)