@amplitude/plugin-custom-enrichment-browser

中文文档
1.0.0发布于 2026/10/22MITTypeScriptESM + CJS构建来源已验证近 30 天下载 653万
原始使用文档
文档目录7 节
  1. Installation
  2. Usage
  3. 1. Import Amplitude packages
  4. 2. Instantiate custom enrichment plugin
  5. 3. Install plugin to Amplitude SDK
  6. 4. Initialize Amplitude SDK
  7. Result


@amplitude/plugin-custom-enrichment-browser

Official Browser SDK plugin for custom enrichment

Installation

Version 1.0.0 introduces a breaking dependency change: @amplitude/analytics-core is now a required peer dependency (^2.61.0), rather than a regular dependency installed by the plugin.

If you only use this plugin through @amplitude/analytics-browser, install the Browser SDK as usual. A Browser SDK release that bundles this plugin version supplies the compatible core; your application does not need an additional core declaration.

If you install or import this plugin directly, declare a compatible core in your application's dependencies, even if you also install the Browser SDK. For example, after plugin 1.0.0 is published:

# npm
npm install @amplitude/plugin-custom-enrichment-browser@^1.0.0 @amplitude/analytics-core@^2.61.0

# yarn
yarn add @amplitude/plugin-custom-enrichment-browser@^1.0.0 @amplitude/analytics-core@^2.61.0

When also using the Browser SDK, align the supplied core with its version within the supported peer range. Without a declared peer, Yarn PnP cannot resolve the plugin's published TypeScript declarations. The plugin's JavaScript currently imports only types from core; this change does not reduce the runtime bundle.

Usage

This plugin works on top of the Amplitude Browser SDK and allows custom functionality to execute on events. Plugin 1.0.0 requires a host that supplies core ^2.61.0. This stable peer range does not promise support for arbitrary core prerelease versions.

1. Import Amplitude packages

  • @amplitude/plugin-custom-enrichment-browser
import { customEnrichmentPlugin } from '@amplitude/plugin-custom-enrichment-browser';

2. Instantiate custom enrichment plugin

const customEnrichmentPlugin = customEnrichmentPlugin();

Options

3. Install plugin to Amplitude SDK

amplitude.add(customEnrichmentPlugin);

4. Initialize Amplitude SDK

amplitude.init('API_KEY');

Result

This plugin executes a user-defined script, defined within Amplitude Remote Configuration Settings.

Event type

  • No event type added

Event properties

  • Defined by user

版本与发布记录

@amplitude/plugin-custom-enrichment-browser 共发布 43 个版本,首次发布于 2026/03/20;过去 12 个月发布了 43 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.0latest2026/10/2217 天前
0.1.282026/10/2118 天前
0.1.272026/10/1623 天前
0.1.27-video-analytics-6.02026/10/1623 天前
0.1.262026/10/1425 天前
0.1.252026/10/0930 天前

其他发布通道:SR-3115 → 0.1.4-SR-3115.0,SR-3115-rc1 → 0.1.4-SR-3115-rc1.0,SR-3115-rc2 → 0.1.4-SR-3115-rc2.0,sr-3531-rc-2 → 0.1.6-sr-3531-rc-2.0,sr-idb-multitab-test-rc → 0.1.9-sr-idb-multitab-test-rc.0,sr-4646-rc → 0.1.10-sr-4646-rc.0。

关于 @amplitude/plugin-custom-enrichment-browser 的常见问题

如何安装 @amplitude/plugin-custom-enrichment-browser?

在项目目录运行 npm install @amplitude/plugin-custom-enrichment-browser,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@amplitude/analytics-core(^2.61.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@amplitude/plugin-custom-enrichment-browser 支持 TypeScript 吗?

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

@amplitude/plugin-custom-enrichment-browser 支持 ESM 还是 CommonJS?

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

@amplitude/plugin-custom-enrichment-browser 可以商用吗?

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

@amplitude/plugin-custom-enrichment-browser 的下载量有多少?

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

@amplitude/plugin-custom-enrichment-browser 还在维护吗?

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