Skip to content

Conversation

@lohanidamodar
Copy link
Member

@lohanidamodar lohanidamodar commented Jan 21, 2026

What does this PR do?

  • Add screenshots generated metric to usage reports

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?

YES

Summary by CodeRabbit

  • New Features
    • Added "Screenshots generated" as a tracked usage metric across billing and usage UIs.
    • Visible in billing plan summaries, organization and project usage dashboards, charts, progress bars, and project-level breakdowns.
    • New dashboard panels and billing table rows mirror existing image-transformation displays so users can monitor totals, trends, and per-project consumption.

✏️ Tip: You can customize this high-level summary in your review settings.

@appwrite
Copy link

appwrite bot commented Jan 21, 2026

Console (appwrite/console)

Project ID: 688b7bf400350cbd60e9

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

Tip

GraphQL API works alongside REST and WebSocket protocols

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2026

Walkthrough

Adds a new billing metric "screenshots generated" across the codebase. Type definitions in src/lib/sdk/billing.ts gain fields: Plan.screenshotsGenerated, OrganizationUsage.screenshotsGeneratedTotal, and OrganizationUsage.projects[].screenshotsGenerated. UI updates add displays for the metric in billing plan summaries and usage pages: new rows/cards, a BarChart-derived view, and a ProjectBreakdown metric union extended to include "screenshotsGenerated". The page load early-return now includes null-initialized screenshotsGenerated and screenshotsGeneratedTotal. All changes are additive; no existing fields or control flow were removed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a screenshots generated metric to billing and usage reports, which aligns with all file modifications across the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/lib/sdk/billing.ts (1)

289-322: Missing screenshotsGenerated fields in OrganizationUsage type causes pipeline failures.

The pipeline errors indicate that screenshotsGeneratedTotal does not exist on type OrganizationUsage. The type needs to be updated to include both the time-series array and total fields, similar to other metrics like imageTransformations.

🔧 Proposed fix
 export type OrganizationUsage = {
     bandwidth: Array<Models.Metric>;
     executions: Array<Models.Metric>;
     databasesReads: Array<Models.Metric>;
     databasesWritesTotal: Array<Models.Metric>;
     imageTransformations: Array<Models.Metric>;
+    screenshotsGenerated: Array<Models.Metric>;
     executionsTotal: number;
     filesStorageTotal: number;
     buildsStorageTotal: number;
     databasesReadsTotal: number;
     databasesWritesTotal: number;
     imageTransformationsTotal: number;
+    screenshotsGeneratedTotal: number;
     deploymentsStorageTotal: number;
     executionsMBSecondsTotal: number;
     buildsMBSecondsTotal: number;
     backupsStorageTotal: number;
     storageTotal: number;
     users: Array<Models.Metric>;
     usersTotal: number;
     projects: Array<{
         projectId: string;
         storage: number;
         executions: number;
         bandwidth: number;
         databasesReads: number;
         databasesWrites: number;
         users: number;
         authPhoneTotal: number;
         authPhoneEstimate: number;
         imageTransformations: number;
+        screenshotsGenerated: number;
     }>;
     authPhoneTotal: number;
     authPhoneEstimate: number;
 };
src/routes/(console)/organization-[organization]/usage/[[invoice]]/ProjectBreakdown.svelte (1)

86-102: Missing format case for screenshotsGenerated - will return undefined.

The format function handles various metrics in the switch statement, but screenshotsGenerated is not included in any case. This will cause the function to return undefined when formatting screenshot values in the project breakdown table.

🔧 Proposed fix
     function format(value: number): string {
         if (databaseOperationMetric) {
             return abbreviateNumber(value);
         }

         switch (metric) {
             case 'imageTransformations':
+            case 'screenshotsGenerated':
             case 'authPhoneTotal':
                 return formatNumberWithCommas(value);
             case 'executions':
             case 'users':
                 return abbreviateNumber(value);
             case 'storage':
             case 'bandwidth':
                 return humanFileSize(value).value + humanFileSize(value).unit;
         }
     }
