Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@yorkjs/web-error

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yorkjs/web-error

process web-error and report tool

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
2
Weekly downloads
 
Created
Source

web-error

捕获页面异常,并上报

安装

CDN

<script src="https://unpkg.com/@yorkjs/web-error"></script>

NPM

npm install @yorkjs/web-error

YARN

yarn add @yorkjs/web-error

初始化

提供了两种上传方式
webError.sendImage(url, queryStr)
webError.sendBeacon(url, data)

参考:

Navigator.sendBeacon()

ErrorMsg 对象
export interface ErrorMsg {
  url: string,
  type: number | string,
  error?: string,
  file?: string,
  line?: number,
  column?: number,
}
使用示例
import * as webError from '@yorkjs/web-error'

// 初始化需要的对象
// reportError 上报错误信息方法
webError.init({
  reportError(errObj) {
    // 方式一: 使用图片方式上传错误信息
    // 将错误对象处理成功 query 参数
    const query = formatMessage(errObj)
    webError.sendImage(url, query)

    // 方式二: 使用 Navigator.sendBeacon 方法
    webError.sendBeacon(url, errObj)
  },
})

Keywords

FAQs

Package last updated on 20 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc