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

cla-mina

v0.0.2

Published

Wechat applet automatic report logs sdk

Downloads

6

Readme

CLA MINA SDK

功能点

参考emonitor/aegis的日志获取

  • 获取cgi日志
  • 获取错误日志
  • 获取异常日志
  • 获取console日志
  • 重载wx.request
  • 提供主动上报的接口(分级别info/debug/error)
  • 为用户分配uuid(如果配合node sdk使用,由node sdk分配)
  • 防止死循环造成的重复上报,做频率限制
  • 大包体压缩,不能造成日志请求失败

使用说明

  1. 下载
npm i cla-mina -s
# or
yarn add cla-mina
  1. 使用sdk
  • 在小程序入口app.js引入并初始化
// 引入sdk
const CLA = require('./libs/cla')
// 初始化并传入配置参数,参数参考‘参数说明’
const cla = CLA({
    // 参数配置
    appname: "fca-wechat-help",
    repeat: 0,
    delay: 0,
    sampling: 1,
    baseUrl: "https://cvptrace.tsdp.fcachinagsdp.com/collect",
})
//app.js
App({
  onLaunch: function () {
    
  },
  //...
})
  • 在kibana查看对应的appname的上报记录

参数说明

| 名称 | sdk传 | 说明 | | ------- | ------- | ------- | | timestamp | 否 | 上报时间点 | | ip | 否 | 用户IP | | appname | 是 | 应用名,es以此字段建索引 | | level | 是 | 日志级别。ERROR/DEBUG/INFO | | uuid | 是 | 用户ID | | userAgent | 是 | UA | | page | 是 | web sdk为location.href; mina sdk为小程序页面路径 | | ref | 是 | 页面refer | | msg | 是 | 日志内容 | | stack | 是 | 错误堆栈 | | reqBody | 是 | cgi请求参数 | | latency | 是 | cgi时延| | status | 是 | cgi状态码 |

日志格式

  • 基础数据

| 字段 | 说明 | | -------- | -------- | | appname | 应用名 | | timestamp | 上报时间点 | | level | 日志级别,ERROR/DEBUG/INFO| | uuid | 用户ID | | userAgent | UA | | page | 小程序页面路径 | | ref | 页面refer |

  • 日志内容

| 字段 | 说明 | | -------- | -------- | | msg | 日志内容体(js异常错误内容、debug日志内容、异常请求返回内容) | | msg.code | 请求返回码 | | msg.result | 请求返回结果数据 | | msg.isOk | 返回错误与否 | | msg.errMsg | 返回错误信息 |

  • 请求内容

| 字段 | 说明 | | -------- | -------- | | reqBody | 请求体 | | reqBody.method | 请求方法 | | reqBody.url | 请求url | | reqBody.data | 请求参数 |

  • 响应内容

| 字段 | 说明 | | -------- | -------- | | status | 状态码 | | latency | 时延 | 其他返回参考msg

  • 异常内容

| 字段 | 说明 | | -------- | -------- | | stack | 错误堆栈 | 其他内容参考msg

API

cla为初始化后实例

  • cla.report([option])
    • 为手动上报接口
    • option参考‘参数配置’