@amplitude/segment-session-replay-plugin

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

Plugin for Segment's analytics.js library to support Amplitude's Session Replay.

原始使用文档
文档目录4 节
  1. Installation
  2. Usage
  3. Segment Plugin Architecture
  4. User ID to Device ID mapping


@amplitude/segment-session-replay-plugin

This package is a wrapper to facilitate integration between Segment and Amplitude's Session Replay SDK. This package currently only supports the Segment Amplitude (Actions) destination.

Installation

This package is published on NPM registry and is available to be installed using npm and yarn. Amplitude's Session Replay SDK is included in this package, and does not need to be installed separately.

# npm
npm install @amplitude/segment-session-replay-plugin --save

# yarn
yarn add @amplitude/segment-session-replay-plugin

Usage

import { AnalyticsBrowser } from '@segment/analytics-next';
import { createSegmentActionsPlugin } from '@amplitude/segment-session-replay-plugin';

export const SegmentAnalytics = AnalyticsBrowser.load({
  writeKey: SEGMENT_API_KEY,
});

createSegmentActionsPlugin({
    segmentInstance: SegmentAnalytics,
    amplitudeApiKey: AMPLITUDE_API_KEY,
    sessionReplayOptions: {
        logLevel: 4,
        sampleRate: 1,
        debugMode: true,
    },
    enableWrapperDebug: true,
});

SegmentAnalytics.track("Immediate Event");

The sessionReplayOptions parameter properties match those documented for the Session Replay Standalone SDK.

Segment Plugin Architecture

This wrapper makes use of Segment's plugin architecture, which ensures that all track and page events are decorated with the Session Replay ID event property.

User ID to Device ID mapping

Following Segment's documentation, the wrapper maps the Segment user id to the Amplitude device id. To determine the device id for session replay captures, the wrapper uses the anonymousId unless sessionReplayOptions.deviceId is provided.

版本与发布记录

@amplitude/segment-session-replay-plugin 共发布 176 个版本,首次发布于 2025/05/15;过去 12 个月发布了 126 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.0.55latest2026/11/071 天前
0.0.55-sr-bfcache-pageshow-snapshot.02026/11/052 天前
0.0.542026/10/317 天前
0.0.54-video-analytics-8.02026/10/2811 天前
0.0.54-video-analytics-7.02026/10/2712 天前
0.0.54-codexsemantic-review-integration.02026/10/2315 天前

其他发布通道:prereleasenetworkcapture → 0.0.0-prereleasenetworkcapture.0,networkcaptureprerelease → 0.0.0-networkcaptureprerelease.0,networktrackingprereleasemay → 0.0.0-networktrackingprereleasemay.0,frustrationanalytics → 0.0.0-frustrationanalytics.0,fixwebworkerscript → 0.0.0-fixwebworkerscript.0,fixsdk-init → 0.0.0-fixsdk-init.0。

关于 @amplitude/segment-session-replay-plugin 的常见问题

@amplitude/segment-session-replay-plugin 是什么?

Plugin for Segment's analytics.js library to support Amplitude's Session Replay.

如何安装 @amplitude/segment-session-replay-plugin?

在项目目录运行 npm install @amplitude/segment-session-replay-plugin,或使用 pnpm add / yarn add / bun add。

@amplitude/segment-session-replay-plugin 支持 TypeScript 吗?

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

@amplitude/segment-session-replay-plugin 支持 ESM 还是 CommonJS?

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

@amplitude/segment-session-replay-plugin 可以商用吗?

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

@amplitude/segment-session-replay-plugin 的下载量有多少?

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

@amplitude/segment-session-replay-plugin 还在维护吗?

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