0.0.4 • Published 1 year ago

rilog-lib v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Rilog lib

Simple way to logging and debugging your web apps. Rilog lib collects requests, collects the local storage state, and does some request analytics. Know, rilog-lib is adapted for axios. But you can also use it with fetch soon.

Installation and usage

Installing

yarn add rilog-lib

or

npm i rilog-lib

Usage (axios)

  1. Import Rilog object from lib.
import { Rilog } from 'rilog-lib'
  1. Init Rilog
Rilog.init({ 
    key: 'RILOG_APP_KEY',
    config: {} 
})
  1. Set up config if you need:
config: {
    headers: [] // Write the headers you want to store
    localStorage: [] // Write the params from Local Storage you want to store
    sensetiveRequsts: [] // Write the URL of request you want to exclude from storing
    sensetiveDataRequests: [] // Write the URL of the request you want to exclude from storing request data
}
  1. Set up axios your axios instance and interceptors. Add pushRequest and pushResponse functions.
instance.interceptors.request.use(async function (request) { // Your axios instance
    Rilog.pushRequest(request);
})
instance.interceptors.response.use(function(response) {
    Rilog.pushResponse(response);
}, function(error) {
    Rilog.pushResponse(error);
    return Promise.reject(error);
})