Skip to content

Conversation

@MananTank
Copy link
Member

@MananTank MananTank commented Aug 6, 2025


PR-Codex overview

This PR introduces the authToken parameter 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

  • Added authToken prop to multiple components and functions.
  • Refactored API calls to include authToken for data fetching.
  • Updated functions like getUserOpUsage, getWalletConnections, and others to accept authToken.
  • Modified components like InAppWalletsSummary, EcosystemAnalyticsPage, and ProjectAnalytics to utilize the new authToken.

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

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.

@changeset-bot
Copy link

changeset-bot bot commented Aug 6, 2025

⚠️ No Changeset found

Latest commit: 86d38c8

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 Aug 6, 2025

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

Name Status Preview Comments Updated (UTC)
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 7, 2025 2:40pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Skipped (Inspect) Aug 7, 2025 2:40pm
nebula ⬜️ Skipped (Inspect) Aug 7, 2025 2:40pm
thirdweb_playground ⬜️ Skipped (Inspect) Aug 7, 2025 2:40pm
wallet-ui ⬜️ Skipped (Inspect) Aug 7, 2025 2:40pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 6, 2025

Note

Other AI code review bot(s) detected

CodeRabbit 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.

Walkthrough

This 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 unstable_cache. All affected functions now accept an authToken parameter, and parameter normalization is standardized. Component and API call signatures are updated throughout the app to propagate and utilize the authToken for authenticated requests.

Changes

Cohort / File(s) Change Summary
Analytics API Refactor
apps/dashboard/src/@/api/analytics.ts
Refactored all analytics data fetching to require explicit authToken parameters, added parameter normalization, introduced caching with unstable_cache, standardized error handling, and updated function/type signatures accordingly.
Team Overview Analytics
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/page.tsx
Updated getProjectsWithAnalytics and its invocation to require and pass authToken; updated call to getWalletConnections to include authToken.
Team Analytics Highlights Card
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/analytics/highlights-card.tsx,
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/overview/highlights-card.tsx
Changed default activeChart from "totalVolume" to "activeUsers" if selectedChart is undefined or invalid.
Team Analytics Page and Subcomponents
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/analytics/page.tsx
Added authentication token retrieval and enforced login redirect if missing; propagated authToken as required prop to all analytics-fetching child components and their API calls.
Ecosystem Analytics Page and Subcomponents
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/analytics/components/EcosystemAnalyticsPage.tsx,
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/analytics/page.tsx
Added authToken as a required prop to the main ecosystem analytics page and its async subcomponents, and passed it to all API calls.
Account Abstraction Analytics
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/account-abstraction/AccountAbstractionAnalytics/AccountAbstractionSummary.tsx,
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/account-abstraction/page.tsx
Updated summary and page components to require and forward authToken to analytics API calls.
Engine Cloud and RPC Method Chart Cards
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/index.tsx,
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/RpcMethodBarChartCard/index.tsx
Refactored async chart card components to accept params and authToken props, passing both to analytics API calls.
Transactions Chart Card
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/Transactions/index.tsx
Refactored to accept a single props object with params and authToken, and updated analytics API calls accordingly.
Insight Analytics
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/insight/components/InsightAnalytics.tsx,
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/insight/page.tsx
Extended analytics and page components to accept and forward authToken to all insight analytics API calls.
Project Overview Analytics
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/page.tsx
Propagated authToken through the overview page and all nested analytics components and API calls; consolidated parameter passing for consistency.
Payments Analytics
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/payments/components/PayAnalytics.tsx,
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/payments/analytics/page.tsx
Added authToken as a required prop and forwarded it to all universal bridge analytics API calls.
RPC Analytics
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/rpc/components/RpcAnalytics.tsx,
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/rpc/page.tsx
Added and propagated authToken prop through RPC analytics components and API calls.
Wallet Analytics and Summary
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/wallets/analytics/chart/Summary.tsx,
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/wallets/analytics/chart/index.tsx,
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/wallets/page.tsx
Added authToken as required prop to wallet analytics summary and chart components, and passed it to all relevant analytics API calls; enforced login redirect if token missing.
Webhooks Analytics
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/analytics/page.tsx,
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/page.tsx
Updated webhooks analytics and summary API calls to require and receive authToken as an explicit argument.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

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 86d38c8 and 7883127.

