@auditaur/api

中文文档
0.15.1发布于 2026/10/31MITTypeScriptES Module构建来源已验证近 30 天下载 3700

Frontend telemetry API for Auditaur-enabled Tauri apps.

原始使用文档
文档目录5 节
  1. Install
  2. Quick start
  3. Debug drive bridge
  4. Custom invoke wrappers
  5. OpenTelemetry JS spans

@auditaur/api

Frontend telemetry helpers for Auditaur-enabled Tauri apps.

Use this package in a Tauri webview to capture frontend console logs, errors, wrapped Tauri IPC calls, Tauri events, and optional OpenTelemetry JS spans. Telemetry is sent to the tauri-plugin-auditaur backend plugin, which stores it in Auditaur's local SQLite session database.

Install

npm install @auditaur/api

Quick start

import { initAuditaur } from '@auditaur/api';

const auditaur = await initAuditaur({
  serviceName: 'my-tauri-app',
  onExportError(failure) {
    console.warn('Auditaur export failed', failure.error);
  },
});

export const invoke = auditaur.invoke;

By default, Auditaur instruments console logs, frontend errors, Tauri invokes, Tauri events, and W3C trace context propagation for wrapped invokes. Full payload capture is disabled by default.

Debug drive bridge

For local/debug UI automation, apps can explicitly opt into the Auditaur in-app drive bridge. The bridge lets auditaur drive execute Tauri-native selector operations from inside the WebView on every platform:

await initAuditaur({
  serviceName: 'my-tauri-app',
  driveBridge: {
    windowLabel: 'main',
    pollIntervalMs: 100,
  },
});

The bridge is disabled by default, requires the Auditaur Tauri plugin commands permitted by auditaur:default, and should only be enabled in development/test builds. It supports wait, exists, text, click, fill, type, press, hover, select, check, uncheck, evaluate, snapshot, and screenshot; action telemetry is logged without recording filled, typed, or selected text values. Bridge screenshots first try native WebView capture for occlusion-free WebView pixels; selector screenshots crop that WebView image and include screenshotScope=selector plus selectorRect. If WebView capture fails, Auditaur falls back to native window capture and then to a DOM text summary PNG when OS permissions or window matching prevent native capture. evaluate runs arbitrary JavaScript in the WebView, so keep the bridge restricted to development/test sessions. The bridge is intentionally single-window for now: enable it in exactly one WebView per Auditaur session, usually with windowLabel: 'main'. If multiple windows enable it in the same session, target selection is unsupported and may be ambiguous.

Custom invoke wrappers

If you build your own Tauri invoke wrapper, use the exported trace context helpers so backend commands annotated with #[tauri_plugin_auditaur::instrument_ipc] can continue the frontend trace:

import { AUDITAUR_TRACE_CONTEXT_ARG, createAuditaurTraceContext } from '@auditaur/api';

const args = {
  id: 'user-1',
  [AUDITAUR_TRACE_CONTEXT_ARG]: createAuditaurTraceContext(),
};

OpenTelemetry JS spans

Attach Auditaur's exporter to an existing OpenTelemetry JS tracer provider:

import { BasicTracerProvider, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { initAuditaur } from '@auditaur/api';

const auditaur = await initAuditaur({ serviceName: 'my-tauri-app' });

const provider = new BasicTracerProvider({
  spanProcessors: [
    new SimpleSpanProcessor(auditaur.createOpenTelemetrySpanExporter()),
  ],
});

See the Auditaur docs for full setup with the Rust Tauri plugin and CLI.

版本与发布记录

@auditaur/api 共发布 26 个版本,首次发布于 2026/06/06;过去 12 个月发布了 26 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.15.1latest2026/10/317 天前
0.15.02026/10/308 天前
0.14.02026/10/308 天前
0.13.02026/10/308 天前
0.12.32026/10/308 天前
0.12.22026/10/308 天前

关于 @auditaur/api 的常见问题

@auditaur/api 是什么?

Frontend telemetry API for Auditaur-enabled Tauri apps.

如何安装 @auditaur/api?

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

@auditaur/api 支持 TypeScript 吗?

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

@auditaur/api 支持 ESM 还是 CommonJS?

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

@auditaur/api 可以商用吗?

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

@auditaur/api 的下载量有多少?

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

@auditaur/api 还在维护吗?

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