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

@page-wright/recorder

v0.2.0

Published

Pagewright 浏览器录制 SDK,基于 rrweb 进行事件采集并上传。

Readme

@page-wright/recorder

Pagewright 浏览器 SDK,基于 [email protected] 录制用户会话并上报到 Pagewright 后端。

安装

pnpm add @page-wright/recorder

也可以直接通过 IIFE 构建物引入(见 dist/index.global.js)。

基本用法

import { start } from "@page-wright/recorder";

const handle = start({
  sessionId: "自生成或业务侧指定", // 可缺省,SDK 会 nanoid
  endpoint: "https://your-app.example.com/api/events",
  metadata: {
    appVersion: process.env.APP_VERSION,
    userId: currentUser.id,
  },
  // 可选:抽样、脱敏等
  sampling: { mousemove: 50 },
  maskAllInputs: true,
});

// 用户结束时显式停止
window.addEventListener("pagehide", () => handle.stop());

SDK 会:

  1. 以批量方式 fetch(endpoint, { method: "POST" }) 上传 rrweb 事件。
  2. 在页面关闭时回退 navigator.sendBeacon,保证最后一批事件不会丢。
  3. 对表单输入、点击、keypress 事件附加自定义 semantic 事件,携带 primarySelector / backupSelectors / semantic.description,降低服务端降噪成本。

数据契约

上报的 body 为 EventBatch(见 @pagewright/schemas),核心字段:

interface EventBatch {
  sessionId: string;
  seq: number;           // 批次序号,服务端据此去重
  sentAt: number;        // 客户端毫秒时间戳
  events: RawRrwebEvent[];
  metadata?: Record<string, unknown>;
}

与后端交互

后端实现参考 apps/web/src/app/api/events/route.ts

  • POST /api/events:接收事件,同时支持 application/jsontext/plain(sendBeacon 场景)。
  • PATCH /api/events?sessionId=...:触发降噪 + LLM 转换。

注意事项

  • 当前仅在 Chromium(Playwright 默认驱动)上做过端到端验证;Safari/WebKit 的 sendBeacon 兼容性请自行评估。
  • maskAllInputs 默认关闭,生产环境请显式打开并配合 maskTextSelector / blockSelector 控制敏感数据。
  • 若业务方希望离线缓存,可在 onQueueDrop 回调里接入自己的 IndexedDB/LocalStorage 兜底。