@amplitude/segment-session-replay-wrapper

中文文档
0.4.1-targetedcapture.0发布于 2024/08/24MITTypeScriptESM + CJS近 30 天下载 1.6万

Wrapper to enable usage of Segment with Amplitude's Session Replay product

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


@amplitude/segment-session-replay-wrapper

This package is a wrapper to facilitate a one-line 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-wrapper" --save

# yarn
yarn add @amplitude/segment-session-replay-wrapper"

Usage

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

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

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

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 first checks if userId is set, if not, anonymousId is used.

版本与发布记录

@amplitude/segment-session-replay-wrapper 共发布 8 个版本,首次发布于 2024/06/28;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.4.1-targetedcapture.0latest2024/08/242 年前
0.4.02024/08/242 年前
0.3.2-targetedcapture.02024/08/102 年前
0.3.12024/07/242 年前
0.3.02024/07/182 年前
0.1.02024/06/292 年前

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

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

Wrapper to enable usage of Segment with Amplitude's Session Replay product

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

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

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

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

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

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

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

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

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

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

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

最新版本 0.4.1-targetedcapture.0 发布于 2024/08/24(2 年前);至今共发布 8 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/06/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。