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 🙏

© 2025 – Pkg Stats / Ryan Hefner

loggerdb

v2.0.18

Published

快递助手 前端日志持久化

Readme

logDb

前言:

为什么要有logDb

  • 难以复现的用户问题无处排查? 要是能有当时操作日志就好了。
  • 用户客户端不能打开控制台? 看眼输出都这么难! 能不能不要怎么麻烦(抓狂)!!
  • 上线bug不能及时发现, 要等用户反馈才察觉? 有错误上报多好,好怕P0事故~~
  • 亲有时间吗麻烦把有问题的操作流程给我演示遍.... 解决客户问题卑微又没效率。

研发同学们,你们工作是否经常遇见以上痛点? 现在,解决问题的轮子来了, 就是 logDb。 他是能将用户操作中产生数据存储到indexDb做持久化。可以通过api调出日志, 也可通过在线页来查询分析。 而且还实现了错误上报、性能分析、页面录制|回放、虚拟控制台等功能。 加强我们排查问题的能力。

为什么不实时上传而要存在indexDb里?

  • 需要保存的用户数据/其他记录,这个数据记录平时大部分用户不需要使用它,而在排查问题/验证时很重要;
  • 日志数据量很大,存储在后端会造成极大的资源浪费而且没别的意义,使用这个工具可以节省极大的后端资源;
  • 不会因为频繁上传数据产生过多的请求, 节省用户资源;

特点

  • 无感知: 在用户使用过程中,logDb只会进行插入操作,这对客户端性能影响微乎其微@性能测试报告。 开发原则是对用户体验0影响
  • 轻量: 依赖大小仅200kb (还有优化空间)。
  • 通用: 原生js实现,不分技术栈,web端通用。
  • 简单: 引入即用,api简单, 带有可视化界面。

使用

1.安装

npm i loggerdb -save

2.初始化

  import loggerDb from 'loggerdb';
  window.logDb = new loggerDb(option);   // 挂载window上,方便能在控制台中使用
option[object]

|参数|说明|类型|默认值|版本| | ---- | ---- | ---- | ---- | ---- | |expirationTime|保存日志的天数,超出的历史日志将会被清除|number|2|| |isEmit|调用logDb.log时是否在控制台打印日志|bool|true|| |roomId|使用在线可视化页需要的房间id|string|非必传|2.0+| |openRecord|启用页面录屏,为true时,录屏相关api才能正常使用|bool|false|2.0+| |useErrStytem|使用报错捕获系统(报错录屏,错误上报),为true时,openRecord置为true|bool|false|2.0+| |serveUrl|服务器的socket.io的地址|string|非必传|2.0+|

3.API

* logDb.log(核心)

说明: 将传参作为日志存储起来。

可用版本: 1.0+

传参:没有数量和类型限制。 最终会将所有传参转成字符串,拼接后保存。

  • 当参数数量>1时,若arguments[0]类型为string且少于20字符时,会将arguments[0]作为错误类型存储。

* logDb.openOnline(核心)

说明: 启用在线可视化页面,控制台会打印url地址

  • cltr+F12 快捷键启用, url地址将通过通知栏弹出

可用版本: 2.0+

传参: (serveUrl)

|参数|说明|类型|默认值| | ---- | ---- | ---- | ---- | |serveUrl|服务器的soket.io地址|string|可不传|

* logDb.getDate

说明: 返回以日期为维度的所有日志(可以在控制台调用返回日志,适合数据量不大时使用)

传参: (dateString)

|参数|说明|类型|默认值| | ---- | ---- | ---- | ---- | |dateString|传入指定日期字符如"2022-03-28",不传则会返回所有日期的数据|string\undefined|非必传|

* logDb.get

说明: 获取时间段内的所有数据 (可以在控制台调用返回日志,当数据过多时会导致控制台卡死时,需要缩小时间范围降低数据量)

可用版本: 1.0+

传参:不传则获取所有数据,可传:(start,end)

|参数|说明|类型|默认值| | ---- | ---- | ---- | ---- | |start|开始时间,不传则从最初始开始查|日期字符串\日期对象\时间戳|undefined| |end|结束时间,不传则截止到最后一条|日期字符串\日期对象\时间戳|undefined|

record 录屏相关API

注意:在openRecord为true时才生效

* logDb.record.spark

说明: 触发保存。 调用该函数后,会将触发时机的那段时间的页面操作保存下来

可用版本: 2.0+

* logDb.record.stop

说明: 停止录屏

可用版本: 2.0+