@djangocfg/devtools

中文文档
2.1.655发布于 2026/11/12MITTypeScriptESM + CJS零依赖近 30 天下载 1.5万

Frontend devtools for django-cfg apps: error/console capture with backend ingest, plus a floating debug panel. One package, one event stream.

原始使用文档

@djangocfg/devtools

Frontend devtools for django-cfg apps. One package, one event stream:

  • Capture — window.onerror, unhandled rejections, console.warn/error, zod validation events from @djangocfg/api clients.
  • Ingest — errors/warnings are batched to POST /cfg/monitor/ingest/ (django-cfg's django_monitor extension) with dedupe, keepalive flush on unload, and a circuit breaker.
  • Debug panel — floating button (auto in dev, ?debug=1 in prod, ⌘D) with a filterable log feed and app-defined custom tabs.

Replaces the retired @djangocfg/monitor + @djangocfg/debuger pair.

Usage

// Root layout — that's the whole setup
import { Devtools } from '@djangocfg/devtools'

<Devtools project="my-app" environment={process.env.NODE_ENV} />
// Anywhere in client code
import { devtools } from '@djangocfg/devtools'

devtools.error('Payment widget crashed', { orderId })   // panel + backend
const log = devtools.log('CheckoutForm')                // panel only
log.info('step changed', { step })
// Server (route handlers / RSC)
import { serverDevtools } from '@djangocfg/devtools/server'

serverDevtools.configure({ project: 'my-app', baseUrl: process.env.API_URL })
await serverDevtools.captureError(err, { url: req.url })

In the browser console: window.devtools.status(), window.devtools.error('test').

Is it reaching the backend?

Ingest needs the API origin: <Devtools baseUrl>, or in BaseApp auth.apiUrl / apiUrl (for auth={false}), or NEXT_PUBLIC_API_URL baked in at build time. With none, devtools warns once in the console and drops events.

  • devtools.status() returns { ingest, baseUrl, queued, sent, failed, lastError, lastSentAt, circuitOpen }.
  • await devtools.ping() sends one info event (devtools ping) and resolves with status().
  • Server: python manage.py monitor_tail --frontend.

版本与发布记录

@djangocfg/devtools 共发布 164 个版本,首次发布于 2026/07/10;过去 12 个月发布了 164 个版本。

版本发布日期距今
2.1.655latest2026/11/12今天
2.1.6532026/11/12今天
2.1.6522026/11/11今天
2.1.6512026/11/111 天前
2.1.6502026/11/111 天前
2.1.6482026/11/111 天前

关于 @djangocfg/devtools 的常见问题

@djangocfg/devtools 是什么?

Frontend devtools for django-cfg apps: error/console capture with backend ingest, plus a floating debug panel. One package, one event stream.

如何安装 @djangocfg/devtools?

在项目目录运行 npm install @djangocfg/devtools,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.0.0)、zustand(^5.0.0)、react-dom(^19.0.0)、lucide-react(>=0.400.0)、@djangocfg/api(^2.1.655)、@djangocfg/ui-core(^2.1.655)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@djangocfg/devtools 支持 TypeScript 吗?

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

@djangocfg/devtools 支持 ESM 还是 CommonJS?

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

@djangocfg/devtools 可以商用吗?

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

@djangocfg/devtools 的下载量有多少?

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

@djangocfg/devtools 还在维护吗?

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