pulse-telemetry
npx skills add https://github.com/shashi-ntx/nutanix-skills --skill pulse-telemetry
Agent 安装分布
Skill 文档
Pulse Telemetry Implementation
Implement telemetry tracking for web apps using @nutanix-ui/pulse-telemetry. This skill uses a gated workflow: scaffold the foundation, verify one event works end-to-end in the browser, then ask the user before implementing the remaining requirements.
Workflow
1. Detect â 2. Scaffold â 3. Smoke Test â 3c. Handoff Doc â 4. CHECKPOINT â â 5. Implement All â 6. Verify â 7. Report
1. Detect Project State
First, check for an existing handoff doc (TELEMETRY_STATUS.md in the telemetry utils directory). If one exists, read it â it contains the full context from a prior session: file map, established patterns, and a requirements tracker. Resume from the first row with status Pending. Skip steps 2â4 and go to step 5, but continue using this skill’s reference files (templates, requirement-type-map, codebase-adapters) whenever you encounter a requirement type or pattern not covered in the handoff doc.
If no handoff doc exists, search the codebase for existing telemetry setup:
Look for:
âââ TELEMETRY_STATUS.md in utils/telemetry/ or shared/telemetry/
âââ TelemetryProvider or TelemetryManager imports
âââ utils/telemetry/ or shared/telemetry/ directory
âââ constants.ts with FEAT_NAME / PAGE_SECTION / SUB_PAGE_SECTION
âââ data/ directory with TelemetryConfigObj aggregation
âââ data-telemetry attributes in JSX/HTML
âââ @nutanix-ui/pulse-telemetry in package.json
If handoff doc exists: read it and resume from its first Pending requirement (skip to step 5). Still consult skill reference files for unfamiliar requirement types.
If telemetry exists but no handoff doc: extend the current setup â add new constants, config files, and provider wiring as needed.
If telemetry is missing: scaffold the full foundation (step 2).
See references/setup-detection.md for detection commands, scaffold rules, and handoff doc resume logic.
2. Scaffold Missing Foundation
Only create files that don’t already exist. Required foundation:
| File | Purpose |
|---|---|
utils/telemetry/constants.ts |
FEAT_NAME, PAGE_SECTION, SUB_PAGE_SECTION as const objects |
utils/telemetry/data/index.ts |
Aggregates all feature configs into one TelemetryConfigObj |
utils/telemetry/data/<feature>.ts |
Per-feature TelemetryConfigData with defaults + eventMap |
utils/telemetry/index.ts |
Exports config args; creates TelemetryManager if non-React code needs access |
| Provider wiring | TelemetryProvider at app/page root, or TelemetryManager.initialize() for non-React |
See references/templates.md for copy-paste file templates.
Adapt, don’t copy-paste. Templates show the full pattern â only use the parts you actually need. Don’t add wrapper components, extra files, or abstractions unless the specific case requires them. Match the style and complexity of the existing codebase. See the General Principles section in references/templates.md for details.
Important: At this stage, only populate constants.ts with values needed for the smoke-test event (step 3). Do NOT add all constants from the full requirement list yet â those will be added in step 5 after the user approves.
3. Smoke Test â One Event End-to-End
Before implementing the full requirement list, verify that the base telemetry setup is working correctly by testing one event end-to-end.
3a. Pick One Simple Requirement
Choose the simplest config-driven click event from the requirement list (e.g., a button click with a static data-test attribute). Implement only this single event:
- Add the minimal constants needed for this one event to
constants.ts - Create the config file with just this one
eventMapentry - Wire the aggregation and provider
- Ensure
data-telemetryanddata-testattributes exist on the relevant elements
3b. Verify in the Browser
This step is mandatory. Use the browser automation tool (or ask the user to assist) to confirm the event fires correctly:
- Enable
debugLog: trueandverboseClicks: truein the provider/config options - Start the dev server (or confirm it is already running)
- Navigate to the page containing the tracked element
- Click the element and check the browser console for the telemetry log output
- Confirm the logged payload has the correct
featName,actionName,pageSection,subPageSection, andactionType
See references/payload-verification.md for what the console output looks like and common issues.
If the event fires correctly: proceed to step 3c (handoff doc).
If it does not fire: debug and fix the setup before proceeding. Common issues include missing data-telemetry on a parent container, mismatched data-test / eventMap keys, or the provider not wrapping the component tree.
3c. Create the Handoff Doc
After smoke test passes, create TELEMETRY_STATUS.md in the telemetry utils directory (e.g., utils/telemetry/TELEMETRY_STATUS.md). This file is a concise context snapshot that lets a fresh agent thread resume implementation without re-discovering the codebase.
The handoff doc must contain:
- Quick Start â dev server URL, next pending requirement, known quirks (e.g., dismiss a modal before testing), active
data-telemetrycontainer keys - Telemetry File Map â paths of all created/modified telemetry files and key non-telemetry wiring files (e.g., the component where
TelemetryProviderwas added) - Established Patterns â project-specific rules discovered during detection (e.g., EBR uses
telemetryName, codebase adapter type, import alias conventions) - Requirements Tracker â table with columns:
#,Requirement,Status,Type,Files,Verified Payload. Mark the smoke-test row asDonewith its verified payload. All remaining rows start asPending. - Code Snippet â one concrete example showing the pattern used for the smoke-test event (config entry + wiring). Keep it short â just enough for a new agent to replicate the pattern without re-reading templates.
See references/templates.md for the TELEMETRY_STATUS.md template.
Rules:
- Keep the doc under 200 lines. Use tables over prose, snippets over full files.
- Never include sensitive data or user-entered content in payload examples.
- The doc is a working aid, not a deliverable â do not commit it. Add it to
.gitignoreif not already ignored.
4. CHECKPOINT â Ask the User Before Continuing â
STOP HERE. Do not proceed to implement the remaining requirements automatically.
Present the user with:
- What was set up â list the scaffolded files and the provider wiring
- The smoke test result â show the verified payload from step 3b
- The handoff doc â mention the path to
TELEMETRY_STATUS.mdand that it can be used to resume in a new thread - The remaining work â summarize how many requirements are left and what types they are (config-driven clicks, hover tracking, debounced inputs, etc.)
Then ask the user:
“The base telemetry setup is working â [describe the verified event]. I’ve created a handoff doc at [path to TELEMETRY_STATUS.md] so work can be continued in a new thread if needed. There are [N] remaining requirements to implement. Would you like me to continue implementing all of them, or would you prefer to review the setup first?”
Wait for the user’s response. Only proceed to step 5 if the user confirms.
5. Implement Remaining Requirements
Process each remaining requirement row in order. For each:
- Classify the requirement type (static click, dynamic click, hover, debounced input, tutorial step, non-React event)
- Choose approach â config-driven first; programmatic only when required
- Implement using the matching pattern
- Update the handoff doc â set the row’s status to
Done, fill in files touched and verified payload. This keepsTELEMETRY_STATUS.mdcurrent so that if the session is interrupted, a new thread can resume from the exact point of interruption. - Record files touched and expected payload
See references/requirement-type-map.md for the classification table and implementation patterns. See references/codebase-adapters.md for adapting patterns to different codebase structures.
Decision: Config-Driven vs. Programmatic
| Use config-driven | Use programmatic |
|---|---|
| Simple clicks on static elements | Hover / tooltip tracking |
Elements with existing data-test |
Debounced search/input |
| Buttons, links, tabs, checkboxes | Multi-step tutorials/wizards |
| Events needing dynamic payload data | |
| Non-React code (render functions, middleware) |
6. Verify Payloads
For each implemented requirement, verify the emitted payload matches the expected telemetry data.
Automated (preferred): enable debugLog: true and verboseClicks: true, trigger the interaction, confirm logged payload fields.
Manual fallback: structured checklist when runtime is unavailable.
See references/payload-verification.md for the full verification playbook.
7. Return Completion Report
After all requirements are implemented:
- Ensure every row in
TELEMETRY_STATUS.mdis markedDone(orNot feasiblewith a reason). The handoff doc’s requirements tracker should be fully up to date. - Produce a summary table for the user:
| # | Requirement | Status | Type | Files | Payload |
|---|-------------|--------|------|-------|---------|
| 1 | ... | Done | config-driven | ... | { ... } |
See references/templates.md for the report template.
Guardrails
These rules are non-negotiable:
- Config-driven first â use
data-telemetry+data-test+eventMapfor static clicks. Only use programmatic tracking when config-driven cannot handle the interaction type. - Typed constants â all
featName,pageSection,subPageSectionvalues must come from typedas constobjects inconstants.ts. Never use raw strings in config or event calls. ACTION_TYPEenum â always useACTION_TYPE.CLICK,ACTION_TYPE.HOVER,ACTION_TYPE.CHANGE. Never use raw string'click'.data-test/data-telemetryconsistency â everyeventMapkey must match an actualdata-testattribute in the DOM. Everydata-telemetryvalue must match a key in the aggregatedTelemetryConfigObj.- Regex for dynamic IDs â when
data-testcontains dynamic segments (entity IDs, row indices), add a regex todefaults.regexListand use the static prefix as theeventMapkey. getInstanceSafe()in non-React code â always usetelemetryManager.getInstanceSafe()(with optional chaining) outside React components. Never usegetInstance()which throws if uninitialized.- No sensitive data â track that an action happened, not user-entered content.
actionName: 'Search', notactionName: searchQuery. mapDataToEventMapfor repetitive actions â when 3+ buttons share the samesubPageSection, use the helper to reduce boilerplate.- Shared events for similar features â export common event maps and spread them into feature-specific configs instead of duplicating.
- snake_case naming â
featName,pageSection,subPageSectionusesnake_case.actionNameis human-readable and descriptive. - Never batch-implement without checkpoint â always complete steps 1â4 (detect, scaffold, smoke test, checkpoint) before implementing the full requirement list. Do not skip the user confirmation step.
- Always create and maintain the handoff doc â create
TELEMETRY_STATUS.mdafter the smoke test (step 3c) and update it after each requirement is implemented (step 5). If resuming from an existing handoff doc, re-validate that referenced files still exist before implementing.