@amplitude/plugin-engagement-react-native

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

Amplitude Engagement plugin for React Native

原始使用文档
文档目录7 节
  1. Installation
  2. Usage
  3. Setup code
  4. Linking setup
  5. Boot
  6. Integrations
  7. License

@amplitude/plugin-engagement-react-native

Amplitude Engagement plugin for React Native

Installation

To install:

  • Add @amplitude/analytics-react-native and @amplitude/plugin-engagement-react-native
  • Also, add @react-native-async-storage/async-storage
    • Why? This is used by the engagement native module, but the CLI only auto links native modules which you directly depend on in your app’s package.json
npm install @amplitude/analytics-react-native
npm install @react-native-async-storage/async-storage
npm install @amplitude/plugin-engagement-react-native

Re-run pod install in the ios directory:

$ cd ios
$ bundle exec pod install

Usage

Setup code

Setup by adding the plugin and calling “init” as usual:

// 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
});

Linking setup

If you don't already have it set up, please follow this guide to enable deep-linking support in your React Native app in addition to adding the above Linking code: https://reactnative.dev/docs/linking#enabling-deep-links

Then, following the Alpha Onboarding guide to setup the "scheme" for the deep links in your Android and iOS projects.

Boot

Finally, “boot” the plugin with the user’s ID; "booting" the SDK enables Guides and Surveys to be shown:

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

To forward events tracked by the Guides and Surveys SDK to analytics providers other than Amplitude Analytics, pass integrations to boot(). Each integration is a callback that receives the event type and event properties for every tracked event:

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);
    },
  ],
});

License

MIT

版本与发布记录

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