Telemetry
Quick Start
Use this skill to add lightweight app instrumentation that helps debug behavior
without turning the codebase into a logging landfill. Prefer Apple's unified
logging APIs and verify the events after a build/run loop.
Core Guidelines
- Prefer
Logger from the OSLog framework for structured app logs.
- Give each feature a clear subsystem/category pair so runtime filtering stays easy.
- Log meaningful user and app lifecycle events: window opening, sidebar selection changes, menu commands, menu bar extra actions, sync/load milestones, and unexpected fallback paths.
- Keep info logs concise and stable. Use debug logs for noisy state details.
- Do not log secrets, auth tokens, personal data, or raw document contents.
- Add signposts only when measuring timing or performance spans; do not overinstrument by default.
Minimal Logger Pattern
import OSLog
private let logger = Logger(
subsystem: Bundle.main.bundleIdentifier ?? "SampleApp",
category: "Sidebar"
)
@MainActor
func selectItem(_ item: SidebarItem) {
logger.info("Selected sidebar item: \(item.id, privacy: .public)")
selection = item.id
}
Use feature-specific categories like Windowing, Commands, MenuBar, Sidebar,
Sync, or Import so logs can be filtered quickly.
Workflow
Identify the behavior that needs observability.
- Window open/close
- Sidebar or inspector selection changes
- Menu or keyboard command actions
- Menu bar extra actions
- Background load/sync/import events
- Error and recovery paths
Add the smallest useful instrumentation.
- Create one
Logger per feature area or type.
- Log action boundaries and key state transitions.
- Prefer one high-signal line per user action over noisy value dumps.
Build and run the app.
- Use
build-run-debug for the build/run loop.
- If
script/build_and_run.sh exists, prefer ./script/build_and_run.sh --telemetry for live telemetry checks or ./script/build_and_run.sh --logs for broader process logs.
- Exercise the UI or command path that should emit telemetry.
Read runtime logs and verify the event fired.
- Use Console.app with a process/subsystem filter when that is the fastest manual check.
- Use
log stream --style compact --predicate 'process == "AppName"' for live terminal verification.
- Prefer tighter predicates when you know the subsystem/category:
log stream --style compact --predicate 'subsystem == "com.example.app" && category == "Sidebar"'
Tighten or remove instrumentation.
- If the event fires, keep only the logs that remain useful for future debugging.
- If it does not fire, move the log closer to the suspected control path and rerun.
Verification Checklist
- The app builds after telemetry changes.
- The relevant action emits exactly one clear log line or a small bounded sequence.
- The log can be filtered by process, subsystem, or category.
- No sensitive payloads are written to unified logs.
- Noisy temporary debug logs are removed or demoted before finishing.
Guardrails
- Do not use
print as the primary app telemetry mechanism for macOS app code.
- Do not leave a dense trail of permanent debug logs around every state mutation.
- Do not claim an event is wired correctly until you have a concrete verification path through Console,
log stream, or captured process output.
- If the debugging task is mostly about crash/backtrace analysis rather than action telemetry, switch to
build-run-debug.
1---2name: telemetry3description: Add and verify lightweight macOS runtime telemetry. Use when wiring Logger events or inspecting logs for windows, sidebars, menus, and actions.4metadata:5 source: https://skillmd.com/skills/concertonotes/telemetry6---78# Telemetry910## Quick Start1112Use this skill to add lightweight app instrumentation that helps debug behavior13without turning the codebase into a logging landfill. Prefer Apple's unified14logging APIs and verify the events after a build/run loop.1516## Core Guidelines1718- Prefer `Logger` from the `OSLog` framework for structured app logs.19- Give each feature a clear subsystem/category pair so runtime filtering stays easy.20- Log meaningful user and app lifecycle events: window opening, sidebar selection changes, menu commands, menu bar extra actions, sync/load milestones, and unexpected fallback paths.21- Keep info logs concise and stable. Use debug logs for noisy state details.22- Do not log secrets, auth tokens, personal data, or raw document contents.23- Add signposts only when measuring timing or performance spans; do not overinstrument by default.2425## Minimal Logger Pattern2627```swift28import OSLog2930private let logger = Logger(31 subsystem: Bundle.main.bundleIdentifier ?? "SampleApp",32 category: "Sidebar"33)3435@MainActor36func selectItem(_ item: SidebarItem) {37 logger.info("Selected sidebar item: \(item.id, privacy: .public)")38 selection = item.id39}40```4142Use feature-specific categories like `Windowing`, `Commands`, `MenuBar`, `Sidebar`,43`Sync`, or `Import` so logs can be filtered quickly.4445## Workflow46471. Identify the behavior that needs observability.48 - Window open/close49 - Sidebar or inspector selection changes50 - Menu or keyboard command actions51 - Menu bar extra actions52 - Background load/sync/import events53 - Error and recovery paths54552. Add the smallest useful instrumentation.56 - Create one `Logger` per feature area or type.57 - Log action boundaries and key state transitions.58 - Prefer one high-signal line per user action over noisy value dumps.59603. Build and run the app.61 - Use `build-run-debug` for the build/run loop.62 - If `script/build_and_run.sh` exists, prefer `./script/build_and_run.sh --telemetry` for live telemetry checks or `./script/build_and_run.sh --logs` for broader process logs.63 - Exercise the UI or command path that should emit telemetry.64654. Read runtime logs and verify the event fired.66 - Use Console.app with a process/subsystem filter when that is the fastest manual check.67 - Use `log stream --style compact --predicate 'process == "AppName"'` for live terminal verification.68 - Prefer tighter predicates when you know the subsystem/category:69 `log stream --style compact --predicate 'subsystem == "com.example.app" && category == "Sidebar"'`70715. Tighten or remove instrumentation.72 - If the event fires, keep only the logs that remain useful for future debugging.73 - If it does not fire, move the log closer to the suspected control path and rerun.7475## Verification Checklist7677- The app builds after telemetry changes.78- The relevant action emits exactly one clear log line or a small bounded sequence.79- The log can be filtered by process, subsystem, or category.80- No sensitive payloads are written to unified logs.81- Noisy temporary debug logs are removed or demoted before finishing.8283## Guardrails8485- Do not use `print` as the primary app telemetry mechanism for macOS app code.86- Do not leave a dense trail of permanent debug logs around every state mutation.87- Do not claim an event is wired correctly until you have a concrete verification path through Console, `log stream`, or captured process output.88- If the debugging task is mostly about crash/backtrace analysis rather than action telemetry, switch to `build-run-debug`.