Skip to content

[SDK] Feature: Adds gateway usage source #7641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

gregfromstl
Copy link
Member

@gregfromstl gregfromstl commented Jul 17, 2025


PR-Codex overview

This PR introduces support for a new service named gateway across various files in the service-utils package, enhancing the existing functionality by defining its structure and properties.

Detailed summary

  • Added gateway to the USAGE_V2_SOURCES constant in usageV2.ts.
  • Defined gateway properties (enabled and rateLimit) in mocks.ts.
  • Introduced gateway configuration in services.ts with attributes like actions, description, name, and title.
  • Updated ProjectService type in api.ts to include gateway with its properties.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • Introduced "gateway" as a new capability for teams, including support for enabling/disabling and setting rate limits.
    • Added "gateway" as a new service and usage source, allowing it to be tracked and managed alongside existing services.
  • Chores

    • Updated mock data to include the new "gateway" capability for testing and development purposes.

@gregfromstl gregfromstl requested a review from a team as a code owner July 17, 2025 20:31
Copy link

linear bot commented Jul 17, 2025

Copy link

changeset-bot bot commented Jul 17, 2025

⚠️ No Changeset found

Latest commit: ca2bb3f

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

Copy link

vercel bot commented Jul 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
thirdweb-www ❌ Failed (Inspect) Jul 17, 2025 8:50pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Skipped (Inspect) Jul 17, 2025 8:50pm
nebula ⬜️ Skipped (Inspect) Jul 17, 2025 8:50pm
thirdweb_playground ⬜️ Skipped (Inspect) Jul 17, 2025 8:50pm
wallet-ui ⬜️ Skipped (Inspect) Jul 17, 2025 8:50pm

Copy link
Contributor

coderabbitai bot commented Jul 17, 2025

Walkthrough

A new "gateway" capability and service were introduced across the codebase. The types, service definitions, usage sources, and mock data were updated to include the "gateway" entry, with associated properties such as enabled, rateLimit, and metadata. No functional logic or control flow was changed.

Changes

File(s) Change Summary
.../src/core/api.ts Added gateway property to TeamCapabilities type; added "gateway" variant to ProjectService.
.../src/core/services.ts Added gateway entry to SERVICE_DEFINITIONS with description, name, title, and empty actions.
.../src/core/usageV2.ts Added "gateway" to USAGE_V2_SOURCES and to UsageV2Source union type.
.../src/mocks.ts Added gateway capability with enabled: true and rateLimit: 1000 to mock validTeamResponse.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ServiceUtils
    participant Gateway

    Client->>ServiceUtils: Request with usage source "gateway"
    ServiceUtils->>Gateway: Forward request based on gateway capability/rateLimit
    Gateway-->>ServiceUtils: Respond with data/status
    ServiceUtils-->>Client: Return gateway response
Loading

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 20e5107 and ca2bb3f.

📒 Files selected for processing (4)
  • packages/service-utils/src/core/api.ts (2 hunks)
  • packages/service-utils/src/core/services.ts (1 hunks)
  • packages/service-utils/src/core/usageV2.ts (1 hunks)
  • packages/service-utils/src/mocks.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/service-utils/src/core/usageV2.ts
  • packages/service-utils/src/core/services.ts
  • packages/service-utils/src/core/api.ts
  • packages/service-utils/src/mocks.ts
⏰ 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). (3)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Size
  • GitHub Check: Analyze (javascript)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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

Documentation and Community

  • 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
Contributor

graphite-app bot commented Jul 17, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Copy link

codecov bot commented Jul 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.46%. Comparing base (4cbf671) to head (ca2bb3f).
⚠️ Report is 54 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7641   +/-   ##
=======================================
  Coverage   56.46%   56.46%           
=======================================
  Files         908      908           
  Lines       58159    58159           
  Branches     4225     4225           
=======================================
  Hits        32840    32840           
  Misses      25211    25211           
  Partials      108      108           
Flag Coverage Δ
packages 56.46% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

🧹 Nitpick comments (2)
packages/service-utils/src/core/usageV2.ts (1)

13-14: Consider keeping the source list alphabetically sorted

Placing "gateway" at the correct lexical position (between "engine-cloud" and "insight") makes future diffs easier to reason about.

   "engine-cloud", // Engine Cloud
   "insight",
+  "gateway",
   "nebula",
packages/service-utils/src/core/services.ts (1)

