Fill Metric IDs (Generic)
This skill provides a generic utility to scan an HTML file for text (metric names) and append their corresponding IDs from a provided data source.
Capabilities
- •Generic Matching: Matches text in HTML against a Name->ID dictionary (Excel or CSV).
- •Fuzzy Matching: Uses difflib to handle slight variations (e.g. "User Count" vs "Count", "访问数" vs "访问人数").
- •Context Aware: Can prepend prefixes to keys based on parent element IDs/Classes (defined in config).
- •Flexible Selectors: Target specific tags (default
h3, th, td).
Usage
1. Unified Metric Filler
bash
python3 .agent/skills/fill-metric-ids/scripts/fill_metrics.py \ --html <input.html> \ --source <metrics.xlsx>
The script automatically handles:
- •Specialized Logic: Fixes known structural issues (Bound Users, Retention Tables).
- •Context Mapping: Uses
miniprogram_context.jsonto map specific tabs to metric prefixes. - •Generic Filling: Scans for remaining metrics using Fuzzy and Substring matching.
- •Optimizations: Excludes "Date" column, applies manual mappings for known aliases.
Context Config Example
context.json:
json
{
"#login-tab": ["Login User"],
".share-section": ["Share User"]
}
If the tool finds "Count" inside <div id="login-tab">, it looks for "Login UserCount" in the Excel.