Skip to content

docs: clean up examples#4242

Merged
chronark merged 2 commits intomainfrom
11-05-docs_clean_up_examples
Nov 5, 2025
Merged

docs: clean up examples#4242
chronark merged 2 commits intomainfrom
11-05-docs_clean_up_examples

Conversation

@chronark
Copy link
Collaborator

@chronark chronark commented Nov 5, 2025

What does this PR do?

Enhances the Analytics documentation with improved readability, organization, and examples. The changes include:

  • Added detailed explanations for each query example with use cases
  • Implemented CodeGroup components for better SQL/cURL presentation
  • Improved query examples to use aggregated tables for better performance
  • Added new sections like "Use Cases" to highlight practical applications
  • Created a new Quick Reference page for fast lookup of common patterns
  • Added a Troubleshooting page with common issues and solutions
  • Reorganized content to be more task-oriented and user-friendly
  • Updated query examples to use SUM(count) with aggregated tables instead of COUNT(*)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How should this be tested?

  • Review the documentation pages in the browser to ensure proper formatting
  • Verify that all code examples are properly displayed in the CodeGroup components
  • Test the SQL queries to confirm they work as expected
  • Check that navigation between pages is logical and intuitive

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read Contributing Guide
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand areas
  • Ran pnpm build
  • Ran pnpm fmt
  • Ran make fmt on /go directory
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Unkey Docs if changes were necessary

@changeset-bot
Copy link

changeset-bot bot commented Nov 5, 2025

⚠️ No Changeset found

Latest commit: fd98b78

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Nov 5, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
dashboard Ready Ready Preview Comment Nov 5, 2025 6:04pm
engineering Ready Ready Preview Comment Nov 5, 2025 6:04pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 5, 2025

📝 Walkthrough

Walkthrough

Analytics documentation overhauled to use pre-aggregated tables instead of raw tables in query examples, replace JSON examples with curl-based API commands, reorganize content into use-case themes, introduce quick-reference and troubleshooting guides, remove deprecated sections, and make the Analytics section visible in navigation.

Changes

Cohort / File(s) Summary
Existing analytics documentation
apps/docs/analytics/getting-started.mdx, apps/docs/analytics/overview.mdx, apps/docs/analytics/query-examples.mdx
Refactored query examples to use pre-aggregated tables (key_verifications_per_day_v1, key_verifications_per_hour_v1) with SUM(count) aggregations; replaced JSON payloads with curl-based API commands in CodeGroup wrappers; added descriptive narrative blocks; restructured "Next Steps" into "Use Cases" section with three new use-case cards (Billing Teams, Monitoring, Product Teams); removed legacy card references.
Query restrictions and schema reference
apps/docs/analytics/query-restrictions.mdx, apps/docs/analytics/schema-reference.mdx
Removed "Workspace Isolation" and "Authentication" sections; expanded Allowed Functions lists with additional date/time functions (toDateTime64, toIntervalMillisecond, etc.); reformatted tables and accordions for consistency; removed "Max rows to read" resource limit; renamed error code query_rows_limit_exceeded to query_result_rows_exceeded; removed "Next Steps" CardGroup sections.
New analytics documentation
apps/docs/analytics/quick-reference.mdx, apps/docs/analytics/troubleshooting.mdx
Added quick-reference guide with essential query patterns (Usage Analytics, User Analytics, API Analytics, Billing, Tag-Based Filtering), table selection guide, and common filters; added troubleshooting guide covering empty results, filter issues, data availability, timeouts, API errors, and performance optimizations.
Navigation configuration
apps/docs/docs.json
Changed Analytics section hidden flag from true to false to enable section visibility; minor formatting adjustments to Concepts/Identities and Errors/Too Many Requests page array layouts.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Query consistency: Verify that all query examples using aggregated tables correctly reference the same table versions and use SUM(count) patterns uniformly across getting-started.mdx, query-examples.mdx, and quick-reference.mdx.
  • Curl command accuracy: Confirm API payloads in curl examples match the updated SQL queries and are syntactically correct.
  • Use case card links: Validate that new cards in overview.mdx (Billing Teams, Monitoring, Product Teams) link to appropriate documentation destinations.
  • Function list completeness: Ensure all added date/time functions in query-restrictions.mdx are supported and accurately documented.

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'docs: clean up examples' is vague and generic, using non-descriptive language that does not convey the specific nature of the changes beyond a general cleanup. Consider using a more specific title that captures the main enhancement, such as 'docs: enhance analytics documentation with improved examples and organization' or similar.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description is comprehensive and well-structured, covering objectives, changes made, type of change, testing instructions, and completing all required checklist items.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 11-05-docs_clean_up_examples

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Collaborator Author

chronark commented Nov 5, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
apps/docs/docs.json (1)

174-183: Analytics section now visible but missing new pages in navigation.

The Analytics section visibility has been correctly changed to hidden: false. However, based on the PR summary, two new documentation pages (quick-reference.mdx and troubleshooting.mdx) have been added but are not listed in the pages array. These should be included in the navigation structure for discoverability.