86-92: Polish the new service definition

  1. The description string is less informative than the others.
  2. If the Gateway will eventually expose distinct verbs (e.g. "read"), documenting them now prevents a breaking change later.
   gateway: {
     // all actions allowed
     actions: [],
-    description: "api.thirdweb.com",
+    description: "Gateway HTTP API (api.thirdweb.com)",
     name: "gateway",
     title: "Gateway",
   },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4cbf671 and 20e5107.

📒 Files selected for processing (4)
  • packages/service-utils/src/core/api.ts (3 hunks)
  • packages/service-utils/src/core/services.ts (1 hunks)
  • packages/service-utils/src/core/usageV2.ts (1 hunks)
  • packages/service-utils/src/mocks.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • CLAUDE.md
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.488Z
Learning: Surface breaking changes prominently in PR descriptions
packages/service-utils/src/mocks.ts (2)
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.488Z
Learning: Applies to **/*.test.{ts,tsx} : Use Mock Service Worker (MSW) for fetch/HTTP call interception in tests
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.488Z
Learning: Applies to **/*.test.{ts,tsx} : Use real function invocations with stub data in tests; avoid brittle mocks
packages/service-utils/src/core/usageV2.ts (2)
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.489Z
Learning: Applies to src/wallets/**/*.{ts,tsx} : Unified `Wallet` and `Account` interfaces in wallet architecture
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.489Z
Learning: Applies to src/wallets/**/*.{ts,tsx} : Smart wallets with account abstraction in wallet architecture
packages/service-utils/src/core/api.ts (2)
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-06-30T10:26:04.389Z
Learning: Applies to dashboard/**/api/**/*.{ts,tsx} : Return typed results (`Project[]`, `User[]`, …) – avoid `any`.
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.489Z
Learning: Applies to apps/{dashboard,playground-web}/**/*.{tsx,ts} : Server Side Data Fetching: Return typed results (`Project[]`, `User[]`) – avoid `any`
⏰ 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). (8)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Build Packages
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
packages/service-utils/src/mocks.ts (1)

87-90: Gateway capability mock looks correct

The new mock entry matches the shape declared in TeamCapabilities (enabled: boolean, rateLimit: number). No issues spotted.

packages/service-utils/src/core/api.ts (1)

115-118: Capability wiring LGTM

The gateway capability mirrors the existing pattern for simple features (boolean + rateLimit). ✅

Copy link
Contributor

github-actions bot commented Jul 17, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 63.25 KB (0%) 1.3 s (0%) 972 ms (+156.55% 🔺) 2.3 s
thirdweb (cjs) 353.31 KB (0%) 7.1 s (0%) 3.1 s (+12.9% 🔺) 10.1 s
thirdweb (minimal + tree-shaking) 5.7 KB (0%) 114 ms (0%) 535 ms (+2852.24% 🔺) 649 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 499 ms (+7245.58% 🔺) 509 ms
thirdweb/react (minimal + tree-shaking) 19.59 KB (0%) 392 ms (0%) 577 ms (+1095.34% 🔺) 969 ms

@gregfromstl gregfromstl force-pushed the greg/tool-5039-add-tracking-to-all-endpoints branch from 20e5107 to e25a96c Compare July 17, 2025 20:37
@vercel vercel bot temporarily deployed to Preview – nebula July 17, 2025 20:38 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground July 17, 2025 20:38 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 July 17, 2025 20:38 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui July 17, 2025 20:38 Inactive
@gregfromstl gregfromstl force-pushed the greg/tool-5039-add-tracking-to-all-endpoints branch from e25a96c to ca2bb3f Compare July 17, 2025 20:39
@vercel vercel bot temporarily deployed to Preview – nebula July 17, 2025 20:39 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground July 17, 2025 20:39 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 July 17, 2025 20:39 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui July 17, 2025 20:39 Inactive
@gregfromstl gregfromstl requested a review from jnsdls July 17, 2025 20:39
@@ -83,6 +83,13 @@ export const SERVICE_DEFINITIONS = {
name: "storage",
title: "Storage",
},
gateway: {
Copy link
Member

Choose a reason for hiding this comment

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

i think the dashboard reads this btw, would make sure it does what you want (particularly enabled by default) also api server needs to have this if this is gonna be a proper projectService

we can store dev settings in there in the future

@jnsdls jnsdls closed this Jul 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants