npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rilog-development/rilog-lib

v0.3.19

Published

**Simple way to log and debug your web apps.**

Downloads

32

Readme

Rilog lib

Simple way to log and debug your web apps.

Rilog lib intercepts and stores different events such as requests, button clicks, client custom messages (instead of using console.log), etc. Today, rilog-lib is adapted for axios and fetch.

Table of Contents


Installation and usage


Installing

yarn add @rilog-development/rilog-lib

or

npm i @rilog-development/rilog-lib

Usage (axios)

  1. Import Rilog object from lib.
import rilog from '@rilog-development/rilog-lib';
  1. Init Rilog and set up config
rilog.init();
  1. Set up your axios instance and interceptors. Add interceptRequestAxios and interceptResponseAxios functions.
// request interceptor
instance.interceptors.request.use(async function (request) { // Your axios instance

    rilog.interceptRequestAxios(request);

    return Promise.resolve(request);
});
// response interceptor
instance.interceptors.response.use(function(response) {

    rilog.interceptResponseAxios(response);

    return Promise.resolve(response);
}, function(error) {

    rilog.interceptResponseAxios(error);
    
    return Promise.reject(error);
})

Usage (fetch)

By default Rilog lib intercept all fetch requests when you call rilog.init() method. But, you can disable fetch interception with passing disableFetchInterceptor: true to config.

Local server


You can store your log data offline on your drive with Rilog local-server. It's very useful, because you can store as many logs data as your drive allows you.

Install and launch the local-server on your device for local storing events. Local-server would launch on http://localhost:2525. The Rilog lib will send events to local-server.

Then define in config localServer with appName. (Look at localServer config) The Rilog local-server will create folder for project (using app name) and log file (using current date and unique client token).

Example:

config: {
        localServer: {
            appName: "Rilog test lib"
        }
    }

Also, you can pass any additional params for your app. They would be written to you log file. In this example we pass an environment info and a current build type:

config: {
        localServer: {
            appName: "Rilog test lib",
            params: {
                env: "dev",
                build: "uat"
            }
        }
    }

Local Server Config

Below is a list of local server config params (ILocalServerConfig):

| Param | Type | Required | Definition | |---------|------------------------------------------|----------|-----------------------------------------------------| | appName | string | Yes | App name would be used for creating project folder. | | params | any | No | Any additional params for storing in log file. |

Your server


You can use your own server for storing intercepted events. You should create a POST method and pass the selfServer with url param to config. Every time when events were collected the Rilog lib would call your POST method and pass events to body:

    { events: string }

The array of events would be passed as JSON string to the method. So, you should parse it.

Self server config

| Param | Type | Required | Definition | |---------|------------------------|----------|------------------------------------------------------------------| | url | string | Yes | The url of your own backend endpoint (POST) for storing events. | | headers | Record<string, string> | No | Additional headers for storing events endpoint. |

Below is a list of self server config params:

Config


Below is a list of config params:

| Param | Type | Definition | |-------|------------------------------------------|--------------------------------------------------------------------------------------------------------------| | ignoredRequests| string[] | Urls of requests that would be ignored. The rilog lib wouldn't store events for this events. | | sensetiveRequsts | string[] | The request headers and data wouldn't be stored. Headers and data would be replaced with 'sensetive' string. | | sensetiveDataRequests | string[] | The request data wouldn't be stored. Data would be replaced with 'sensetive' string. | | headers | string[] | Only this headers would be stored. By default rilog-lib doesn't store requests with all headers. | | localStorage | string[] | Only this localStorage values would be stored. By default rilog-lib doesn't store all local storage values. | | disableFetchInterceptor | boolean | Disable fetch interception. | | disableClickInterceptor | boolean | Disable click interception. | | localServer | ILocalServerConfig | Config for storing events to local server. | | selfServer | ISelfServer | Config for storing events to your custom backend. | | onPushEvent | function(event) {} | Push event call back. It calls when some event is intercepted. | | | onSaveEvents | function(events) {} | Save events call back. It calls before evets would be sent to any storage. |

Examples


Sensetive Requests

Imagine if you need to hide sensitive card data for few request:

rilog.init({
    config: {
        sensetiveDataRequests: ['/api/v1/pay/card', '/api/v1/send/card']
    }
});

You are interested in storing only axios requests:

rilog.init({
    config: {
        disableFetchInterceptor: true,
        disableClickInterceptor: true
    }
});

You need to ignore some request:

rilog.init({
    config: {
        ignoredRequests: ['https://some.test/request'],
    }
});

Store some headers in request events and some values from local storage:

rilog.init({
    config: {
        headers: ['Authorization'],
        localStorage: ['token', 'userId']
    }
});