@amplitude/plugin-engagement-react-native

中文文档
4.3.0发布于 2026/10/30MITTypeScriptCommonJS近 30 天下载 7.6万

原生反应的振幅插件

中文使用文档
文档目录7 节
  1. 安装
  2. 使用量
  3. 设置代码
  4. 连接设置
  5. 启动
  6. 一体化
  7. 许可证

@ amplitude/plugin- engagement- react- native

原生反应的振幅插件

安装

要安装 :

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

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

$ 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 页面存档备份,存于互联网档案馆

然后,遵循阿尔法登机指南,为您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 共发布 58 个版本,首次发布于 2025/06/01;过去 12 个月发布了 33 个版本。

版本发布日期距今
4.3.0latest2026/10/308 天前
4.2.02026/10/2018 天前
4.1.02026/10/0929 天前
4.0.12026/09/221 个月前
4.0.02026/09/221 个月前
3.14.02026/09/032 个月前

关于 @amplitude/plugin-engagement-react-native 的常见问题

@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 和提交记录判断。