Skip to content

Conversation

@HarshMN2345
Copy link
Member

@HarshMN2345 HarshMN2345 commented Nov 3, 2025

What does this PR do?

(Provide a description of what this PR does.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

Summary by CodeRabbit

  • New Features

    • Added tracking and dashboard display for "Screenshots generated" across billing plan summaries, organization and project usage pages, progress bars, charts, and per-project breakdowns.
  • Chores

    • Updated console dependency source and added a new runtime dependency ("install" ^0.13.0).

@appwrite
Copy link

appwrite bot commented Nov 3, 2025

Console

Project ID: 688b7bf400350cbd60e9

Sites (1)
Site Status Logs Preview QR
 console-stage
688b7cf6003b1842c9dc
Ready Ready View Logs Preview URL QR Code

Tip

You can use Avatars API to generate QR code for any text or URLs.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 3, 2025

Walkthrough

This pull request adds a new resource metric, screenshotsGenerated, across billing and usage surfaces. SDK types (OrganizationUsage, Plan, UsageProject) now include screenshotsGenerated arrays and totals; PlanServices union gains 'screenshotsGenerated'. UI pages (organization and project usage, plan summary, project breakdown) display the new metric and reuse existing formatting/progress logic. package.json updates the @appwrite.io/console dependency source and adds an install dependency. No control-flow or error-handling behavior was changed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Files requiring focused review:
    • src/lib/sdk/billing.ts — new fields in public types and nested project entries
    • src/lib/sdk/usage.ts — UsageProject type additions
    • src/lib/stores/billing.ts — PlanServices union change
    • src/routes/(console)/organization-[organization]/billing/planSummary.svelte — data mapping, limit lookups, progress row
    • src/routes/(console)/organization-[organization]/usage/[[invoice]]/+page.svelte and +page.ts — UI block and early-return placeholder fields
    • src/routes/(console)/organization-[organization]/usage/[[invoice]]/ProjectBreakdown.svelte — Metric type and formatting logic
    • src/routes/(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.svelte — project-level UI block
    • package.json — dependency source change and added install
  • Attention points:
    • Ensure type shapes are consistent across SDK, stores, and UI mappings
    • Verify formatting and chart/legend logic treats screenshotsGenerated the same as analogous metrics
    • Confirm plan limit lookups (e.g., currentPlan?.screenshotsGenerated) correctly handle null/undefined and the Unlimited case

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding screenshotsGenerated metrics across the console, which aligns with all modified files that introduce this new tracking capability.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-screenshots-api-billing-metrics-console

📜 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 930d0fb and 1af8a32.

📒 Files selected for processing (1)
  • src/routes/(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.svelte (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/routes/(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.svelte
⏰ 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). (1)
  • GitHub Check: e2e

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c5fd02a and b7e99ba.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (9)
  • package.json (1 hunks)
  • src/lib/sdk/billing.ts (4 hunks)
  • src/lib/sdk/usage.ts (1 hunks)
  • src/lib/stores/billing.ts (1 hunks)
  • src/routes/(console)/organization-[organization]/billing/planSummary.svelte (2 hunks)
  • src/routes/(console)/organization-[organization]/usage/[[invoice]]/+page.svelte (1 hunks)
  • src/routes/(console)/organization-[organization]/usage/[[invoice]]/+page.ts (1 hunks)
  • src/routes/(console)/organization-[organization]/usage/[[invoice]]/ProjectBreakdown.svelte (2 hunks)
  • src/routes/(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.svelte (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-26T06:48:57.938Z
Learnt from: ItzNotABug
Repo: appwrite/console PR: 2373
File: src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte:629-631
Timestamp: 2025-09-26T06:48:57.938Z
Learning: In the Appwrite console codebase using appwrite.io/pink-svelte, the Icon component automatically handles CSS variable names passed to its color prop by internally wrapping them with var(). Therefore, passing '--some-css-variable' as a string to the Icon color prop works correctly without needing to manually wrap it with var().

Applied to files:

  • package.json
🧬 Code graph analysis (1)
src/lib/sdk/billing.ts (1)
src/lib/sdk/usage.ts (1)
  • Metric (21-30)
🪛 ESLint
src/routes/(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.svelte

[error] 33-33: Unexpected any. Specify a different type.

(@typescript-eslint/no-explicit-any)


[error] 34-34: Unexpected any. Specify a different type.

(@typescript-eslint/no-explicit-any)

🔇 Additional comments (10)
src/routes/(console)/organization-[organization]/usage/[[invoice]]/+page.ts (1)

37-39: LGTM! Consistent with existing temporary fix pattern.

The new fields are correctly initialized to null in the early-return path, matching the pattern used for other metrics like imageTransformationsTotal.

src/lib/stores/billing.ts (1)

153-154: LGTM! Service type extension is correct.

The addition of 'screenshotsGenerated' to the PlanServices union follows the existing pattern and enables the new metric to be used with getServiceLimit().

src/lib/sdk/usage.ts (1)

336-344: LGTM! Type definitions follow established pattern.

The new screenshotsGenerated and screenshotsGeneratedTotal fields mirror the structure of imageTransformations, maintaining consistency in the data model.

package.json (1)

25-25: Dependency update noted.

Package version updated to support the new screenshotsGenerated metric feature.

src/routes/(console)/organization-[organization]/usage/[[invoice]]/ProjectBreakdown.svelte (1)

19-20: LGTM! Metric handling is consistent.

The addition of 'screenshotsGenerated' to the Metric type and its formatting logic correctly mirrors the imageTransformations implementation, using formatNumberWithCommas for display.

Also applies to: 93-93

src/lib/sdk/billing.ts (1)

295-295: LGTM! Comprehensive metric integration.

The new screenshotsGenerated metric is properly integrated across all billing data structures:

  • Organization-level metrics and totals
  • Per-project tracking
  • Plan limits and usage pricing

All additions follow the established pattern from imageTransformations.

Also applies to: 302-302, 321-321, 390-390, 418-418

src/routes/(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.svelte (1)

246-283: LGTM! UI implementation follows established patterns.

The new "Screenshots generated" CardGrid section correctly mirrors the structure of other usage metrics, including the chart visualization and "No data to show" fallback state.

src/routes/(console)/organization-[organization]/usage/[[invoice]]/+page.svelte (1)

325-370: LGTM! Organization usage section is well-implemented.

The new "Screenshots generated" section correctly integrates with the billing system, including:

  • Progress bar with current usage and plan limits
  • Bar chart visualization
  • Project breakdown for detailed analysis
  • Proper conditional rendering for empty states

The implementation is consistent with other usage metrics in the file.

src/routes/(console)/organization-[organization]/billing/planSummary.svelte (2)

130-132: LGTM! Resource mapping follows established pattern.

The addition of screenshotsGenerated to the resource mapping is consistent with how other metrics (executions, imageTransformations, etc.) are handled.


286-298: LGTM! Billing row implementation is consistent and complete.

The screenshots generated metric row correctly implements:

  • Formatted usage display with current/limit values
  • Currency formatting for pricing
  • Progress bar visualization
  • Proper handling of unlimited plans

The implementation mirrors the pattern used for other metrics like image transformations, ensuring UI consistency.

Comment on lines 33 to 34
$: screenshotsGenerated = (data.usage as any).screenshotsGenerated ?? null;
$: screenshotsGeneratedTotal = (data.usage as any).screenshotsGeneratedTotal ?? 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Address type casting with proper type definitions.

The as any casts bypass TypeScript's type safety. Since screenshotsGenerated and screenshotsGeneratedTotal are defined in the UsageProject type (src/lib/sdk/usage.ts), the data loader should be updated to properly type the usage data.

Consider updating the data loader or type imports to avoid the as any cast:

-$: screenshotsGenerated = (data.usage as any).screenshotsGenerated ?? null;
-$: screenshotsGeneratedTotal = (data.usage as any).screenshotsGeneratedTotal ?? 0;
+$: screenshotsGenerated = data.usage.screenshotsGenerated ?? null;
+$: screenshotsGeneratedTotal = data.usage.screenshotsGeneratedTotal ?? 0;

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 ESLint

[error] 33-33: Unexpected any. Specify a different type.

(@typescript-eslint/no-explicit-any)


[error] 34-34: Unexpected any. Specify a different type.

(@typescript-eslint/no-explicit-any)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants