@ariestools/pixel

中文文档
9.0.3发布于 2026/11/06LGPL-3.0-onlyTypeScriptES Module近 30 天下载 2963

Event Client for xylabs ESB

原始使用文档
文档目录207 节
  1. Install
  2. License
  3. Reference
  4. packages
  5. pixel
  6. Constructors
  7. Constructor
  8. Parameters
  9. Returns
  10. Methods
  11. trackEvents()
  12. Parameters
  13. Returns
  14. Constructors
  15. Constructor
  16. Returns
  17. Properties
  18. local
  19. session
  20. Methods
  21. toJson()
  22. Returns
  23. Constructors
  24. Constructor
  25. Returns
  26. Properties
  27. id
  28. Methods
  29. toString()
  30. Returns
  31. Extended by
  32. Type Parameters
  33. TData
  34. Constructors
  35. Constructor
  36. Returns
  37. Methods
  38. funnelStarted()
  39. Type Parameters
  40. Parameters
  41. Returns
  42. testStarted()
  43. Type Parameters
  44. Parameters
  45. Returns
  46. userClick()
  47. Type Parameters
  48. Parameters
  49. Returns
  50. viewContent()
  51. Type Parameters
  52. Parameters
  53. Returns
  54. Constructors
  55. Constructor
  56. Returns
  57. Properties
  58. fields
  59. Methods
  60. getUtmRecord()
  61. Returns
  62. toString()
  63. Returns
  64. update()
  65. Returns
  66. Properties
  67. api
  68. cid
  69. email?
  70. email_hash?
  71. exids?
  72. pixelId?
  73. queue
  74. Accessors
  75. instance
  76. Get Signature
  77. Methods
  78. init()
  79. Parameters
  80. Returns
  81. selectApi()
  82. Parameters
  83. Returns
  84. identify()
  85. Parameters
  86. Returns
  87. send()
  88. Type Parameters
  89. Parameters
  90. Returns
  91. Extends
  92. Type Parameters
  93. T
  94. Constructors
  95. Constructor
  96. Returns
  97. Overrides
  98. Methods
  99. funnelStarted()
  100. Parameters
  101. Returns
  102. Overrides
  103. purchase()
  104. Parameters
  105. Returns
  106. testStarted()
  107. Parameters
  108. Returns
  109. Overrides
  110. userClick()
  111. Parameters
  112. Returns
  113. Overrides
  114. viewContent()
  115. Parameters
  116. Returns
  117. Overrides
  118. Extended by
  119. Properties
  120. funnel?
  121. testData?
  122. Extends
  123. Properties
  124. funnel?
  125. Inherited from
  126. testData?
  127. Inherited from
  128. name
  129. Extends
  130. Properties
  131. funnel?
  132. Inherited from
  133. testData?
  134. Inherited from
  135. id
  136. name?
  137. price?
  138. value?
  139. Extends
  140. Properties
  141. funnel?
  142. Inherited from
  143. testData?
  144. Inherited from
  145. name
  146. Extends
  147. Properties
  148. funnel?
  149. Inherited from
  150. testData?
  151. Inherited from
  152. elementName
  153. elementType
  154. intent?
  155. placement?
  156. Properties
  157. cid
  158. create_time?
  159. email?
  160. email_hash?
  161. event?
  162. event_id?
  163. exids?
  164. fields?
  165. host?
  166. pathname?
  167. pixel?
  168. receive_time?
  169. referrer?
  170. local
  171. session
  172. rid?
  173. system?
  174. uid?
  175. utm?
  176. Extends
  177. Properties
  178. funnel?
  179. Inherited from
  180. testData?
  181. Inherited from
  182. name
  183. path
  184. Properties
  185. cid
  186. create_time?
  187. email?
  188. email_hash?
  189. event?
  190. event_id?
  191. exids?
  192. fields?
  193. host?
  194. ip?
  195. pathname?
  196. pixel?
  197. receive_time?
  198. rid?
  199. system?
  200. ua?
  201. uid?
  202. utm?
  203. browser?
  204. engine?
  205. os?
  206. platform?
  207. Credits

