npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@seaart/spm-sdk

v1.1.8

Published

SeaArt SPM 埋点 SDK,支持自动采集、曝光、点击和批量上报

Readme

@seaart/spm-sdk

SeaArt SPM 埋点 SDK,支持自动获取规则并标记 DOM,同时采集点击、曝光、滚动、焦点、页面访问和自定义事件。

安装

npm install @seaart/spm-sdk

使用

import SpmSDK from '@seaart/spm-sdk';

SpmSDK.init({
  projectId: 'your-project-id',
  baseURL: 'https://api.example.com',
  appId: 'web_app',
  version: '1.1.8',
});

SpmSDK.setUserInfo({
  user_id: 'user-123',
});

SpmSDK.track('custom_submit', 'page|form|submit', {
  form_type: 'contact',
});

SDK 初始化后会自动监听 URL 变化、获取打点规则、标记 x-spm-code 元素并上报事件。

浏览器脚本也可以直接使用构建产物:

<script src="node_modules/@seaart/spm-sdk/dist/spm-sdk.umd.js"></script>
<script>
  window.SpmSDK.init({ projectId: 'your-project-id' });
</script>

配置

| 参数 | 必填 | 默认值 | 说明 | | --- | --- | --- | --- | | projectId | 是 | - | SPM 项目 ID | | baseURL | 否 | - | 透传给 @seaart/request-seaart 的请求基础地址;配置后规则和上报请求都使用该地址 | | apiEndpoint | 否 | https://aiart-auto-capture.dev.seaart.dev | 规则接口地址 | | reportEndpoint | 否 | https://aiart-openresty.dev.seaart.dev | 事件上报地址 | | namespace | 否 | release | 规则环境 | | appId | 否 | web_app | 应用 ID | | version | 否 | 1.0.0 | 上报的 SDK/应用版本 | | lang | 否 | [] | URL 多语言前缀 | | enableLog | 否 | false | 是否输出调试日志 | | enableAutoTracking | 否 | true | 是否监听 URL 变化 | | enableDynamicTracking | 否 | true | 是否监听动态 DOM | | token | 否 | Cookie T | 请求认证 Token |

配置 baseURL 后,请求路径为 /api/auto-capture/page/rules/fetch/log/v1/standard_report;未配置时继续使用 apiEndpointreportEndpoint

规则请求和事件上报均使用 @seaart/request-seaart 的 SeaArt 请求协议。由于该依赖当前 npm 版本包含 workspace:* 元数据,本包在构建产物中内置了请求内核,消费者安装本包时无需额外安装请求依赖。

API

SpmSDK.init(options)
SpmSDK.setUserInfo(userInfo)
SpmSDK.getUserInfo()
SpmSDK.clearUserInfo()
SpmSDK.track(eventName, spm, customProperties)
SpmSDK.trackClick(spm, customProperties)
SpmSDK.trackExposure(spm, customProperties)
SpmSDK.flush()
SpmSDK.refreshCurrentPage(forceReload)
SpmSDK.notifyUrlChange(path)
SpmSDK.getVersion()
SpmSDK.destroy()

DOM 属性

<button
  x-spm-code="page|button|submit"
  data-obj-id="button-1"
  data-conan-custom='{"campaign_id":"summer"}'
>
  提交
</button>

data-conan-custom 支持任意 JSON 字段;单独的 data-* 属性会覆盖 JSON 中同名字段。

开发

pnpm --filter @seaart/spm-sdk build
pnpm --filter @seaart/spm-sdk test