-
Notifications
You must be signed in to change notification settings - Fork 619
Dashboard: Add caching to analytics charts #7804
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
Dashboard: Add caching to analytics charts #7804
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThis change refactors analytics data fetching across the dashboard app to require explicit authentication tokens and introduces caching for analytics API calls using Next.js's Changes
Sequence Diagram(s)sequenceDiagram
participant PageComponent
participant getAuthToken
participant ChildAnalyticsComponent
participant AnalyticsAPI
PageComponent->>getAuthToken: getAuthToken()
alt Token present
PageComponent->>ChildAnalyticsComponent: Render with authToken
ChildAnalyticsComponent->>AnalyticsAPI: fetchData(params, authToken)
AnalyticsAPI-->>ChildAnalyticsComponent: Data (cached if available)
ChildAnalyticsComponent-->>PageComponent: Rendered analytics
else Token missing
PageComponent->>PageComponent: Redirect to login
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (24)
🚧 Files skipped from review as they are similar to previous changes (23)
🧰 Additional context used📓 Path-based instructions (3)**/*.{ts,tsx}📄 CodeRabbit Inference Engine (CLAUDE.md)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit Inference Engine (CLAUDE.md)
Files:
apps/{dashboard,playground-web}/**/*.{ts,tsx}📄 CodeRabbit Inference Engine (CLAUDE.md)
Files:
🧠 Learnings (19)📓 Common learnings📚 Learning: applies to dashboard/**/*.{ts,tsx} : heavy data fetching that should not ship to the client (e.g. an...Applied to files:
📚 Learning: applies to src/@/analytics/report.ts : review `src/@/analytics/report.ts` before adding analytics ev...Applied to files:
📚 Learning: applies to dashboard/**/api/**/*.{ts,tsx} : always call `getauthtoken()` to get the jwt from cookies...Applied to files:
📚 Learning: applies to dashboard/**/*.{ts,tsx} : export default async functions without `'use client';` – they r...Applied to files:
📚 Learning: applies to dashboard/**/*client.tsx : keep `querykey` stable and descriptive for cache hits....Applied to files:
📚 Learning: applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : wrap client-side data fetching calls in r...Applied to files:
📚 Learning: applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : always call `getauthtoken()` to retrieve ...Applied to files:
📚 Learning: applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : use descriptive, stable `querykeys` for r...Applied to files:
📚 Learning: applies to dashboard/**/*client.tsx : create light wrappers (e.g. `fetchjson`) that automatically at...Applied to files:
📚 Learning: applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : configure `staletime`/`cachetime` in reac...Applied to files:
📚 Learning: applies to dashboard/**/*.{ts,tsx} : accessing server-only environment variables or secrets....Applied to files:
📚 Learning: applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : server components (node edge): start file...Applied to files:
📚 Learning: applies to dashboard/**/*client.tsx : configure `staletime` / `cachetime` according to freshness req...Applied to files:
📚 Learning: applies to dashboard/**/api/**/*.{ts,tsx} : prefix files with `import "server-only";` so they never ...Applied to files:
📚 Learning: applies to dashboard/**/api/**/*.{ts,tsx} : co-locate data helpers under `@/api/**` and mark them wi...Applied to files:
📚 Learning: in next.js server components, the `params` object can sometimes be a promise that needs to be awaite...Applied to files:
📚 Learning: applies to dashboard/**/*client.tsx : interactive ui that relies on hooks (`usestate`, `useeffect`, ...Applied to files:
📚 Learning: applies to dashboard/**/*client.tsx : pages requiring fast transitions where data is prefetched on t...Applied to files:
🧬 Code Graph Analysis (1)apps/dashboard/src/@/api/analytics.ts (3)
⏰ 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)
🔇 Additional comments (9)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7804 +/- ##
=======================================
Coverage 56.33% 56.33%
=======================================
Files 905 905
Lines 58809 58809
Branches 4147 4147
=======================================
Hits 33131 33131
Misses 25573 25573
Partials 105 105
🚀 New features to boost your workflow:
|
788068b to
95c42f7
Compare
5ce2058 to
5e15af1
Compare
95c42f7 to
04d6c76
Compare
04d6c76 to
a29048e
Compare
size-limit report 📦
|
5e15af1 to
8bb2b0a
Compare
Merge activity
|
a29048e to
86d38c8
Compare
<!--
## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes"
If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000):
## Notes for the reviewer
Anything important to call out? Be sure to also clarify these in your comments.
## How to test
Unit tests, playground, etc.
-->
<!-- start pr-codex -->
---
## PR-Codex overview
This PR focuses on enhancing the analytics functionality across various components by adding an `authToken` parameter to API calls, ensuring secure access to analytics data.
### Detailed summary
- Added `authToken` prop to multiple components for secure API access.
- Updated API functions to accept `authToken` for authentication.
- Modified analytics data fetching methods to include `authToken`.
- Changed default values and parameters in several functions for consistency.
> ✨ 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**
* Analytics data fetching now uses caching for improved performance.
* Authentication is enforced for all analytics-related pages and components, with users redirected to login if not authenticated.
* **Refactor**
* All analytics API calls and related components now require an explicit authentication token, improving security and consistency.
* Parameters for analytics functions and components are more consistently structured, often grouped into objects for clarity.
* **Style**
* Default chart display updated from "totalVolume" to "activeUsers" in highlights cards for a more relevant initial view.
* **Bug Fixes**
* Standardized error handling across analytics data requests.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
86d38c8 to
7883127
Compare

PR-Codex overview
This PR introduces the
authTokenparameter across various components and functions, enhancing authentication handling for analytics and data fetching. It also refactors several API calls to include this token for improved security.Detailed summary
authTokenprop to multiple components and functions.authTokenfor data fetching.getUserOpUsage,getWalletConnections, and others to acceptauthToken.InAppWalletsSummary,EcosystemAnalyticsPage, andProjectAnalyticsto utilize the newauthToken.Summary by CodeRabbit
New Features
Refactor
Style
Bug Fixes