@amplitude/unified

中文文档
1.2.2发布于 2026/11/07MITTypeScriptESM + CJS构建来源已验证近 30 天下载 107.1万

Official Amplitude SDK for Web analytics, experiment, session replay, and more.

原始使用文档
文档目录11 节
  1. Installation
  2. Usage
  3. 1. Initialize Amplitude Unified SDK
  4. 2. Access SDK Features
  5. Configuration Options
  6. Shared Options
  7. Analytics Options
  8. Session Replay Options
  9. Experiment Options
  10. Guides and Surveys Options
  11. Learn More


@amplitude/unified

Official Amplitude SDK for Web analytics, experiment, session replay, Guides and Surveys, and more.

Full Amplitude Unified SDK Documentation lives at (https://amplitude.com/docs/sdks/analytics/browser/browser-unified-sdk)

Installation

This package is published on NPM registry and is available to be installed using npm and yarn.

# npm
npm install @amplitude/unified

# yarn
yarn add @amplitude/unified

Usage

The Unified SDK provides a single entry point for all Amplitude features, including Analytics, Experiment, and Session Replay. It simplifies the integration process by handling the initialization and configuration of all components.

1. Initialize Amplitude Unified SDK

import { Identify, experiment, identify, initAll, sessionReplay, track } from '@amplitude/unified';

await initAll('YOUR_API_KEY', {
  // Shared options for all SDKs (optional)
  serverZone: 'US', // or 'EU'
  instanceName: 'my-instance',

  // Analytics options
  analytics: {
    // Analytics configuration options
  },

  // Session Replay options
  sessionReplay: {
    // Session Replay configuration options
  },

  // Experiment options
  experiment: {
    // Experiment configuration options
  },

  // Guides and Surveys options
  engagement: {
    // Guides and Surveys configuration options
  },
});

2. Access SDK Features

The Unified SDK provides access to all Amplitude features through a single interface:

// Track events
track('Button Clicked', { buttonName: 'Sign Up' });

// Identify users
identify(new Identify().set('userType', 'premium'));

// Access Experiment features
const experimentClient = experiment();
if (experimentClient) {
  await experimentClient.fetch();
  const variant = experimentClient.variant('experiment-key');
}

// Access Session Replay features
await sessionReplay()?.flush(false);

// Access Guides and Surveys features via engagement global
const activeGuidesAndSurveys = window.engagement.gs.list();

Configuration Options

Shared Options

NameTypeDefaultDescription
serverZone'US' or 'EU''US'The server zone to use for all SDKs.
instanceNamestringundefinedA unique name for this instance of the SDK.

Analytics Options

All options from @amplitude/analytics-browser are supported. See the Analytics Browser SDK documentation for details.

Session Replay Options

All options from @amplitude/plugin-session-replay-browser are supported. See the Session Replay plugin documentation for details.

Experiment Options

All options from @amplitude/plugin-experiment-browser are supported. See the Experiment documentation for details.

Guides and Surveys Options

All options from @amplitude/engagement-browser are supported. See the Guides and Surveys documentation for details.

Learn More

版本与发布记录

@amplitude/unified 共发布 164 个版本,首次发布于 2025/04/23;过去 12 个月发布了 146 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.2.2latest2026/11/071 天前
1.2.2-sr-bfcache-pageshow-snapshot.02026/11/052 天前
1.2.12026/11/034 天前
1.2.02026/10/317 天前
1.1.44-video-analytics-8.02026/10/2811 天前
1.1.44-video-analytics-7.02026/10/2712 天前

其他发布通道:perfrecord-init-prelease → 1.0.0-perfrecord-init-prelease.0,SR-1975 → 1.0.0-SR-1975.0,zen-observable-migration → 1.0.0-zen-observable-migration.1,zen-plus-zoning → 1.0.0-zen-plus-zoning.2,feat-zoning → 1.0.0-feat-zoning.0,feat-zoning-1211 → 1.0.0-feat-zoning-1211.0。

关于 @amplitude/unified 的常见问题

@amplitude/unified 是什么?

Official Amplitude SDK for Web analytics, experiment, session replay, and more.

如何安装 @amplitude/unified?

在项目目录运行 npm install @amplitude/unified,或使用 pnpm add / yarn add / bun add。

@amplitude/unified 支持 TypeScript 吗?

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

@amplitude/unified 支持 ESM 还是 CommonJS?

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

@amplitude/unified 可以商用吗?

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

@amplitude/unified 的下载量有多少?

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

@amplitude/unified 还在维护吗?

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