managing-path-cleaning-rules
यह क्या करती है
यह स्किल एजेंट को PostHog में वेब पेज पतों को साफ़ करने वाले नियम बनाना सिखाती है। यह उन साइट मालिकों के लिए है जिनकी रिपोर्ट हज़ारों लगभग एक जैसे पेज लिंक में बँटी हुई है।
कब इस्तेमाल करें
- ✓जब आपके वेब एनालिटिक्स में एक ही पेज के कई संस्करण अलग-अलग ID के साथ दिखें।
- ✓जब आप यूज़र प्रोफ़ाइल जैसे मिलते-जुलते पतों को एक पंक्ति में समूहित करना चाहें।
- ✓जब आप पेज पते साफ़ करने वाले नियमों को टेस्ट या बदलना चाहें।
Skill का लिंक
https://github.com/PostHog/posthog/blob/master/products/web_analytics/skills/managing-path-cleaning-rules/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरी रिपोर्ट में हर यूज़र प्रोफ़ाइल पेज की अलग पंक्ति दिखती है। क्या आप ऐसे नियम सेट कर सकते हैं कि वे सब एक पंक्ति में समूहित हों?”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट असली पेज पतों को देखकर वे हिस्से ढूँढता है जो बदलते हैं, जैसे नंबर या ID। वह एक पैटर्न और पठनीय प्रतिस्थापन लिखता है, डेटा पर टेस्ट करता है, और नियमों को ऐसे क्रम में रखता है कि खास नियम पहले लागू हों।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Managing path cleaning rules
Path cleaning rules normalize $pathname and $entry_pathname so that pages
sharing the same template (/users/123/profile, /users/456/profile, …) collapse
into one row (/users/<id>/profile) in Web analytics tiles, Paths insights, and
any HogQL query that calls apply_path_cleaning. They are the right answer when
a breakdown is fragmented across thousands of near-identical URLs.
This skill teaches you how to:
- recognize when path cleaning is the right tool
- inspect real paths to find what needs cleaning
- write
regex+aliasrules in re2 syntax with the project's placeholder convention - test rules before saving them
- order rules so specific patterns aren't swallowed by generic ones
- apply the rules via MCP
Data model
Team.path_cleaning_filters is a JSON list of PathCleaningFilter objects:
{
"regex": "/users/\\d+/profile",
"alias": "/users/<id>/profile",
"order": 0
}
regex— a re2 pattern. No need to escape/. Anchor with^/$when you mean it.alias— the replacement. Default to angle-bracket placeholders (<id>,<slug>,<uuid>,<date>) so the cleaned path stays human-readable. Backreferences to the regex's capture groups also work, but they cost more to evaluate — see the backreference pitfall below before reaching for one.order— integer. Rules apply sequentially inorderascending, each rule's output feeds the next.
Application is replaceRegexpAll(pathname, regex, alias) per rule, chained.
Workflow
1. Confirm path cleaning is the right move
Ask yourself: is the user complaining about cardinality (too many distinct paths
in a chart), or do they want a per-URL drill-down? Path cleaning is for the
former. If they want per-URL data, suggest a property filter on $pathname
instead.
2. Inspect the real paths
Don't guess at patterns — query them. With the execute-sql MCP tool:
SELECT properties.$pathname AS path, count() AS views
FROM events
WHERE event = '$pageview'
AND timestamp > now() - INTERVAL 7 DAY
GROUP BY path
ORDER BY views DESC
LIMIT 200
Scan the result for:
- numeric IDs:
/users/123,/orders/4242 - UUIDs:
/sessions/8f3c1a3b-… - slugs:
/posts/why-i-love-posthog - dates:
/archive/2024-09-12 - locales:
/en-US/,/fr-FR/ - pagination:
?page=3,/page/3/
3. Draft regex + alias
| Pattern | Example match | regex |
alias |
|---|---|---|---|
| Numeric segment | /users/123/profile |
/users/\d+/profile |
/users/<id>/profile |
| UUID v4 | /sessions/8f3c1a3b-… |
/sessions/[0-9a-f-]{36} |
/sessions/<uuid> |
| Slug | /posts/why-posthog |
/posts/[a-z0-9-]+$ |
/posts/<slug> |
| ISO date | /archive/2024-09-12 |
/archive/\d{4}-\d{2}-\d{2} |
/archive/<date> |
| Locale prefix | /en-US/about |
^/[a-z]{2}-[A-Z]{2}/ |
/<locale>/ |
| Trailing query/page | /blog?page=3 |
\?page=\d+$ |
(empty alias drops it) |
Anchoring rules of thumb:
- start the regex with
^only when the segment must be at the beginning of the path - end with
$to keep a generic rule (e.g.\d+$) from matching mid-path segments
4. Test before saving
Three options, pick one:
Settings page tester:
/settings/project#path_cleaninghas a built-in "test path" input that replays the full ordered chain.Project HogQL (via
execute-sql):SELECT replaceRegexpAll('/users/42/profile', '/users/\d+/profile', '/users/<id>/profile')Chain
replaceRegexpAllcalls in the same order the rules will run if you want to verify multi-rule interaction.Built-in AI helper: there is already an
AiRegexHelpermodal accessible from the rule editor (Help me with Regexbutton) that turns natural language into a regex. Suggest it to the user when they say "I don't know regex" — but always validate the output against real paths via the tester.
5. Order rules from most-specific to most-general
Sequential application means a generic rule placed first will swallow everything that should have hit a specific rule.
order=0 /users/me/profile → /users/me/pro
अक्सर पूछे जाने वाले सवाल
क्या साफ़ किए गए पते रिपोर्ट में दिखते हैं?
हाँ। साफ़ किया गया संस्करण उन रिपोर्ट और क्वेरी में दिखता है जो इन नियमों का उपयोग करती हैं।
id जैसे प्लेसहोल्डर कैसे दिखते हैं?
ये पठनीय लेबल होते हैं, जैसे id या slug, जो साफ़ किए गए पते में < > चिह्नों के भीतर दिखते हैं।
नियमों का क्रम क्यों मायने रखता है?
एक व्यापक नियम किसी खास नियम को निगल सकता है, इसलिए खास पैटर्न पहले रखे जाने चाहिए।
जानकारी
लेखक का मूल विवरण
Inspects URL paths and proposes, tests, orders, and applies project-level path cleaning rules so dynamic segments (numeric IDs, UUIDs, slugs, dates) collapse into readable aliases. Use when the user says "clean the paths", "normalize URLs", "group similar pages", "too many distinct paths", "/users/123 and /users/456 are the same page", "set up path cleaning", or asks why a Web analytics or Paths breakdown is fragmented across thousands of nearly-identical URLs. Covers regex syntax (re2), alias placeholder convention, rule ordering, the test workflow, and applying rules via the path-cleaning-ru
repo: PostHog/posthog
लोकप्रियता
- GitHub स्टार
- 41k
- रैंकिंग में स्थान
- #6976
- लाइसेंस
- —
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
depot-ci
41kयह आपके एजेंट को Depot CI वर्कफ़्लो सेट अप करने, चलाने और माइग्रेट करने में मदद करती है, साथ ही रन के लॉग पढ़ने में।
depot-container-builds
41kयह आपके एजेंट को Depot के रिमोट बिल्डर पर Docker इमेज बनाने में मदद करती है, जिसमें मल्टी-प्लेटफ़ॉर्म इमेज और बिल्ड सुधार शामिल हैं।
depot-github-runners
41kयह आपके एजेंट को GitHub Actions जॉब Depot के मैनेज्ड रनर पर ले जाने, रनर का साइज़ और लेबल चुनने, और रनर सेटअप की समस्याएँ ठीक करने में मदद करती है।
editing-agents-md
41kयह आपके एजेंट को तय करने में मदद करती है कि कोई नियम AGENTS.md या CLAUDE.md में जाए या नहीं, और उसे ऐसे लिखे कि फ़ाइल भारी न हो।
मिलती-जुलती skills
gitcrawl
394kयह आपके एजेंट को GitHub issues और pull requests के सेव आर्काइव में खोजने, मिलते-जुलते मामलों को समूह में रखने और लाइव स्थिति जांचने देती है।
slacrawl
394kयह आपके एजेंट को स्थानीय Slack आर्काइव में संदेश खोजने और गिनने, उसकी ताज़गी जांचने और ज़रूरत पड़ने पर उसे ताज़ा करने देती है।
goplaces
394kयह आपके एजेंट को Google Places से जगहें खोजने, उनका विवरण और समीक्षाएं पाने, और जगह के नाम हल करने में मदद करती है, स्क्रिप्ट के लिए JSON आउटपुट के साथ।