logo

@ariestools/pixel

npm license

Event Client for xylabs ESB

Install

Using npm:

npm install {{name}}

Using yarn:

yarn add {{name}}

Using pnpm:

pnpm add {{name}}

Using bun:

bun add {{name}}

License

See the LICENSE file for license rights and limitations (LGPL-3.0-only).

Reference

packages

pixel

### .temp-typedoc

  ### classes

    ### <a id="PixelApi"></a>PixelApi

@ariestools/pixel


HTTP client for sending tracking events to the XY Labs pixel API.

Constructors

Constructor

new PixelApi(baseUri?): PixelApi;

Parameters

baseUri?

string = 'prod'

Returns

PixelApi

Methods

trackEvents()

trackEvents(events): Promise<any>;

Sends an array of user events to the tracking API.

Parameters

events

[UserEvent]#../interfaces/UserEvent

The events to submit

Returns

Promise<any>

The response data from the API

    ### <a id="Referrer"></a>Referrer

@ariestools/pixel


Tracks and persists the document referrer in both session and local storage.

Constructors

Constructor

new Referrer(): Referrer;

Returns

Referrer

Properties

local

local: string;

session

session: string;

Methods

toJson()

toJson(): 
  | {
  local: string;
  session: string;
}
  | undefined;

Returns the referrer data as a JSON object, or undefined if both values are empty.

Returns

| { local: string; session: string; } | undefined

An object with local and session referrer strings, or undefined

    ### <a id="UniqueUserId"></a>UniqueUserId

@ariestools/pixel


Generates and persists a unique user identifier in localStorage.

Constructors

Constructor

new UniqueUserId(): UniqueUserId;

Returns

UniqueUserId

Properties

id

id: string;

Methods

toString()

toString(): string;

Returns the unique user ID as a string.

Returns

string

    ### <a id="UserEventHandler"></a>UserEventHandler

@ariestools/pixel


Abstract base class for handling user tracking events.

Extended by

Type Parameters

TData

TData extends EmptyObject

Constructors

Constructor

new UserEventHandler<TData>(): UserEventHandler<TData>;

Returns

UserEventHandler<TData>

Methods

funnelStarted()

abstract funnelStarted<T>(fields): Promisable<void>;

Tracks a funnel-started event.

Type Parameters

T

T extends object

Parameters

fields

FunnelStartedFields | T

Returns

Promisable<void>


testStarted()

abstract testStarted<T>(fields): Promisable<void>;

Tracks a test-started event.

Type Parameters

T

T extends object

Parameters

fields

TestStartedFields | T

Returns

Promisable<void>


userClick()

abstract userClick<T>(fields): Promisable<void>;

Tracks a user click event.

Type Parameters

T

T extends object

Parameters

fields

UserClickFields | T

Returns

Promisable<void>


viewContent()

abstract viewContent<T>(fields): Promisable<void>;

Tracks a view-content event.

Type Parameters

T

T extends object

Parameters

fields

T | ViewContentFields

Returns

Promisable<void>

    ### <a id="UtmFields"></a>UtmFields

@ariestools/pixel


Tracks UTM campaign parameters from query strings, persisting history in localStorage.

Constructors

Constructor

new UtmFields(): UtmFields;

Returns

UtmFields

Properties

fields

fields: Record<string, string>[] = [];

Methods

getUtmRecord()

getUtmRecord(): Record<string, string> | null;

Parses UTM parameters from the current URL query string.

Returns

Record<string, string> | null

A record of UTM key-value pairs, or null if none are present


toString()

toString(): string;

Returns the UTM fields history as a JSON string.

Returns

string


update()

update(): Record<string, string>[];

Checks the query string for new UTM values and appends them to the history if changed.

Returns

Record<string, string>[]

The current UTM fields array, or undefined if empty

    ### <a id="XyPixel"></a>XyPixel

@ariestools/pixel


Singleton pixel tracker that queues and sends user events to the XY Labs tracking API.

Properties

api

static api: PixelApi;

cid

cid: string;

email?

optional email?: string;

email_hash?

optional email_hash?: string | null;

exids?

optional exids?: ExIds;

pixelId?

optional pixelId?: string;

queue

queue: UserEvent[] = [];

Accessors

instance

Get Signature

get static instance(): XyPixel;

Returns the singleton XyPixel instance, throwing if not yet initialized.

Returns

XyPixel

Methods

init()

static init(pixelId): XyPixel;

Initializes the XyPixel singleton with the given pixel ID.

Parameters

pixelId

string

The pixel identifier for this tracking instance

Returns

XyPixel

The newly created XyPixel instance


selectApi()

static selectApi(api): void;

Replaces the default PixelApi instance used for sending events.

Parameters

api

PixelApi

The PixelApi instance to use

Returns

void


identify()

identify(email?): void;

Associates an email address with this pixel instance, hashing it for privacy.

Parameters

email?

string

The email address to identify the user with

Returns

void


send()

send<T>(
   event, 
   fields?, 
eventId?): Promise<void>;

Queues a tracking event and attempts to flush the queue to the API.

Type Parameters

T

T extends Record<string, unknown>

Parameters

event

string

The event name

fields?

T

Optional event-specific fields

eventId?

string

Optional unique event identifier

Returns

Promise<void>

    ### <a id="XyUserEventHandler"></a>XyUserEventHandler

@ariestools/pixel


Concrete event handler that sends tracking events through the XyPixel singleton.

Extends

Type Parameters

T

T extends EmptyObject = EmptyObject

Constructors

Constructor

new XyUserEventHandler<T>(): XyUserEventHandler<T>;

Returns

XyUserEventHandler<T>

Overrides

UserEventHandler.constructor

Methods

funnelStarted()

funnelStarted(fields): Promise<void>;

Sends a funnel-started event via the pixel API.

Parameters

fields

FunnelStartedFields | T

Returns

Promise<void>

Overrides

UserEventHandler.funnelStarted


purchase()

purchase(fields): Promise<void>;

Sends a purchase event via the pixel API.

Parameters

fields

PurchaseFields | T

Returns

Promise<void>


testStarted()

testStarted(fields): Promise<void>;

Sends a test-started event via the pixel API.

Parameters

fields

TestStartedFields | T

Returns

Promise<void>

Overrides

UserEventHandler.testStarted


userClick()

userClick(fields): Promise<void>;

Sends a user click event via the pixel API.

Parameters

fields

UserClickFields | T

Returns

Promise<void>

Overrides

UserEventHandler.userClick


viewContent()

viewContent(fields): Promise<void>;

Sends a view-content event via the pixel API.

Parameters

fields

ViewContentFields | T

Returns

Promise<void>

Overrides

UserEventHandler.viewContent

  ### interfaces

    ### <a id="CommonFields"></a>CommonFields

@ariestools/pixel


Common fields shared across all tracking event types.

Extended by

Properties

funnel?

optional funnel?: string;

testData?

optional testData?: string;
    ### <a id="FunnelStartedFields"></a>FunnelStartedFields

@ariestools/pixel


Fields for a funnel-started tracking event.

Extends

Properties

funnel?

optional funnel?: string;

Inherited from

CommonFields.funnel


testData?

optional testData?: string;

Inherited from

CommonFields.testData


name

name: string;
    ### <a id="PurchaseFields"></a>PurchaseFields

@ariestools/pixel


Fields for a purchase tracking event.

Extends

Properties

funnel?

optional funnel?: string;

Inherited from

CommonFields.funnel


testData?

optional testData?: string;

Inherited from

CommonFields.testData


id

id: string;

name?

optional name?: string;

price?

optional price?: number;

value?

optional value?: number;
    ### <a id="TestStartedFields"></a>TestStartedFields

@ariestools/pixel


Fields for a test-started tracking event (e.g. A/B test).

Extends

Properties

funnel?

optional funnel?: string;

Inherited from

CommonFields.funnel


testData?

optional testData?: string;

Inherited from

CommonFields.testData


name

name: string;
    ### <a id="UserClickFields"></a>UserClickFields

@ariestools/pixel


