@amplitude/amp-semantic

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

Shared package foundation for Amplitude semantic event capture

原始使用文档

@amplitude/amp-semantic

Internal, composable semantic capture runtime for Amplitude. This increment installs no production event recorders and is not connected to Session Replay.

The host supplies a document, window, and transport callback. createSemanticCapture accepts typed recorder factories and optional per-family budgets (200 events per session by default). With no recorders supplied it emits nothing and installs no browser listeners.

The runtime owns opt-in sampling, start/stop and session reset, event version/timestamp/identity stamping, host signals, subscriptions, exception isolation, and cleanup rollback. Sampling and caps survive stop/start and reset only for a new session. Identity is allocated lazily when an event is accepted; its fallback is document-scoped memory, with no storage access.

Recorders register teardown immediately with onCleanup when setup can fail. canEmit lets them avoid expensive payload work at capacity. dropped returns delivery-cap diagnostics; recorders acknowledge successfully delivered diagnostics with clearDropped.

The snapshot host signal describes an accepted full snapshot; the runtime does not subscribe to rrweb itself. The host remains responsible for privacy-safe payloads, recording consent, transport, and any persisted tab identity.

Context, Session Replay integration, and visibility are added in separate follow-up PRs. No analytics SDK depends on this package in this increment.

Development

From the repository root, install dependencies and build with Node 24, pnpm install, and pnpm build. Run pnpm --filter @amplitude/amp-semantic test for runtime lifecycle and public contract tests.

版本与发布记录

@amplitude/amp-semantic 共发布 5 个版本,首次发布于 2026/10/23;过去 12 个月发布了 5 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.2.0latest2026/11/071 天前
0.2.0-sr-bfcache-pageshow-snapshot.0sr-bfcache-pageshow-snapshot2026/11/052 天前
0.2.0-codexsemantic-review-integration.0codexsemantic-review-integration2026/10/2315 天前
0.0.1alpha2026/10/2315 天前
0.0.0-stage2026/10/2315 天前

关于 @amplitude/amp-semantic 的常见问题

@amplitude/amp-semantic 是什么?

Shared package foundation for Amplitude semantic event capture

如何安装 @amplitude/amp-semantic?

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

@amplitude/amp-semantic 支持 TypeScript 吗?

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

@amplitude/amp-semantic 支持 ESM 还是 CommonJS?

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

@amplitude/amp-semantic 可以商用吗?

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

@amplitude/amp-semantic 的下载量有多少?

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

@amplitude/amp-semantic 还在维护吗?

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