magic-web-error-logging

Enforce structured logger.error calls with eventKey, errorKind, error, message, and context fields.

5.0k|557|Updated May 14, 2025
One-click install
npx skills add https://github.com/dtyq/magic --skill magic-web-error-logging
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: magic-web-error-logging
Source: https://github.com/dtyq/magic/tree/main/frontend/magic-web/.agents/skills/magic-web-error-logging
Command: npx skills add https://github.com/dtyq/magic --skill magic-web-error-logging

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Inconsistent or lossy error logging makes production failures hard to diagnose. This Skill ensures every logger.error call in the Magic Web frontend follows a structured contract that preserves original Error objects, historical messages, and bounded diagnostic context without leaking sensitive data.

Core Features & Use Cases

  • Structured Error Mapping: Guides conversion of legacy logger.error calls into the { eventKey, errorKind, error, message, context } shape across src, enterprise/src, and customer/src overlays.
  • Diagnostic Preservation Rules: Defines how to keep original Error objects, callback parameters, raw parsing evidence, and shared context builders while excluding credentials, tokens, and unbounded objects.
  • Review & Verification Workflow: Provides a prioritized review checklist plus verification commands (rg, vitest, git diff --check) to confirm no diagnostic information was lost.
  • Use Case: When migrating a catch block that previously logged logger.error(\Connection failed: ${error.message}`), the Skill directs you to keep the original Error at top level, assign eventKey: "voice_worker_connection_failed"anderrorKind: "network", and verify the /log-report` and Volcengine probe behavior.

Quick Start

Use the magic-web-error-logging skill to review and migrate the logger.error calls in my changed files to the structured error contract.

Frequently Asked Questions about magic-web-error-logging

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a structured logger.error call in TypeScript?

Pass a single object with required non-empty eventKey and errorKind strings, plus optional error, message, and context fields. Keep the original Error object at top level rather than passing only error.message, and put bounded diagnostic values in context with semantic keys.

How do I migrate legacy logger.error string calls to structured logging?

Identify the unified Logger first, then map the historical call: the stable failure scenario becomes eventKey, the original error value stays in top-level error, the historical description stays in message, and remaining bounded diagnostics move into context. Verify no historical argument is lost.

What errorKind values are supported in structured error logging?

The supported vocabulary is network, storage, render, permission, worker, lifecycle, timeout, invalid_state, quota, parse, database, and unknown. Use unknown when evidence does not support a narrower category rather than inferring from arbitrary error text.

Does structured error logging work with the Aliyun provider?

No. With MAGIC_APM.strategy set to Aliyun, the SDK initializes but the manual AliyunProvider.error() is currently a no-op. Only the Volcengine strategy sends structured manual and global errors via captureException, while self-hosted /log-report reporting works independently.

What data must never be included in error log context?

Never log access tokens, session tokens, API keys, passwords, signatures, complete business bodies, full attachment collections, circular objects, or unbounded runtime values. URLs and filenames should be evaluated for actual sensitivity and masked narrowly only when justified.

Why should the original Error object be kept instead of error.message?

A real Error controls the Volcengine probe exception message and stack, and the self-hosted record serializes its name, message, and stack. Passing only error.message loses the stack trace and forces creation of a synthetic error with a fabricated stack.