Skip to content

Conversation

aidankmcalister
Copy link
Member

@aidankmcalister aidankmcalister commented Sep 5, 2025

Summary by CodeRabbit

  • New Features
    • Optionally include user agent in database creation requests for improved telemetry.
  • Chores
    • Standardized utm_source to always reflect the CLI identity; user agent is sent separately when available.
    • Forward user agent to backend services via request headers for better diagnostics.
    • Added lightweight logging of user agent for observability.
  • Notes
    • No changes to request validation, error handling, or overall flow.
    • No breaking changes; existing integrations continue to work.

Copy link

coderabbitai bot commented Sep 5, 2025

Walkthrough

Adds optional userAgent propagation from the CLI to the create-db worker and then to the Prisma API via a User-Agent header. Adjusts the CLI payload to always set utm_source to CLI_NAME and, when provided, include a top-level userAgent field. No changes to exported APIs or existing control flow.

Changes

Cohort / File(s) Summary
Worker: accept and forward userAgent
create-db-worker/src/index.ts
Reads optional userAgent from request body, logs it, and forwards it to Prisma as the 'User-Agent' request header (empty string if absent). Request body to Prisma remains unchanged (region, name).
CLI: payload shape update
create-db/index.js
In createDatabase, always sets utm_source to CLI_NAME and adds a top-level userAgent field when provided. No change to error handling or other flow.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant CLI as CLI (create-db)
  participant Worker as create-db-worker /create
  participant Prisma as Prisma API

  CLI->>Worker: POST /create { region, name, userAgent? }<br/>utm_source=CLI_NAME
  Worker->>Worker: Extract userAgent (optional)
  Worker->>Prisma: POST /databases { region, name }<br/>Header: User-Agent = userAgent || ""
  Prisma-->>Worker: Response (created/error)
  Worker-->>CLI: Response passthrough
Loading

Possibly related PRs

Suggested reviewers

  • nurul3101
  • mhessdev
  • ankur-arch
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch user-agent-sent-to-mgmt-api

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Sep 5, 2025

Preview CLIs & Workers are live!

Test the CLIs locally under tag pr54-user-agent-sent-to-mgmt-api-17502093016:

npx create-db@pr54
npx create-pg@pr54
npx create-postgres@$pr54

Worker URLs
• Create-DB Worker:
• Claim-DB Worker:

These will live as long as this PR exists under tag pr54-user-agent-sent-to-mgmt-api-17502093016.

Copy link

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
claim-db-worker 5041be3 Commit Preview URL

Branch Preview URL
Sep 05 2025, 07:03 PM

Copy link

@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: 3

Caution

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

⚠️ Outside diff range comments (3)
create-db/index.js (2)

518-518: UTM consistency: keep utm_source stable (use CLI_NAME), move UA to utm_content

claimUrl currently sets utm_source to userAgent when present, diverging from the new convention. Standardize utm_source to CLI_NAME and, if desired, carry the UA via utm_content.

Apply:

-  const claimUrl = `${CLAIM_DB_WORKER_URL}/claim?projectID=${projectId}&utm_source=${userAgent || CLI_NAME}&utm_medium=cli`;
+  const claimUrl =
+    `${CLAIM_DB_WORKER_URL}/claim?projectID=${projectId}` +
+    `&utm_source=${CLI_NAME}&utm_medium=cli` +
+    (userAgent ? `&utm_content=${encodeURIComponent(userAgent)}` : "");

411-417: Normalize analytics property casing for UA

You use "user-agent" in analytics payloads but userAgent elsewhere. Consider standardizing on userAgent for consistency across the codebase and analytics dashboards. Low-risk, optional.

Also applies to: 455-462, 485-491, 555-561, 635-651

create-db-worker/src/index.ts (1)

51-61: Consider forwarding UA on regions fetch (optional)

If correlating UA across flows is useful, consider also passing sanitized UA (when present) to the /regions call for consistency. Not required for correctness.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ad03c04 and 5041be3.

📒 Files selected for processing (2)
  • create-db-worker/src/index.ts (2 hunks)
  • create-db/index.js (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
create-db-worker/src/index.ts (1)
create-db/index.js (1)
  • userAgent (629-629)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Workers Builds: claim-db-worker
  • GitHub Check: Workers Builds: create-db-worker
🔇 Additional comments (1)
create-db/index.js (1)

434-436: User-Agent propagation looks correct

Adding a top-level userAgent while keeping utm_source fixed to CLI_NAME matches the PR goal and won’t break existing consumers (undefined is omitted by JSON.stringify).

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.

1 participant