🤖 Fix all issues with AI agents
In
`@src/routes/`(console)/organization-[organization]/usage/[[invoice]]/+page.svelte:
- Around line 330-336: The OrganizationUsage type is missing
screenshotsGenerated and screenshotsGeneratedTotal used by the Svelte page;
update the OrganizationUsage interface/type (named OrganizationUsage) in the
billing SDK to include screenshotsGenerated: number and
screenshotsGeneratedTotal: number (or optional number if backend may omit them),
ensure they are exported and any mapping/parsing code that builds
OrganizationUsage from API responses populates these fields so
data.organizationUsage.screenshotsGeneratedTotal in the +page.svelte resolves
correctly.
- Around line 345-355: The BarChart series for "Screenshots generated" is using
the wrong data source; replace references to
data.organizationUsage.imageTransformations with
data.organizationUsage.screenshotsGenerated in the series mapping so the chart
maps (e.date, e.value) from screenshotsGenerated instead of
imageTransformations; update the series object in the component where the chart
is defined (the code creating series={[ { name: 'Screenshots generated', data:
[...] } ]}) to use screenshotsGenerated.

In
`@src/routes/`(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.svelte:
- Around line 252-258: The label text for the screenshots metric is wrong:
update the hardcoded span that currently reads "Transformations" (near the span
containing {current} in the +page.svelte markup) to "Screenshots generated" so
the UI correctly reflects the screenshots metric; ensure you only change the
visible label string and leave the surrounding structure and the {current}
variable intact.

Comment on lines +345 to +355
series={[
{
name: 'Screenshots generated',
data: [
...(data.organizationUsage.imageTransformations ?? []).map((e) => [
e.date,
e.value
])
]
}
]} />
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 | 🔴 Critical

Bug: Chart uses wrong data source - displays imageTransformations instead of screenshotsGenerated.

The BarChart is mapping data.organizationUsage.imageTransformations instead of data.organizationUsage.screenshotsGenerated. This will display incorrect data in the "Screenshots generated" chart.

🐛 Proposed fix
                     series={[
                         {
                             name: 'Screenshots generated',
                             data: [
-                                ...(data.organizationUsage.imageTransformations ?? []).map((e) => [
+                                ...(data.organizationUsage.screenshotsGenerated ?? []).map((e) => [
                                     e.date,
                                     e.value
                                 ])
                             ]
                         }
                     ]} />
🤖 Prompt for AI Agents
In
`@src/routes/`(console)/organization-[organization]/usage/[[invoice]]/+page.svelte
around lines 345 - 355, The BarChart series for "Screenshots generated" is using
the wrong data source; replace references to
data.organizationUsage.imageTransformations with
data.organizationUsage.screenshotsGenerated in the series mapping so the chart
maps (e.date, e.value) from screenshotsGenerated instead of
imageTransformations; update the series object in the component where the chart
is defined (the code creating series={[ { name: 'Screenshots generated', data:
[...] } ]}) to use screenshotsGenerated.

Comment on lines +252 to +258
<div class="u-flex u-flex-vertical">
<div class="u-flex u-main-space-between">
<p>
<span class="heading-level-4">{current}</span>
<span class="body-text-1 u-bold">Transformations</span>
</p>
</div>
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

Incorrect label: Shows "Transformations" instead of "Screenshots".

The label text appears to be a copy/paste artifact from the Image transformations section. It should reflect the "Screenshots generated" metric.

✏️ Proposed fix
                 <div class="u-flex u-flex-vertical">
                     <div class="u-flex u-main-space-between">
                         <p>
                             <span class="heading-level-4">{current}</span>
-                            <span class="body-text-1 u-bold">Transformations</span>
+                            <span class="body-text-1 u-bold">Screenshots</span>
                         </p>
                     </div>
                 </div>
📝 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.

Suggested change
<div class="u-flex u-flex-vertical">
<div class="u-flex u-main-space-between">
<p>
<span class="heading-level-4">{current}</span>
<span class="body-text-1 u-bold">Transformations</span>
</p>
</div>
<div class="u-flex u-flex-vertical">
<div class="u-flex u-main-space-between">
<p>
<span class="heading-level-4">{current}</span>
<span class="body-text-1 u-bold">Screenshots</span>
</p>
</div>
🤖 Prompt for AI Agents
In
`@src/routes/`(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.svelte
around lines 252 - 258, The label text for the screenshots metric is wrong:
update the hardcoded span that currently reads "Transformations" (near the span
containing {current} in the +page.svelte markup) to "Screenshots generated" so
the UI correctly reflects the screenshots metric; ensure you only change the
visible label string and leave the surrounding structure and the {current}
variable intact.

@lohanidamodar lohanidamodar merged commit 1c4dd01 into main Jan 21, 2026
4 checks passed
@lohanidamodar lohanidamodar deleted the feat-new-metric branch January 21, 2026 12:53
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.

3 participants