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
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.json to 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:
{
"#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.