@1sygnal/onesygnal-web-sdk

中文文档
1.0.4发布于 2026/10/07MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 2559

1Sygnal Web SDK — thin loader + CDN-hosted survey engine

原始使用文档
文档目录11 节
  1. Installation
  2. npm
  3. Script tag (auto-init)
  4. Usage
  5. Tracking events
  6. Identifying users
  7. Listening for survey events
  8. How it works
  9. Mobile safe-area insets
  10. Docs
  11. Other SDKs

1Sygnal Web SDK

Thin loader + CDN-hosted survey engine for 1Sygnal in-product surveys, event tracking, and user identification.

Installation

npm

npm install @1sygnal/onesygnal-web-sdk
import oneSygnal from '@1sygnal/onesygnal-web-sdk';

oneSygnal.init('your-api-key', { apiUrl: 'https://sdk-api.1sygnal.app' });

The package has a default export only — there's no { init, track, identify } named export.

Script tag (auto-init)

<script
  src="https://repo.1sygnal.app/js/1sygnal.js"
  data-api-key="your-api-key"
  data-api-url="https://sdk-api.1sygnal.app"
></script>

Usage

Tracking events

oneSygnal.track('button_click', { id: 'cta' });

Identifying users

oneSygnal.identify('user-123', { plan: 'pro' });

Also available: oneSygnal.logout() to clear session/user state, and oneSygnal.setSurveysEnabled(enabled) to toggle surveys at runtime.

Listening for survey events

oneSygnal.on('survey:completed', (event) => {
  // handle completion
});

Other available events: "survey:shown", "survey:step", "survey:dismissed". Unsubscribe with oneSygnal.off(event, callback).

How it works

init() returns void, not a Promise — it injects a <script> tag that loads the full SDK bundle from 1Sygnal's CDN, and queues track/identify/on/etc. calls until that bundle loads and signals readiness. There's nothing to await; calls made before the bundle is ready are queued and replayed once it is. This lets survey-triggering fixes and features ship to every embedded site immediately, without a dependency bump and redeploy.

Mobile safe-area insets

Bottom/top-anchored surveys use env(safe-area-inset-*) to clear notches and the home indicator on phones. Those env() values only resolve once the page opts in via:

<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">

init() patches this in automatically (appending viewport-fit=cover to an existing <meta name="viewport">, or adding one if the page has none), so this is a fallback, not a hard requirement — but setting it yourself in the page <head> is still recommended, since it takes effect before the SDK loads.

Docs

Full integration guide: https://docs.1sygnal.app

Other SDKs

版本与发布记录

@1sygnal/onesygnal-web-sdk 共发布 4 个版本,首次发布于 2026/08/20;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.4latest2026/10/071 个月前
1.0.32026/09/181 个月前
1.0.12026/08/242 个月前
1.0.02026/08/202 个月前

关于 @1sygnal/onesygnal-web-sdk 的常见问题

@1sygnal/onesygnal-web-sdk 是什么?

1Sygnal Web SDK — thin loader + CDN-hosted survey engine

如何安装 @1sygnal/onesygnal-web-sdk?

在项目目录运行 npm install @1sygnal/onesygnal-web-sdk,或使用 pnpm add / yarn add / bun add。

@1sygnal/onesygnal-web-sdk 支持 TypeScript 吗?

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

@1sygnal/onesygnal-web-sdk 支持 ESM 还是 CommonJS?

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

@1sygnal/onesygnal-web-sdk 可以商用吗?

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

@1sygnal/onesygnal-web-sdk 的下载量有多少?

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

@1sygnal/onesygnal-web-sdk 还在维护吗?

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