# @amplitude/plugin-engagement-react-native 中文文档

规范地址：https://npmcn.com/package/%40amplitude/plugin-engagement-react-native/

版本：4\.3\.0
npm 元数据更新时间：2026-10-29T20:21:25.833Z
中文译文更新时间：2026-11-06T01:22:48.417Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40amplitude/plugin-engagement-react-native
原文对照：https://npmcn.com/package/%40amplitude/plugin-engagement-react-native/?lang=original
项目主页：https://amplitude.com/#readme

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

- 包体积（解压后）：151 kB，66 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：1 个
- peer 依赖：react \*，react-native \*，@react-native-async-storage/async-storage ^2\.1\.2
- 首次发布：2025-05-31T22:07:17.438Z
- 最新版本发布：2026-10-29T20:21:25.619Z
- 近 30 天下载量：75818（2026-10-06 至 2026-11-04，npm 官方下载统计）
- 已发布版本数：58（近 12 个月 33 个）

## 中文简介

原生反应的振幅插件

## 安装

```sh
npm install @amplitude/plugin-engagement-react-native
```

也可以使用：`pnpm add @amplitude/plugin-engagement-react-native`、`yarn add @amplitude/plugin-engagement-react-native`、`bun add @amplitude/plugin-engagement-react-native`

## README

# @ amplitude/plugin- engagement- react- native

原生反应的振幅插件

## 安装

要安装 :

-   添加 `@amplitude/analytics-react-native` 财务报告和审定财务报表 `@amplitude/plugin-engagement-react-native`
-   添加 `@react-native-async-storage/async-storage`
    -   为什么? 此为 `engagement` 本地模块, 但 CLI 只将您在应用程序中直接依赖的本地模块自动链接 `package.json`

```sh
npm install @amplitude/analytics-react-native
npm install @react-native-async-storage/async-storage
npm install @amplitude/plugin-engagement-react-native
```

重新运行 `pod install` 输入 `ios` 目录 :

```sh
$ cd ios
$ bundle exec pod install
```

## 使用量

### 设置代码

通过添加插件并按常态调用“ init” 设置 :

```
// index.js

import {Linking} from 'react-native';

import { init, add } from '@amplitude/analytics-react-native';
import { getPlugin, handleURL } from '@amplitude/plugin-engagement-react-native';

init('<<< YOUR API KEY HERE >>>');
add(getPlugin());

Linking.getInitialURL().then(async (url) => {
    if (url) {
    const didHandleURL = await handleURL(url);
    if (didHandleURL) { return; }

    // Handle a non-Amplitude SDK URL
    }
});

Linking.addEventListener('url', async ({ url }) => {
    const didHandleURL = await handleURL(url);
    if (didHandleURL) { return; }

    // Handle a non-Amplitude SDK URL
});
```

### 连接设置

如果您尚未设置, 请遵循此指南, 除了添加上述链接代码外, 在您的 React Industrial app 中启用深链接支持 : [https://reactnative.dev/docs/linking#enabling-deep-links 页面存档备份,存于互联网档案馆](https://reactnative.dev/docs/linking#enabling-deep-links)

然后,遵循阿尔法登机指南,为您Android和iOS项目中的深层链接设置"计划".

### 启动

最后,用用户的ID“启动”插件;SDK“启动”使指南和调查能够显示:

```
import {
  setDeviceId,
  setUserId,
} from '@amplitude/analytics-react-native';
import { useEffect } from 'react';
import { getPlugin } from '@amplitude/plugin-engagement-react-native';

export default function App() {
  useEffect(() => {
    //
    // NOTE: setting the User ID in @amplitude/analytics-react-native
    // --and-- passing it to boot() is necessary for now, but in a
    // future version will not be necessary
    //
    setUserId('rn-test-user-1');
    setDeviceId('test-device-1');
    getPlugin().boot('rn-test-user-1', 'test-device-1');
  }, []);

```

### 一体化

将《指南》和《调查》跟踪的活动转交分析提供者 非振幅分析,通过 `integrations` 改为 `boot()`每一个 集成是接收事件类型和事件属性的回调 每个跟踪事件:

```
getPlugin().boot({
  user: { user_id: 'rn-test-user-1', device_id: 'test-device-1' },
  integrations: [
    (eventType, eventProperties) => {
      // e.g. forward to your third-party analytics provider
      thirdPartyAnalytics.track(eventType, eventProperties);
    },
  ],
});
```

## 许可证

麻省理工学院

## 常见问题

### @amplitude/plugin-engagement-react-native 是什么？

原生反应的振幅插件

### 如何安装 @amplitude/plugin-engagement-react-native？

在项目目录运行 npm install @amplitude/plugin-engagement-react-native，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（\*）、react-native（\*）、@react-native-async-storage/async-storage（^2\.1\.2）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @amplitude/plugin-engagement-react-native 支持 TypeScript 吗？

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

### @amplitude/plugin-engagement-react-native 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @amplitude/plugin-engagement-react-native 可以商用吗？

@amplitude/plugin-engagement-react-native 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @amplitude/plugin-engagement-react-native 的下载量有多少？

根据 npm 官方下载统计，@amplitude/plugin-engagement-react-native 在 2026/10/06 – 2026/11/04 这 30 天内被下载 75,818 次，日均约 2,527 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @amplitude/plugin-engagement-react-native 还在维护吗？

最新版本 4\.3\.0 发布于 2026/10/30（8 天前）；至今共发布 58 个版本，其中过去 12 个月发布了 33 个；首次发布于 2025/06/01。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

