Usage Path Formatter (usage/format-usage-path.ts)

appwrite · apps/console/src/lib/usage/format-usage-path.ts · typescript · BSD-3-Clause
analytics, dev-tools

Formats usage paths by compacting resource IDs. Use for analytics and usage tracking.

// Source: https://github.com/appwrite/appwrite | License: BSD-3-Clause | Copyright 2019 Appwrite (https://appwrite.io) and individual contributors
// Provided via justclaw.it.com; keep this notice with the code.
const OBJECT_ID_PATTERN = /^[a-f0-9]{20,}$/i
const UUID_PATTERN =
  /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i

/** Known REST path tokens - not resource IDs. */
const STATIC_PATH_SEGMENTS = new Set([
  'account',
  'attributes',
  'auth',
  'avatars',
  'blocks',
  'buckets',
  'challenges',
  'collections',
  'columns',
  'console',
  'databases',
  'deployments',
  'documents',
  'download',
  'executions',
  'factors',
  'files',
  'functions',
  'graphql',
  'health',
  'identities',
  'identity',
  'indexes',
  'invites',
  'jwt',
  'keys',


... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key