📒 Files selected for processing (24)
  • apps/dashboard/src/@/api/analytics.ts (5 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/page.tsx (2 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/analytics/highlights-card.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/analytics/page.tsx (13 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/analytics/components/EcosystemAnalyticsPage.tsx (5 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/analytics/page.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/account-abstraction/AccountAbstractionAnalytics/AccountAbstractionSummary.tsx (3 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/account-abstraction/page.tsx (2 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)/components/RpcMethodBarChartCard/index.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/Transactions/index.tsx (2 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/insight/components/InsightAnalytics.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/insight/page.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/overview/highlights-card.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/page.tsx (13 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/payments/analytics/page.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/payments/components/PayAnalytics.tsx (2 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/rpc/components/RpcAnalytics.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/rpc/page.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/wallets/analytics/chart/Summary.tsx (3 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/wallets/analytics/chart/index.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/wallets/page.tsx (4 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/analytics/page.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/page.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (23)
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/analytics/page.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/analytics/page.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/insight/page.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/page.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/overview/highlights-card.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/payments/components/PayAnalytics.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/payments/analytics/page.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/rpc/page.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/account-abstraction/page.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/analytics/highlights-card.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/page.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/wallets/analytics/chart/index.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/wallets/page.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/analytics/components/EcosystemAnalyticsPage.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/EngineCloudChartCard/index.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/insight/components/InsightAnalytics.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/RpcMethodBarChartCard/index.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/rpc/components/RpcAnalytics.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/wallets/analytics/chart/Summary.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/Transactions/index.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/account-abstraction/AccountAbstractionAnalytics/AccountAbstractionSummary.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/page.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/analytics/page.tsx
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

Files:

  • apps/dashboard/src/@/api/analytics.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • apps/dashboard/src/@/api/analytics.ts
apps/{dashboard,playground-web}/**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

apps/{dashboard,playground-web}/**/*.{ts,tsx}: Import UI primitives from @/components/ui/* (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground apps
Use NavLink for internal navigation with automatic active states in dashboard and playground apps
Use Tailwind CSS only – no inline styles or CSS modules
Use cn() from @/lib/utils for conditional class logic
Use design system tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components (Node edge): Start files with import "server-only";
Client Components (browser): Begin files with 'use client';
Always call getAuthToken() to retrieve JWT from cookies on server side
Use Authorization: Bearer header – never embed tokens in URLs
Return typed results (e.g., Project[], User[]) – avoid any
Wrap client-side data fetching calls in React Query (@tanstack/react-query)
Use descriptive, stable queryKeys for React Query cache hits
Configure staleTime/cacheTime in React Query based on freshness (default ≥ 60s)
Keep tokens secret via internal API routes or server actions
Never import posthog-js in server components

Files:

  • apps/dashboard/src/@/api/analytics.ts
🧠 Learnings (19)
📓 Common learnings
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/api/**/*.{ts,tsx} : Always call `getAuthToken()` to get the JWT from cookies.
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : Use `Authorization: Bearer` header – never embed tokens in URLs
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : Always call `getAuthToken()` to retrieve JWT from cookies on server side
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*.{ts,tsx} : Reading cookies/headers with `next/headers` (`getAuthToken()`, `cookies()`).
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Create light wrappers (e.g. `fetchJson`) that automatically attach the JWT from cookies/session when calling internal API routes.
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/api/**/*.{ts,tsx} : Pass the token in the `Authorization: Bearer` header – never embed it in the URL.
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : Keep tokens secret via internal API routes or server actions
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Prefer API routes or server actions to keep tokens secret; the browser only sees relative paths.
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : Wrap client-side data fetching calls in React Query (`tanstack/react-query`)
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*.{ts,tsx} : Heavy data fetching that should not ship to the client (e.g. analytics, billing).
Learnt from: MananTank
PR: thirdweb-dev/js#7177
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/settings/shared-settings-page.tsx:29-39
Timestamp: 2025-05-27T20:10:47.245Z
Learning: MananTank prefers adding error handling (try-catch) directly inside utility functions like `shouldRenderNewPublicPage` rather than requiring callers to wrap the function calls in try-catch blocks. This centralizes error handling and benefits all callers automatically.
📚 Learning: applies to dashboard/**/*.{ts,tsx} : heavy data fetching that should not ship to the client (e.g. an...
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*.{ts,tsx} : Heavy data fetching that should not ship to the client (e.g. analytics, billing).

Applied to files:

  • apps/dashboard/src/@/api/analytics.ts
📚 Learning: applies to src/@/analytics/report.ts : review `src/@/analytics/report.ts` before adding analytics ev...
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to src/@/analytics/report.ts : Review `src/@/analytics/report.ts` before adding analytics events to check for duplicates

Applied to files:

  • apps/dashboard/src/@/api/analytics.ts
📚 Learning: applies to dashboard/**/api/**/*.{ts,tsx} : always call `getauthtoken()` to get the jwt from cookies...
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/api/**/*.{ts,tsx} : Always call `getAuthToken()` to get the JWT from cookies.

Applied to files:

  • apps/dashboard/src/@/api/analytics.ts
📚 Learning: applies to dashboard/**/*.{ts,tsx} : export default async functions without `'use client';` – they r...
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*.{ts,tsx} : Export default async functions without `'use client';` – they run on the Node edge.

Applied to files:

  • apps/dashboard/src/@/api/analytics.ts
📚 Learning: applies to dashboard/**/*client.tsx : keep `querykey` stable and descriptive for cache hits....
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Keep `queryKey` stable and descriptive for cache hits.

Applied to files:

  • apps/dashboard/src/@/api/analytics.ts
📚 Learning: applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : wrap client-side data fetching calls in r...
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : Wrap client-side data fetching calls in React Query (`tanstack/react-query`)

Applied to files:

  • apps/dashboard/src/@/api/analytics.ts
📚 Learning: applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : always call `getauthtoken()` to retrieve ...
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : Always call `getAuthToken()` to retrieve JWT from cookies on server side

Applied to files:

  • apps/dashboard/src/@/api/analytics.ts
📚 Learning: applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : use descriptive, stable `querykeys` for r...
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : Use descriptive, stable `queryKeys` for React Query cache hits

Applied to files:

  • apps/dashboard/src/@/api/analytics.ts
📚 Learning: applies to dashboard/**/*client.tsx : create light wrappers (e.g. `fetchjson`) that automatically at...
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Create light wrappers (e.g. `fetchJson`) that automatically attach the JWT from cookies/session when calling internal API routes.

Applied to files:

  • apps/dashboard/src/@/api/analytics.ts
📚 Learning: applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : configure `staletime`/`cachetime` in reac...
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : Configure `staleTime`/`cacheTime` in React Query based on freshness (default ≥ 60s)

Applied to files:

  • apps/dashboard/src/@/api/analytics.ts
📚 Learning: applies to dashboard/**/*.{ts,tsx} : accessing server-only environment variables or secrets....
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*.{ts,tsx} : Accessing server-only environment variables or secrets.

Applied to files:

  • apps/dashboard/src/@/api/analytics.ts
📚 Learning: applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : server components (node edge): start file...
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : Server Components (Node edge): Start files with `import "server-only";`

Applied to files:

  • apps/dashboard/src/@/api/analytics.ts
📚 Learning: applies to dashboard/**/*client.tsx : configure `staletime` / `cachetime` according to freshness req...
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Configure `staleTime` / `cacheTime` according to freshness requirements.

Applied to files:

  • apps/dashboard/src/@/api/analytics.ts
📚 Learning: applies to dashboard/**/api/**/*.{ts,tsx} : prefix files with `import "server-only";` so they never ...
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/api/**/*.{ts,tsx} : Prefix files with `import "server-only";` so they never end up in the client bundle.

Applied to files:

  • apps/dashboard/src/@/api/analytics.ts
📚 Learning: applies to dashboard/**/api/**/*.{ts,tsx} : co-locate data helpers under `@/api/**` and mark them wi...
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/api/**/*.{ts,tsx} : Co-locate data helpers under `@/api/**` and mark them with "server-only".

Applied to files:

  • apps/dashboard/src/@/api/analytics.ts
📚 Learning: in next.js server components, the `params` object can sometimes be a promise that needs to be awaite...
Learnt from: jnsdls
PR: thirdweb-dev/js#6929
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/insight/webhooks/page.tsx:14-19
Timestamp: 2025-05-21T05:17:31.283Z
Learning: In Next.js server components, the `params` object can sometimes be a Promise that needs to be awaited, despite type annotations suggesting otherwise. In apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/insight/webhooks/page.tsx, it's necessary to await the params object before accessing its properties.

Applied to files:

  • apps/dashboard/src/@/api/analytics.ts
📚 Learning: applies to dashboard/**/*client.tsx : interactive ui that relies on hooks (`usestate`, `useeffect`, ...
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Interactive UI that relies on hooks (`useState`, `useEffect`, React Query, wallet hooks).

Applied to files:

  • apps/dashboard/src/@/api/analytics.ts
📚 Learning: applies to dashboard/**/*client.tsx : pages requiring fast transitions where data is prefetched on t...
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Pages requiring fast transitions where data is prefetched on the client.

Applied to files:

  • apps/dashboard/src/@/api/analytics.ts
🧬 Code Graph Analysis (1)
apps/dashboard/src/@/api/analytics.ts (3)
apps/dashboard/src/@/lib/time.ts (1)
  • normalizeTime (8-12)
apps/dashboard/src/@/types/analytics.ts (13)
  • AnalyticsQueryParams (94-101)
  • WalletStats (3-8)
  • InAppWalletStats (17-21)
  • UserOpStats (27-33)
  • TransactionStats (35-40)
  • WalletUserStats (10-15)
  • EcosystemWalletStats (23-25)
  • UniversalBridgeStats (49-57)
  • UniversalBridgeWalletStats (59-67)
  • EngineCloudStats (42-47)
  • WebhookSummaryStats (84-92)
  • WebhookRequestStats (69-74)
  • WebhookLatencyStats (76-82)
apps/dashboard/src/@/api/chain.ts (1)
  • getChains (6-12)
⏰ 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: E2E Tests (pnpm, webpack)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Lint Packages
  • GitHub Check: Unit Tests
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (9)
apps/dashboard/src/@/api/analytics.ts (9)

3-5: Good addition of required imports and helper function import.

The addition of unstable_cache for caching and normalizeTime for date normalization aligns with the PR's caching objectives and ensures consistent date handling.


58-64: Well-structured parameter normalization helper.

The normalizedParams function properly applies normalizeTime to date parameters while preserving all other properties, ensuring consistent date handling across all analytics API calls.


66-100: Secure authentication token handling in fetchAnalytics.

The refactored fetchAnalytics function properly accepts an object parameter with explicit authToken, correctly sets the Authorization: Bearer header, and maintains proper URL construction. This aligns with the learnings about keeping tokens secret and using Bearer headers.


127-163: Proper caching implementation for wallet connections.

The cached function correctly uses unstable_cache with appropriate cache key and 1-hour revalidation. Error handling is consistent with logging and returning empty array on failure.


493-568: Consistent implementation for ecosystem wallet usage.

The function properly implements the new pattern with explicit authToken parameter, caching, and manual parameter building for the specific ecosystem endpoint requirements.


570-659: Well-structured Universal Bridge functions with proper typing.

Both Universal Bridge usage functions (getUniversalBridgeUsage and getUniversalBridgeWalletUsage) follow the established pattern with proper parameter types, caching, and error handling.


696-803: Consistent webhook analytics implementation.

All three webhook functions (getWebhookSummary, getWebhookRequests, getWebhookLatency) properly implement the new caching pattern with appropriate error handling that returns structured error objects instead of throwing.


805-955: Proper Insight analytics functions implementation.

All four Insight analytics functions follow the established pattern with consistent error handling that returns structured objects with errorMessage properties, proper caching, and explicit authentication token handling.


451-491: isProjectActive’s params are compatible with buildSearchParams

The buildSearchParams implementation only reads teamId (required) and projectId (optional), and safely ignores any other properties (e.g. authToken). Passing your { teamId, projectId, authToken } object is structurally sound in TypeScript, and there’s no mismatch or runtime risk here.

No changes needed.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 08-07-dashboard_add_caching_to_analytics_usage

🪧 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.
  • 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.

Support

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

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 generate unit tests to generate unit tests for 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.

@MananTank MananTank marked this pull request as ready for review August 6, 2025 21:12
@MananTank MananTank requested review from a team as code owners August 6, 2025 21:12
@github-actions github-actions bot added the Dashboard Involves changes to the Dashboard. label Aug 6, 2025
Copy link
Member Author

MananTank commented Aug 6, 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.

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

@codecov
Copy link

codecov bot commented Aug 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.33%. Comparing base (53d0d74) to head (7883127).
⚠️ Report is 1 commits behind head on main.

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           
Flag Coverage Δ
packages 56.33% <ø> (ø)
🚀 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.

@MananTank MananTank force-pushed the 08-07-dashboard_add_caching_to_analytics_usage branch from 788068b to 95c42f7 Compare August 6, 2025 21:16
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground August 6, 2025 21:16 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 August 6, 2025 21:16 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui August 6, 2025 21:16 Inactive
@vercel vercel bot temporarily deployed to Preview – nebula August 6, 2025 21:16 Inactive
@MananTank MananTank force-pushed the 08-06-dashboard_improved_chart_responsiveness_code_cleanup branch from 5ce2058 to 5e15af1 Compare August 6, 2025 21:18
@MananTank MananTank force-pushed the 08-07-dashboard_add_caching_to_analytics_usage branch from 95c42f7 to 04d6c76 Compare August 6, 2025 21:18
@vercel vercel bot temporarily deployed to Preview – nebula August 6, 2025 21:18 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground August 6, 2025 21:18 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 August 6, 2025 21:18 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui August 6, 2025 21:18 Inactive
@MananTank MananTank force-pushed the 08-07-dashboard_add_caching_to_analytics_usage branch from 04d6c76 to a29048e Compare August 6, 2025 21:23
@vercel vercel bot temporarily deployed to Preview – wallet-ui August 6, 2025 21:23 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground August 6, 2025 21:23 Inactive
@vercel vercel bot temporarily deployed to Preview – nebula August 6, 2025 21:23 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 August 6, 2025 21:23 Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Aug 6, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 63.15 KB (0%) 1.3 s (0%) 86 ms (+152.43% 🔺) 1.4 s
thirdweb (cjs) 352.97 KB (0%) 7.1 s (0%) 130 ms (-2.24% 🔽) 7.2 s
thirdweb (minimal + tree-shaking) 5.72 KB (0%) 115 ms (0%) 54 ms (+947.65% 🔺) 168 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 29 ms (+1405.23% 🔺) 40 ms
thirdweb/react (minimal + tree-shaking) 19.29 KB (0%) 386 ms (0%) 51 ms (+287.31% 🔺) 437 ms

@graphite-app graphite-app bot changed the base branch from 08-06-dashboard_improved_chart_responsiveness_code_cleanup to graphite-base/7804 August 7, 2025 01:18
@MananTank MananTank force-pushed the graphite-base/7804 branch from 5e15af1 to 8bb2b0a Compare August 7, 2025 01:19
@graphite-app graphite-app bot changed the base branch from graphite-base/7804 to main August 7, 2025 01:19
@graphite-app
Copy link
Contributor

graphite-app bot commented Aug 7, 2025

Merge activity

@graphite-app graphite-app bot changed the base branch from main to graphite-base/7804 August 7, 2025 01:24
@graphite-app graphite-app bot changed the base branch from graphite-base/7804 to main August 7, 2025 01:35
@MananTank MananTank force-pushed the 08-07-dashboard_add_caching_to_analytics_usage branch from a29048e to 86d38c8 Compare August 7, 2025 13:49
@vercel vercel bot temporarily deployed to Preview – nebula August 7, 2025 13:49 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground August 7, 2025 13:49 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 August 7, 2025 13:49 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui August 7, 2025 13:49 Inactive
@MananTank MananTank changed the title Dashboard: Add caching to analytics usage Dashboard: Add caching to analytics charts Aug 7, 2025
<!--

## 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 -->
@graphite-app graphite-app bot force-pushed the 08-07-dashboard_add_caching_to_analytics_usage branch from 86d38c8 to 7883127 Compare August 7, 2025 14:33
@vercel vercel bot temporarily deployed to Preview – docs-v2 August 7, 2025 14:33 Inactive
@vercel vercel bot temporarily deployed to Preview – nebula August 7, 2025 14:33 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui August 7, 2025 14:33 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground August 7, 2025 14:33 Inactive
@graphite-app graphite-app bot merged commit 7883127 into main Aug 7, 2025
24 checks passed
@graphite-app graphite-app bot deleted the 08-07-dashboard_add_caching_to_analytics_usage branch August 7, 2025 14:41
@vercel vercel bot temporarily deployed to Production – docs-v2 August 7, 2025 14:41 Inactive
@vercel vercel bot temporarily deployed to Production – wallet-ui August 7, 2025 14:41 Inactive
@vercel vercel bot temporarily deployed to Production – thirdweb_playground August 7, 2025 14:41 Inactive
@vercel vercel bot temporarily deployed to Production – nebula August 7, 2025 14:41 Inactive
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