1.2.7 • Published 3 years ago

@iotechpis/ioreporter v1.2.7

Weekly downloads
206
License
ISC
Repository
github
Last release
3 years ago

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)
}
1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.13

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.12

4 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago