Skip to content

feat: add Engine Cloud analytics to project overview #7195

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

Merged

Conversation

arcoraven
Copy link
Contributor

@arcoraven arcoraven commented May 29, 2025

[Dashboard] Feature: Add Engine Cloud Analytics Charts

Example screenshot:

image.png

Notes for the reviewer

This PR adds Engine Cloud analytics to the dashboard, displaying request data in a bar chart visualization. The implementation includes:

  1. A new API endpoint to fetch Engine Cloud method usage data
  2. New UI components for displaying Engine Cloud analytics:
    • EngineCloudBarChartCardUI - Shows Engine Cloud requests by pathname
    • EngineCloudChartCardUI - Shows Engine Cloud methods usage with percentage breakdown
  3. Integration of the new chart into the project analytics page

How to test

  • View the Storybook component at "Analytics/EngineCloudBarChartCard"
  • Navigate to a project dashboard to see the Engine Cloud analytics chart
  • Verify data is properly fetched and displayed in the chart

PR-Codex overview

This PR introduces new features related to engine cloud analytics, including a new interface for engine cloud statistics and components for displaying this data in charts.

Detailed summary

  • Added EngineCloudStats interface to define engine cloud statistics.
  • Introduced EngineCloudChartCard component for displaying engine cloud data.
  • Created getEngineCloudMethodUsage API function to fetch engine cloud usage data.
  • Implemented EngineCloudBarChartCardUI for rendering bar charts with engine cloud data.
  • Added storybook stories for EngineCloudBarChartCardUI to demonstrate its usage.

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

Summary by CodeRabbit

  • New Features

    • Introduced a stacked bar chart visualization for engine cloud request statistics in the analytics dashboard.
    • Added a chart card displaying engine cloud method usage data with loading state support.
    • Enhanced analytics with time series data for multiple API pathnames.
    • Included engine cloud method usage data in the project analytics view.
  • Chores

    • Updated .gitignore to exclude the .pnpm-store/ directory from version control.

Copy link

vercel bot commented May 29, 2025

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

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2025 1:42am
login ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2025 1:42am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2025 1:42am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2025 1:42am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2025 1:42am

Copy link

changeset-bot bot commented May 29, 2025

⚠️ No Changeset found

Latest commit: f2e8b9e

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
Contributor

coderabbitai bot commented May 29, 2025

Walkthrough

The changes introduce a new analytics feature that fetches and visualizes engine cloud method usage statistics. This includes the addition of a new API function, a corresponding data type, a bar chart UI component, a Storybook story for the chart, and integration of the chart card into the project analytics page. Additionally, .pnpm-store/ was added to .gitignore.

Changes

File(s) Change Summary
.gitignore Added .pnpm-store/ to ignored paths.
apps/dashboard/src/types/analytics.ts Added EngineCloudStats interface for engine cloud analytics data structure.
apps/dashboard/src/@/api/analytics.ts Added getEngineCloudMethodUsage async function to fetch engine cloud analytics data.
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/EngineCloudBarChartCardUI.tsx Added EngineCloudBarChartCardUI React component to render a stacked bar chart of engine cloud usage.
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/EngineCloudBarChartCard.stories.tsx Added Storybook story for the EngineCloudBarChartCardUI component with mock data.
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/index.tsx Added EngineCloudChartCard component to fetch and display engine cloud usage chart with loading state.
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/page.tsx Integrated EngineCloudChartCard into the ProjectAnalytics component.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ProjectAnalytics
    participant EngineCloudChartCard
    participant getEngineCloudMethodUsage
    participant EngineCloudBarChartCardUI

    User->>ProjectAnalytics: Render page
    ProjectAnalytics->>EngineCloudChartCard: Render with query params
    EngineCloudChartCard->>getEngineCloudMethodUsage: Fetch engine cloud stats
    getEngineCloudMethodUsage-->>EngineCloudChartCard: Return EngineCloudStats[]
    EngineCloudChartCard->>EngineCloudBarChartCardUI: Render chart with stats
    EngineCloudBarChartCardUI-->>User: Display stacked bar chart
Loading

📜 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 6e6de24 and f2e8b9e.

📒 Files selected for processing (7)
  • .gitignore (1 hunks)
  • apps/dashboard/src/@/api/analytics.ts (2 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/EngineCloudBarChartCard.stories.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/EngineCloudBarChartCardUI.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/index.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/page.tsx (2 hunks)
  • apps/dashboard/src/types/analytics.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • apps/dashboard/src/types/analytics.ts
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/page.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/index.tsx
  • .gitignore
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/EngineCloudBarChartCardUI.tsx
  • apps/dashboard/src/@/api/analytics.ts
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/EngineCloudBarChartCard.stories.tsx
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Unit Tests
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Build Packages
  • GitHub Check: Lint Packages
  • 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.

@github-actions github-actions bot added the Dashboard Involves changes to the Dashboard. label May 29, 2025
Copy link
Contributor Author


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.

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

Copy link

codecov bot commented May 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.63%. Comparing base (5234124) to head (f2e8b9e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7195   +/-   ##
=======================================
  Coverage   55.63%   55.63%           
=======================================
  Files         908      908           
  Lines       58546    58546           
  Branches     4128     4128           
=======================================
  Hits        32572    32572           
  Misses      25868    25868           
  Partials      106      106           
Flag Coverage Δ
packages 55.63% <ø> (ø)
🚀 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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🧹 Nitpick comments (2)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/index.tsx (1)

21-25: LGTM! Clean separation of concerns.

The async component properly handles data fetching and passes the raw data to the UI component. The separation between the sync wrapper and async implementation follows React best practices.

Consider adding explicit error handling if the getEngineCloudMethodUsage API call could fail, though this may already be handled by the Suspense boundary or global error boundaries.

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/EngineCloudBarChartCardUI.tsx (1)

66-66: Remove debug console.log

The debug console.log should be removed before production deployment.

-  console.log("[DEBUG] data:", data);
🛑 Comments failed to post (1)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/EngineCloudBarChartCardUI.tsx (1)

68-70: ⚠️ Potential issue

Fix incorrect metric name in empty state

The empty state card shows "RPC" as the metric, but this component is for Engine Cloud analytics.

-    return <EmptyStateCard metric="RPC" link="https://portal.thirdweb.com/" />;
+    return <EmptyStateCard metric="Engine Cloud" link="https://portal.thirdweb.com/" />;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  if (data.length === 0 || isAllEmpty) {
    return <EmptyStateCard metric="Engine Cloud" link="https://portal.thirdweb.com/" />;
  }
🤖 Prompt for AI Agents
In
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/EngineCloudBarChartCardUI.tsx
around lines 68 to 70, the EmptyStateCard component incorrectly uses the metric
name "RPC". Update the metric prop to reflect the correct context by changing
"RPC" to "Engine Cloud" or another appropriate name that matches the Engine
Cloud analytics theme of this component.

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)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/EngineCloudBarChartCardUI.tsx (2)

66-66: Remove debug logging for production.

The console.log statement should be removed before merging to production to avoid cluttering the browser console.

-  console.log("[DEBUG] data:", data);

68-70: Consider updating the metric name for accuracy.

The EmptyStateCard uses "RPC" as the metric name, but this component displays "Engine Cloud Requests". Consider using a more descriptive metric name that matches the actual data being visualized.

-    return <EmptyStateCard metric="RPC" link="https://portal.thirdweb.com/" />;
+    return <EmptyStateCard metric="Engine Cloud Requests" link="https://portal.thirdweb.com/" />;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 296d445 and fd4e030.

📒 Files selected for processing (7)
  • .gitignore (1 hunks)
  • apps/dashboard/src/@/api/analytics.ts (2 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/EngineCloudBarChartCard.stories.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/EngineCloudBarChartCardUI.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/index.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/page.tsx (2 hunks)
  • apps/dashboard/src/types/analytics.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • .gitignore
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/page.tsx
  • apps/dashboard/src/types/analytics.ts
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/index.tsx
  • apps/dashboard/src/@/api/analytics.ts
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/EngineCloudBarChartCard.stories.tsx
🧰 Additional context used
🪛 GitHub Check: Lint Packages
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/EngineCloudBarChartCardUI.tsx

[failure] 113-113:
'_item' is defined but never used

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Size
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/EngineCloudBarChartCardUI.tsx (3)

23-64: LGTM: Well-structured data processing logic.

The useMemo implementation efficiently processes the raw data:

  • Correctly filters out empty pathnames
  • Properly groups data by date and pathname
  • Handles missing values with sensible defaults
  • Creates appropriate chart configuration
  • Includes empty state detection

The logic is robust and handles edge cases well.


72-140: LGTM: Comprehensive chart implementation.

The chart implementation includes:

  • Proper responsive design with aspect ratio controls
  • Accessible features with accessibilityLayer
  • Well-formatted tooltips and axis labels
  • Appropriate margin and styling configuration
  • Dynamic color assignment using CSS variables

The overall structure follows React and recharts best practices.

🧰 Tools
🪛 GitHub Check: Lint Packages

[failure] 113-113:
'_item' is defined but never used


125-130:

❓ Verification inconclusive

Verify bar radius logic for stacked bars.

The radius configuration might not render as expected for stacked bars. The current logic applies radius to the first and last pathnames, but in stacked bars, this should apply to the bottom and top segments of each bar, not the first and last data series.

Consider testing this with multiple pathnames to ensure the visual appearance is correct. You might need to adjust the radius logic or use a different approach for stacked bar styling.


🏁 Script executed:

#!/bin/bash
# Search for similar stacked bar implementations to compare patterns
rg -A 10 -B 5 "stackId.*radius" --type tsx --type ts

Length of output: 82


Check radius logic for stacked bar segments

It looks like the current radius array is keyed to the first and last data series, but for stacked bars you’ll want the bottom and top segments of each individual bar to be rounded instead. No other instances of radius on stacked bars were found, so please manually verify and adjust as needed:

• File apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/EngineCloudBarChartCardUI.tsx
– Lines 125–130:
ts radius={[ idx === pathnames.length - 1 ? 4 : 0, // currently rounds “last” series idx === pathnames.length - 1 ? 4 : 0, idx === 0 ? 4 : 0, // currently rounds “first” series idx === 0 ? 4 : 0, ]}

Please test with multiple stacked segments to ensure the correct segments are rounded (bottom vs. top), and adjust the condition or approach (e.g. targeting segment index within each bar) accordingly.

Copy link
Contributor

github-actions bot commented May 29, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 62.11 KB (0%) 1.3 s (0%) 377 ms (+126.01% 🔺) 1.7 s
thirdweb (cjs) 345.28 KB (0%) 7 s (0%) 1.3 s (+5.55% 🔺) 8.2 s
thirdweb (minimal + tree-shaking) 5.7 KB (0%) 114 ms (0%) 84 ms (+762.11% 🔺) 198 ms
thirdweb/chains (tree-shaking) 531 B (0%) 11 ms (0%) 17 ms (+537.18% 🔺) 27 ms
thirdweb/react (minimal + tree-shaking) 19.52 KB (0%) 391 ms (0%) 37 ms (+11.99% 🔺) 427 ms

@arcoraven arcoraven force-pushed the 05-29-feat_add_engine_cloud_analytics_to_project_overview branch from fd4e030 to aec4b06 Compare May 29, 2025 18:57
Copy link
Contributor

graphite-app bot commented May 30, 2025

Merge activity

# [Dashboard] Feature: Add Engine Cloud Analytics Charts

Example screenshot:

![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/vKjRiOG6EUjD7XH4cppU/73d7e2b9-23bd-46b5-8cae-5564a3630770.png)

## Notes for the reviewer
This PR adds Engine Cloud analytics to the dashboard, displaying request data in a bar chart visualization. The implementation includes:

1. A new API endpoint to fetch Engine Cloud method usage data
2. New UI components for displaying Engine Cloud analytics:
   - `EngineCloudBarChartCardUI` - Shows Engine Cloud requests by pathname
   - `EngineCloudChartCardUI` - Shows Engine Cloud methods usage with percentage breakdown
3. Integration of the new chart into the project analytics page

## How to test
- View the Storybook component at "Analytics/EngineCloudBarChartCard"
- Navigate to a project dashboard to see the Engine Cloud analytics chart
- Verify data is properly fetched and displayed in the chart

<!-- start pr-codex -->

---

## PR-Codex overview
This PR introduces a new feature to track and visualize `EngineCloud` statistics in the dashboard, enhancing analytics capabilities with new components and API integrations.

### Detailed summary
- Added `EngineCloudStats` interface in `analytics.ts`.
- Implemented `getEngineCloudMethodUsage` API function.
- Created `EngineCloudChartCard` component for displaying cloud stats.
- Developed `EngineCloudBarChartCardUI` for rendering bar charts.
- Added storybook entries for `EngineCloudBarChartCardUI`.
- Enhanced existing analytics with new data visualizations.

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

<!-- end pr-codex -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Introduced a stacked bar chart visualization for engine cloud request statistics in the analytics dashboard.
  - Added a chart card displaying engine cloud method usage data with loading state support.
  - Enhanced analytics with time series data for multiple API pathnames.
  - Included engine cloud method usage data in the project analytics view.

- **Chores**
  - Updated `.gitignore` to exclude the `.pnpm-store/` directory from version control.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dashboard Involves changes to the Dashboard.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants