Skip to content

Conversation

@lohanidamodar
Copy link
Member

@lohanidamodar lohanidamodar commented Nov 24, 2025

What does this PR do?

  • Create downgrade feedback

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

    • Organizations client integrated into the console SDK for managing organization-related operations.
    • Downgrade feedback flow added to submit plan-change feedback via the console SDK.
  • Chores

    • Updated @appwrite.io/console dependency.

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

@appwrite
Copy link

appwrite bot commented Nov 24, 2025

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

JWT tokens let functions act on behalf of users while preserving their permissions

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 24, 2025

Walkthrough

Adds an Organizations client to the console SDK and updates package.json to point to a different @appwrite.io/console commit. The SDK store now initializes and exposes organizations on the console SDK object. A plan change page is refactored to replace a manual HTTP POST and invoice-derived payload with a single createDowngradeFeedback call on the console organizations API, sending organizationId, fromPlanId, toPlanId, reason, and message.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect package.json dependency change to confirm the referenced commit includes the Organizations client and the expected API surface.
  • Review src/lib/stores/sdk.ts to ensure Organizations is imported and initialized correctly and that the console SDK object shape is consistent.
  • Review src/routes/(console)/organization-[organization]/change-plan/+page.svelte to verify the new createDowngradeFeedback call uses the correct fields and that error/success handling remains appropriate.
  • Confirm no other code paths rely on the previously sent invoice-derived fields (paidInvoices, email, orgAge, userAge) and update callers if necessary.

Pre-merge checks and finishing touches

✅ 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 'Feat: downgrade feedback' directly aligns with the main change: adding downgrade feedback functionality via a new SDK-based flow in the Organizations API.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-feedback

📜 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 86ec87d and b352dcb.

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

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

🧹 Nitpick comments (2)
src/routes/(console)/organization-[organization]/change-plan/+page.svelte (2)

142-152: Add error handling for downgrade feedback.

The trackDowngradeFeedback function lacks error handling. If the SDK call fails, it will propagate to the downgrade() function's catch block, potentially causing the entire downgrade flow to fail even though feedback is non-critical.

Consider wrapping the SDK call in try/catch to prevent feedback errors from blocking the downgrade:

 async function trackDowngradeFeedback() {
+    try {
         await sdk.forConsole.organizations.createDowngradeFeedback({
             organizationId: data.organization.$id,
             reason: feedbackDowngradeOptions.find(
                 (option) => option.value === feedbackDowngradeReason
             )?.label,
             message: feedbackMessage ?? '',
             fromPlanId: data.organization.billingPlan,
             toPlanId: selectedPlan
         });
+    } catch (error) {
+        console.warn('Failed to submit downgrade feedback:', error);
+    }
 }

145-147: Add safety check for reason mapping.

The reason mapping could return undefined if feedbackDowngradeReason doesn't match any option value. While this may be prevented by form validation, adding a fallback improves robustness.

Apply this diff to add a fallback:

         reason: feedbackDowngradeOptions.find(
             (option) => option.value === feedbackDowngradeReason
-        )?.label,
+        )?.label ?? feedbackDowngradeReason ?? 'Not specified',
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9cbf8d2 and 86ec87d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • package.json (1 hunks)
  • src/lib/stores/sdk.ts (2 hunks)
  • src/routes/(console)/organization-[organization]/change-plan/+page.svelte (1 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
🔇 Additional comments (4)
src/lib/stores/sdk.ts (2)

26-26: LGTM: Organizations SDK properly integrated.

The Organizations client is correctly imported and initialized, following the same pattern as other SDK clients. This enables the console SDK to expose the downgrade feedback functionality used in the page component.

Also applies to: 100-100


25-25: Verify Realtime addition is within PR scope.

The Realtime client import and initialization appear unrelated to the PR's stated objective of adding "downgrade feedback" functionality. While the implementation follows the correct pattern, confirm whether this change is intentional or should be part of a separate PR.

Also applies to: 99-99

package.json (1)

25-25: Verify the updated dependency commit contains the Organizations SDK.

The dependency for @appwrite.io/console has been updated to commit acef319. Ensure this commit exists and includes the Organizations SDK with the createDowngradeFeedback method that is used in the page component.

Run the following script to verify the commit and check for the Organizations SDK:

src/routes/(console)/organization-[organization]/change-plan/+page.svelte (1)

143-151: Verify the SDK method signature and availability.

Ensure the createDowngradeFeedback method exists on sdk.forConsole.organizations with the expected signature accepting { organizationId, reason, message, fromPlanId, toPlanId }.

Run the following script to verify the method exists in the Organizations SDK:

@lohanidamodar lohanidamodar merged commit 4371c8f into main Nov 25, 2025
4 checks passed
@lohanidamodar lohanidamodar deleted the feat-feedback branch November 25, 2025 05:18
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