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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@inceptionpad/frontend-monitor-web-sdk

v1.0.0

Published

web monitor sdk

Readme

Installation

npm install @inceptionpad/frontend-monitor-web-sdk --save

import webMonitorSdk from '@inceptionpad/frontend-monitor-web-sdk';
const monitor = webMonitorSdk({
    appId: "xxx",
    api: "localhost:3000/api/v1/report/web",
    filterUrls: ['api/xxxx/xx'],
    errcodeReport(res) {
      if (Object.prototype.toString.call(res) === '[object Object]' && res.hasOwnProperty('errcode') && res.errcode !== 0) {
        return { isReport: true, errMsg: res.errmsg,code: res.errcode };
      }
      return { isReport: false };
    },
    isTraceId: true,
    traceIdHeaderName: 'x-trace-id';
})

Parameters

| Init Param | Type | Required | Default | Example | Description | | ------ | ------ | ------ | ------ | ------ | ------ | | appId | String | Required | - | - | The appId of the application | | api | String | Required | '' | https://localhost/web-monitor/api/v1/wx/report/wx | - | | filterUrls | Array | Optional | - | ['api/xx'] | Filter certain endpoints from being reported, e.g. polling requests. Uses fuzzy string matching (try to keep paths complete, fuzzy matching may affect other endpoints) | | errcodeReport (business error reporting) | Function | Optional | - | See example below | For requests where httpStatus is 200 but the business logic returns an error in the response body. E.g. errcode=1 means a backend error, which should be reported to the monitor | | isTraceId | boolean | Optional | false | - | Whether to enable traceId retrieval | | traceIdHeaderName (traceId field name in server response headers) | string | Optional | x-trace-id | - | The response headers need 2 fields: access-control-expose-headers: x-trace-id (allow frontend access); x-trace-id:bdDq1a.a123.12 |

Default filtered domains by SDK

Third-party analytics requests can generate a large amount of noise data. The monitor will not collect data from such endpoints by default. If you need to filter out specific endpoints that don't need monitoring, use filterUrls.

errcodeReport:

  webMonitorSdk({
    errcodeReport(res) {
      if (Object.prototype.toString.call(res) === '[object Object]' && res.hasOwnProperty('errcode') && res.errcode !== 0) {
        return { isReport: true, errMsg: res.errmsg,code: res.errcode };
      }
      return { isReport: false };
    }
  });
Note on positive vs. negative checks

We may use fetch or xmlHttpRequest to request any resource such as APIs, CSS, JS (or framework-initiated requests). The res received by errcodeReport could be a string, object, or other types. Stricter checks may be needed to correctly determine whether a business error should be reported.

For example:

Positive check: res.errcode===1
errcodeReport(res) {
  if (Object.prototype.toString.call(res) === '[object Object]' && res.errcode == 1) {
    return { isReport: true, errMsg: res.errmsg,code: res.errcode };
  }
  return { isReport: false };
}
Negative check: res.errcode!==0 — if hasOwnProperty is not used, responses without an errcode property would also be reported as errors (some business endpoints may not follow a strict response format)
errcodeReport(res) {
  if (Object.prototype.toString.call(res) === '[object Object]' && res.hasOwnProperty('errcode') && res.errcode !== 0) {
    return { isReport: true, errMsg: res.errmsg,code: res.errcode };
  }
  return { isReport: false };
}

Methods

setConfig: Set user info

You can set any one or more properties.

monitor.setConfig({
  p: '8877661112', // phone number
  uid: '100017' // user id
});

addError: Manually report an error

let message = 'js add error';
let col = 20;
let line = 20;
let resourceUrl = 'http://www.xxx.com/01.js';

monitor.addError({
  msg: message,
  col: col,
  line: line,
  resourceUrl: resourceUrl
});

addCustom: Custom event tracking

const monitor = webMonitorSdk({
    appId: "xxx",
    env: 'dev'
})
// Executes immediately by default. If you don't want it to execute immediately, set reportNow to false.
// The event will be queued and reported when report() is called elsewhere, on page change, or on the next API request.
// reportNow defaults to true, optional parameter
monitor.addCustom({
    customName: 'mgStart-getUserInfo',
    customContent: {
      userId: 123,
      system: {
        version: '1.2'
      }
    },
    /*
      Optional field. Custom filter conditions, must be an object (otherwise invalid).
      Manually select specific fields to upload.
      The monitor backend uses the filter fields to query custom parameters.
      Fields in customContent that you want to filter by later should be passed here.
      Note: customFilter only supports 1 level of nesting.
    */
    customFilter: {
      userId: 123,
      version: '1.2'
    }
}, reportNow);

Cross-origin error details unavailable

When loading cross-origin script resources that contain JS errors, the SDK's global window.onerror cannot capture detailed error info — it will only receive Script error. The fix is to add the crossorigin attribute to the cross-origin <script> tag, and configure the server to set the appropriate CORS headers for the resource.

SDK reports the following performance data

  • url: The current page URL
  • preUrl: The URL of the previous page
  • performance: Page performance details — see field descriptions below
  • errorList: Page error details including js, img, ajax, fetch errors — see field descriptions below
  • resoruceList: Resource performance details for all resources on the current page — see field descriptions below
  • markUv: UV tracking identifier
  • markUser: Tracks the user from site entry until they leave; can be used for funnel analysis
  • time: Current report timestamp
  • screenWidth: Screen width
  • screenHeight: Screen height
  • isFristIn: Whether this is the first entry of a session
  • type: Report type — 1: page-level performance, 2: page ajax performance, 3: page error reporting