Fields for a user click tracking event.

Extends

Properties

funnel?

optional funnel?: string;

Inherited from

CommonFields.funnel


testData?

optional testData?: string;

Inherited from

CommonFields.testData


elementName

elementName: string;

elementType

elementType: string;

intent?

optional intent?: string;

placement?

optional placement?: string;
    ### <a id="UserEvent"></a>UserEvent

@ariestools/pixel


Represents a single user tracking event to be sent to the pixel API.

Properties

cid

cid: string;

create_time?

optional create_time?: number;

email?

optional email?: string;

email_hash?

optional email_hash?: string;

event?

optional event?: string;

event_id?

optional event_id?: string;

exids?

optional exids?: ExIds;

fields?

optional fields?: Record<string, unknown>;

host?

optional host?: string;

pathname?

optional pathname?: string;

pixel?

optional pixel?: string;

receive_time?

optional receive_time?: number;

referrer?

optional referrer?: object;

local

local: string;

session

session: string;

rid?

optional rid?: string;

system?

optional system?: ParsedResult;

uid?

optional uid?: string;

utm?

optional utm?: Record<string, string>[] | Record<string, string[]>;
    ### <a id="ViewContentFields"></a>ViewContentFields

@ariestools/pixel


Fields for a view-content tracking event.

Extends

Properties

funnel?

optional funnel?: string;

Inherited from

CommonFields.funnel


testData?

optional testData?: string;

Inherited from

CommonFields.testData


name

name: string;

path

path: string;
    ### <a id="XyLabsTrackingEventJson"></a>XyLabsTrackingEventJson

@ariestools/pixel


JSON structure for an XY Labs tracking event as stored or transmitted.

Properties

cid

cid: string;

create_time?

optional create_time?: number;

email?

optional email?: string;

email_hash?

optional email_hash?: string;

event?

optional event?: string;

event_id?

optional event_id?: string;

exids?

optional exids?: Record<string, string>;

fields?

optional fields?: Record<string, unknown>;

host?

optional host?: string;

ip?

optional ip?: string;

pathname?

optional pathname?: string;

pixel?

optional pixel?: string;

receive_time?

optional receive_time?: number;

rid?

optional rid?: string;

system?

optional system?: unknown;

ua?

optional ua?: string;

uid?

optional uid?: string;

utm?

optional utm?: Record<string, string>[] | Record<string, string[]>;
  ### interfaces

    ### <a id="UserEventSystem"></a>UserEventSystem

@ariestools/pixel


interface UserEventSystem

Parsed browser/OS/engine information from the user agent string.

Properties

browser?

optional browser: UserEventSystemBrowser;

engine?

optional engine: UserEventSystemEngine;

os?

optional os: UserEventSystemOS;

platform?

optional platform: UserEventSystemPlatform;

Credits

Made with 🔥 and ❄️ by XY Labs

版本与发布记录

@ariestools/pixel 共发布 24 个版本,首次发布于 2026/07/07;过去 12 个月发布了 24 个版本。

版本发布日期距今
9.0.3latest2026/11/062 天前
9.0.22026/10/2711 天前
9.0.12026/09/251 个月前
9.0.02026/09/171 个月前
8.3.02026/09/062 个月前
8.2.02026/08/282 个月前

关于 @ariestools/pixel 的常见问题

@ariestools/pixel 是什么?

Event Client for xylabs ESB

如何安装 @ariestools/pixel?

在项目目录运行 npm install @ariestools/pixel,或使用 pnpm add / yarn add / bun add。

@ariestools/pixel 支持 TypeScript 吗?

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

@ariestools/pixel 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@ariestools/pixel 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=26。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@ariestools/pixel 可以商用吗?

@ariestools/pixel 使用 LGPL-3.0-only 许可。弱 Copyleft:作为库被调用时通常不要求开源你自己的代码,但修改库本身需以 LGPL 开源;前端打包合并后的适用边界存在不同理解。以上为概括,不构成法律意见,请以许可原文为准。

@ariestools/pixel 的下载量有多少?

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

@ariestools/pixel 还在维护吗?

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