@complyco/client-recorder-web

中文文档
0.3.1发布于 2026/08/08TypeScriptESM + CJS近 30 天下载 8509

ComplyCo的客户端网络记录器

中文使用文档
文档目录5 节
  1. 开始
  2. 化妆
  3. 导航
  4. 插件
  5. 反应实例

客户端- 记录

此软件包允许您在您的网络应用程序中设置网络会话记录 .

开始

请注意 baseUrl 来源于您在ComplyCO的仪表板上注册的客户端. 它会看起来像 app-<...>.client.complyco.com。 。 。 .

这个 onAuthTokenRequested 调用需要击中您后端的端点, 而后端的端点被配置为生成并签名 JWT . 您在 ComplyCO 仪表板上注册的客户端应当配置与所使用的私钥对应的公钥 在您的后端 API 中签名.

import { createClientRecorder } from "@complyco/client-recorder-web";
import { GzipPlugin } from "@complyco/client-recorder-web/plugins";

// initialize the recorder once for your pageload
const recorder = createClientRecorder({
  syncOptions: {
    baseUrl: process.env.NEXT_PUBLIC_WIDGET_API as string,
    onAuthTokenRequested,
    plugins: [GzipPlugin],
  },
});

// if your JWT callback function changes, you can pass in your new one
recorder.setOnAuthTokenRequested(onAuthTokenRequested);

// start the recording; you only need to do this once.
// NOTE: The argument is optional. This example shows the defaults
recorder.record({
  blockClass: "complyco-block",
  ignoreClass: "complyco-ignore",
  maskTextClass: "complyco-mask",
  maskAllInputs: true,
  captureNavigation: false,
});

// stops the recording and forces a sync to ComplyCO's backend.
recorder.shutdown();

化妆

默认情况下所有输入都被遮住,但您可以选择解析所有输入. 与 maskAllInputs 设置为 true (默认值),标出任何您想要被卸载的字段 data-complyco-unmask="true" 或 complyco-unmask 类(例如:. <input class="complyco-unmask"> 或者说 <select data-complyco-unmask="true">) (中文(简体) ). 使用这个来保持特定的非敏感字段的可见度(例如产品名下放),同时将其他所有东西都遮住.

您可以用块、 忽略并遮盖文本类来配置记录器, 或者您可以使用我们的默认值 。 我们的默认是:

  • apec 块
  • 符合
  • 调试任务

如果您的UI已经从 Sentry 的回放功能中拥有类, 您可以在引用时通过相应的类名 recorder.record(...)。 。 。 .

导航

这个 captureNavigation 选项允许您在单页应用程序中跟踪页面导航事件。 当启用时,它将记录通过下列方式发生的 URL 变化:

  • 历史 API 调用 (pushState, (中文(简体) ), replaceState(中文(简体) )
  • 向后浏览器导航
  • 散列变化

插件

插件的使用是可选的,但在某些情况下它们可能会提供性能改进.

  • GzipPlugin:发送到ComplyCO后端时压缩录音.

反应实例

"use client";
import { useState, useEffect } from "react";
import { createClientRecorder } from "@complyco/client-recorder-web";
import { GzipPlugin } from "@complyco/client-recorder-web/plugins";

export type AuthTracerProviderProps = {
  children: React.ReactNode;
  onAuthTokenRequested: any | undefined;
};

export default function AuthTracerProvider({ children, onAuthTokenRequested }: AuthTracerProviderProps) {
  const [recorder] = useState(() => {
    return createClientRecorder({
      syncOptions: {
        baseUrl: process.env.NEXT_PUBLIC_WIDGET_API as string,
        onAuthTokenRequested,
        plugins: [GzipPlugin],
      },
    });
  });

  useEffect(() => {
    if (onAuthTokenRequested) {
      recorder.setOnAuthTokenRequested(onAuthTokenRequested);
    }
  }, [recorder, onAuthTokenRequested]);

  useEffect(() => {
    recorder.record();

    return () => {
      recorder.shutdown();
    };
  });

  return null;
}

版本与发布记录

@complyco/client-recorder-web 共发布 11 个版本,首次发布于 2024/10/02;过去 12 个月发布了 3 个版本。

版本发布日期距今
0.3.1latest2026/08/083 个月前
0.3.02026/08/083 个月前
0.2.02025/12/1910 个月前
0.1.92025/06/141.4 年前
0.1.82025/03/261.6 年前
0.1.72025/01/071.8 年前

关于 @complyco/client-recorder-web 的常见问题

@complyco/client-recorder-web 是什么?

ComplyCo的客户端网络记录器

如何安装 @complyco/client-recorder-web?

在项目目录运行 npm install @complyco/client-recorder-web,或使用 pnpm add / yarn add / bun add。

@complyco/client-recorder-web 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@complyco/client-recorder-web 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@complyco/client-recorder-web 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@complyco/client-recorder-web 可以商用吗?

@complyco/client-recorder-web 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@complyco/client-recorder-web 的下载量有多少?

根据 npm 官方下载统计,@complyco/client-recorder-web 在 2026/10/11 – 2026/11/09 这 30 天内被下载 8,509 次,日均约 284 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@complyco/client-recorder-web 还在维护吗?

最新版本 0.3.1 发布于 2026/08/08(3 个月前);至今共发布 11 个版本,其中过去 12 个月发布了 3 个;首次发布于 2024/10/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。