88 lines · 4.0 KB
/**
 * Route templates for metrics: a path reduced to its shape (`/:owner/:repo/issues/:n`), never carrying account,
 * repository, branch or file names. Only words from a fixed list of route segments survive; anything else
 * becomes a parameter, so a template is safe to send to analytics whatever the path held.
 */

/** First path segments that are app pages, not account names. */
export const APP_ROOTS = new Set([
  "",
  "abuse",
  "admin",
  "explore",
  "ingest",
  "features",
  "forgot-password",
  "login",
  "new",
  "notifications",
  "orgs",
  "pricing",
  "projects",
  "reset-password",
  "search",
  "self-host",
  "settings",
  "signup",
  "verify-email",
  "api",
  "auth",
]);

const STATIC_SEGMENTS = new Set(
  `abuse accept acceptable-use access actions admin advisories agents ai ai-fix alerts api apply approve artifacts
  attempts audit auto_merge billing blame blob branch-protections branches bypass caches cancel check
  code-owner-review code-scanning codeowners collaborators comments commit commits compare conflicts containers
  contents cookies credential decline deliveries dependencies deploy-tokens deployments discussions dismissals
  dispatches dmca domain drafts edit editor-sessions environments explore features files find forgot-password forks
  hooks import insights integrations invitations issues labels lfs lfs-quota lfs-usage linked-issues login
  mcp-usage members merge merge_queue milestones new notification-settings notifications org
  organization_invitations orgs permissions pings planning policy privacy projects protections pull pull-template