@iotechpis/ioreporter

1.2.7 • Public • Published

ioReporter

About

ioReporter is a IOTech utility that sends messages to ioChat whenever a error happens in front-end or back-end (only logical/bad programming errors, not user errors).

Install

npm i @iotechpis/ioreporter -s

How to use

Back-end (Nodejs & Express)

const express =  require("express");
const app =  express();

//URL where you want to send the error message (you must ask for this)
const webhook_url = "https://webhook.com/weognrwg"; 

//Channel name in the chat
const api_channel = "ioreporter_api";
const app_channel = "ioreporter_app";

//Error message that the server provides everytime a HTTP request results in an error
//If no error_message is provided, this is also the default one
const error_message = {
	http:  500,
	code:  "ServerError",
	type:  "error"
};

require("@iotechpis/ioreporter")(app, webhook_url, api_channel, app_channel, error_message);

This automatically creates an endpoint /ioreporter/error (POST) , that can be used to report front-end errors, if no app_channel is provided, the endpoint is not created.

Front-end (Vuejs)

App.vue

import { sendError } from  "./api/apiError";
export  default {
	created() {
		window.onerror  =  function  myErrorHandler(errorMsg, url, lineNumber) {
			sendError({
				error: errorMsg,
				url,
				line: lineNumber
			});
			return;
		};
	}
}

/api/apiError.js

import { post } from  "../utils/http"

export  function  sendError(data) {
	return  post('/ioreporter/error', data)
}

Readme

Keywords

none

Package Sidebar

Install

npm i @iotechpis/ioreporter

Weekly Downloads

1

Version

1.2.7

License

ISC

Unpacked Size

13.7 kB

Total Files

3

Last publish

Collaborators

  • danielggcarneiro
  • iodevteam