AppReports/README.md
2019-10-21 11:08:56 +02:00

1.6 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 };
  }
  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)

License

GNU General Public License v3.0 or later © Timo Hocker