본문으로 건너뛰기
Skillpedia
분석 및 스프레드시트41k · #6976

managing-path-cleaning-rules

하는 일

이 스킬은 에이전트가 PostHog의 웹 페이지 주소를 정리하는 규칙을 설정하는 방법을 보여 줍니다. 보고서가 거의 같은 페이지 링크 수천 개로 나뉘어 있는 사이트 운영자를 위한 스킬입니다.

사용하는 경우

  • ✓웹 분석에 같은 페이지의 여러 버전이 ID만 달라서 따로 보일 때.
  • ✓사용자 페이지처럼 비슷한 주소를 한 행으로 묶고 싶을 때.
  • ✓주소를 정리하는 규칙을 테스트하거나 바꾸고 싶을 때.

스킬 링크

https://github.com/PostHog/posthog/blob/master/products/web_analytics/skills/managing-path-cleaning-rules/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/PostHog/posthog/blob/master/products/web_analytics/skills/managing-path-cleaning-rules/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“보고서에서 사용자 프로필 페이지마다 행이 따로 나옵니다. 모두 한 행으로 묶이도록 규칙을 설정해 주세요.”

매주 새 스킬 5개. 읽는 데 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 + alias rules 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 in order ascending, 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_cleaning has 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 replaceRegexpAll calls in the same order the rules will run if you want to verify multi-rule interaction.

  • Built-in AI helper: there is already an AiRegexHelper modal accessible from the rule editor (Help me with Regex button) 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
라이선스
—
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