# @adobe/helix-rum-enhancer 中文文档

规范地址：https://npmcn.com/package/%40adobe/helix-rum-enhancer/

版本：2\.51\.0
npm 元数据更新时间：2026-10-29T09:16:09.931Z
中文译文更新时间：2026-11-06T12:53:24.678Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40adobe/helix-rum-enhancer
原文对照：https://npmcn.com/package/%40adobe/helix-rum-enhancer/?lang=original
项目主页：https://github.com/adobe/helix-rum-enhancer#readme
源码仓库：https://github.com/adobe/helix-rum-enhancer

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：356 kB，67 个文件
- 模块格式：ES Module
- TypeScript 类型：未声明
- 运行依赖：0 个
- 首次发布：2022-07-08T09:44:10.954Z
- 最新版本发布：2026-10-29T09:16:09.513Z
- 近 30 天下载量：3176（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：157（近 12 个月 15 个）

## 中文简介

Helix RUM 增强器

## 安装

```sh
npm install @adobe/helix-rum-enhancer
```

也可以使用：`pnpm add @adobe/helix-rum-enhancer`、`yarn add @adobe/helix-rum-enhancer`、`bun add @adobe/helix-rum-enhancer`

## README

# Helix RUM 增强器

> 将高级功能添加到 Helix RUM 收藏( 客户端)

## 状态

[![codecov](https://img.shields.io/codecov/c/github/adobe/helix-rum-enhancer.svg)](https://codecov.io/gh/adobe/helix-rum-enhancer) [![GitHub Actions](https://img.shields.io/github/actions/workflow/status/adobe/helix-rum-enhancer/main.yaml)](https://github.com/adobe/helix-rum-enhancer/actions/workflows/main.yaml) [![GitHub license](https://img.shields.io/github/license/adobe/helix-rum-enhancer.svg)](https://github.com/adobe/helix-rum-enhancer/blob/master/LICENSE.txt) [![GitHub issues](https://img.shields.io/github/issues/adobe/helix-rum-enhancer.svg)](https://github.com/adobe/helix-rum-enhancer/issues) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

## 使用量

这个库是用来配合和加载的 `sampleRUM` 函数在 [螺旋工程](https://github.com/adobe/helix-project-boilerplate/blob/main/scripts/scripts.js) 或者说 [Helix RUM 联合来文](https://github.com/adobe/helix-rum-js)。 。 。 .

它将增加以下新的检查站:

-   `cwv`: 核心网络生命号收藏
-   `pagesviewed`:帮助估计用户平均看到多少页的数字.
-   `click`: 单击文档中的任意位置
-   `viewblock`: 一个螺旋块已滚动到视图端口
-   `viewmedia`: Helix Media Bus 主持的一幅图像或视频被滚动到取景口
-   `reload`, (中文(简体) ), `navigate`, (中文(简体) ), `enter`: 取决于当前页面是如何访问的
-   `formsubmit`: 当提交表格时

### 这个 `source` 参数和 `sourceSelector`

这个 `source` 参数是可用于识别事件源的字符串. 它可以用来识别事件的来源,如按钮,链接,形式等. 它代表着一种理想化的CSS选择器,既可人读又具体,足以在文档中识别出事件源头,即使无法访问 角膜文档。 它被理想化了,因为它假装DOM会使用有简洁语义的现代HTML,即使实际文档使用 `class` 对事物的价值 以语义HTML元素更好地代表.

这个 `sourceSelector` 函数是使用 DOM 元素并返回描述函数 `source` 参数。 如果该元素具有 `data-rum-source` 属性,其值被用作 `source` 参数。 否则,该函数试图生成一个 `source` 基于元素标记名称、类名称和文本内容的参数.

A. 结构 `source` 参数如下:

```
<context> <element>#<identifier>
```

三部分都是可选的

`context` 实值

-   `form` 用于窗体元素
-   `dialog` 用于对话框元素,或固定位置且正高z-指数的母容器
-   `.block-name` 用于螺旋块
-   `header`, (中文(简体) ), `footer`, (中文(简体) ), `nav`, (中文(简体) ), `aside` 主要场地结构
-   `#id` 如果有容器标识,则作为倒置

`element` 实值

-   `button` 按钮,或看起来像按钮的链接(例如,有类) `button` 或者说 `btn` 或者说 `cta`(中文(简体) )
-   `img` 图像
-   `video` 视频
-   `a` 对于不是按钮的链接
-   `input[type="text"]` 用于输入元素(支持所有类型)
-   `select`, (中文(简体) ), `textarea`其他形式元素的等

`identifier` 实值

-   页:1 `id` 元素的属性,如果提供
-   首个 `.class` 如果有的话
-   其它省略

即使一个 `identifier` 提供,如果 `context` 财务报告和审定财务报表 `element` 建议: `source` 参数更可读,更容易理解.

## 发展

### 构建

```bash
$ npm install
```

### 测试

```bash
$ npm test
```

### 林特

```bash
$ npm run lint
```

### 剪取释放前

释放由 [语义释放](https://github.com/semantic-release/semantic-release),然后当 PR 合并到 `main` 或 `1.x` 树枝。 合并为 `beta`,将创建预发版.

## 常见问题

### @adobe/helix-rum-enhancer 是什么？

Helix RUM 增强器

### 如何安装 @adobe/helix-rum-enhancer？

在项目目录运行 npm install @adobe/helix-rum-enhancer，或使用 pnpm add / yarn add / bun add。

### @adobe/helix-rum-enhancer 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/adobe\_\_helix-rum-enhancer 是否存在。

### @adobe/helix-rum-enhancer 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @adobe/helix-rum-enhancer 可以商用吗？

@adobe/helix-rum-enhancer 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @adobe/helix-rum-enhancer 的下载量有多少？

根据 npm 官方下载统计，@adobe/helix-rum-enhancer 在 2026/10/05 – 2026/11/03 这 30 天内被下载 3,176 次，日均约 106 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @adobe/helix-rum-enhancer 还在维护吗？

最新版本 2\.51\.0 发布于 2026/10/29（9 天前）；至今共发布 157 个版本，其中过去 12 个月发布了 15 个；首次发布于 2022/07/08。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