"pages": [
  "analytics/overview",
  "analytics/getting-started",
  "analytics/query-examples",
  "analytics/schema-reference",
-  "analytics/query-restrictions"
+  "analytics/query-restrictions",
+  "analytics/quick-reference",
+  "analytics/troubleshooting"
]
apps/docs/analytics/schema-reference.mdx (1)

295-302: Error code name mismatch with query-restrictions.mdx.

The Query Limits table references query_rows_limit_exceeded, but query-restrictions.mdx (line 109) uses the new error code name query_result_rows_exceeded. This inconsistency will confuse users. The error code name should be synchronized.

| Resource         | Limit      | Error Code                    |
| ---------------- | ---------- | ----------------------------- |
| Execution time   | 30 seconds | `query_execution_timeout`     |
| Memory usage     | 1 GB       | `query_memory_limit_exceeded` |
-| Rows to read     | 10 million | `query_rows_limit_exceeded`   |
+| Result rows     | 10 million | `query_result_rows_exceeded`  |
| Queries per hour | 1000       | `query_quota_exceeded`        |
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e6fbc8 and fd98b78.

📒 Files selected for processing (8)
  • apps/docs/analytics/getting-started.mdx (3 hunks)
  • apps/docs/analytics/overview.mdx (3 hunks)
  • apps/docs/analytics/query-examples.mdx (9 hunks)
  • apps/docs/analytics/query-restrictions.mdx (3 hunks)
  • apps/docs/analytics/quick-reference.mdx (1 hunks)
  • apps/docs/analytics/schema-reference.mdx (3 hunks)
  • apps/docs/analytics/troubleshooting.mdx (1 hunks)
  • apps/docs/docs.json (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-09-15T19:53:28.487Z
Learnt from: mcstepp
Repo: unkeyed/unkey PR: 3952
File: go/proto/ctrl/v1/routing.proto:0-0
Timestamp: 2025-09-15T19:53:28.487Z
Learning: In the Unkey codebase, authentication/authorization errors intentionally return NOT_FOUND error codes instead of distinct auth error codes (like FORBIDDEN or UNAUTHORIZED) for security reasons. This prevents attackers from distinguishing between "resource doesn't exist" and "you don't have permission to access this resource", avoiding information disclosure about workspace existence and access boundaries.

Applied to files:

  • apps/docs/analytics/query-restrictions.mdx
📚 Learning: 2025-08-29T13:35:44.917Z
Learnt from: Flo4604
Repo: unkeyed/unkey PR: 3884
File: go/apps/api/openapi/openapi-generated.yaml:1828-1845
Timestamp: 2025-08-29T13:35:44.917Z
Learning: In the Unkey system, soft-deleted resources (like ratelimit namespaces) cannot be restored through the API or dashboard, but they can be restored manually via direct database operations by the support team. The error documentation should reflect that users need to contact support for restoration, as the current GoneErrorResponse description does.

Applied to files:

  • apps/docs/analytics/query-restrictions.mdx
🔇 Additional comments (5)
apps/docs/analytics/troubleshooting.mdx (1)

1-144: New troubleshooting guide is comprehensive and well-structured.

The new troubleshooting documentation provides practical guidance across multiple common issues with clear examples and references to related documentation. The content aligns well with the other analytics documentation updates.

apps/docs/analytics/getting-started.mdx (1)

42-124: Well-executed migration to aggregated tables and CodeGroup format.

The examples have been effectively migrated to use pre-aggregated tables (key_verifications_per_day_v1, key_verifications_per_hour_v1) with SUM(count) instead of COUNT(*), and the CodeGroup wrapper with curl examples significantly improves usability. The performance tip is valuable.

apps/docs/analytics/quick-reference.mdx (1)

1-209: Excellent new quick-reference documentation with clear patterns and guidance.

The quick-reference guide is well-organized with practical SQL patterns, a helpful table selection guide, and common filter examples. The content is consistent with the broader analytics documentation updates, using aggregated tables and SUM(count) patterns throughout.

apps/docs/analytics/query-examples.mdx (1)

1-855: Excellent restructuring to CodeGroup format with consistent aggregated table patterns.

The query examples have been comprehensively updated to use CodeGroup components with both SQL and curl formats. All examples consistently use pre-aggregated tables (key_verifications_per_day_v1, etc.) and SUM(count) patterns. The organization by use case (Usage, User, API, Billing, Advanced) is logical and mirrors the quick-reference guide.

apps/docs/analytics/overview.mdx (1)

59-83: All anchor references are correct and will properly resolve to their corresponding headings in query-examples.mdx:

  • #billing-usage-based-pricing → "## Billing & Usage-Based Pricing" (line 570)
  • #usage-analytics → "## Usage Analytics" (line 35)
  • #usage-by-user → "## Usage by User" (line 142)

Copy link
Member

@perkinsjr perkinsjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Add SDK example here post launch analytics/getting-started

@chronark chronark merged commit 65e0c9c into main Nov 5, 2025
29 checks passed
@chronark chronark deleted the 11-05-docs_clean_up_examples branch November 5, 2025 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants