Skip to content

feat: add Premium Geo DB addon to project settings#2981

Open
lohanidamodar wants to merge 13 commits intomainfrom
feat/project-premium-geo-db-addon
Open

feat: add Premium Geo DB addon to project settings#2981
lohanidamodar wants to merge 13 commits intomainfrom
feat/project-premium-geo-db-addon

Conversation

@lohanidamodar
Copy link
Copy Markdown
Member

Summary

Adds a Premium Geo DB section to the project settings page so users can enable and disable the premium geolocation addon per-project on cloud.

The section supports the full addon lifecycle, mirroring the BAA pattern at the organization level:

  • Upgrade prompt when the current plan does not support the addon
  • Enable flow with optional 3DS payment authentication
  • Pending state with cancel & retry option (if payment was interrupted)
  • Active state with disable action
  • Scheduled-for-removal state with re-enable action

Uses the new project-scoped SDK methods shipped with the cloud update: listAddons, createPremiumGeoDBAddon, and deleteAddon. Bumps the @appwrite.io/console SDK pin accordingly.

Test plan

  • Navigate to a cloud project's settings as an org owner on a plan that supports Premium Geo DB → section appears with Enable CTA
  • Click Enable → modal confirms and enables the addon (3DS where required); section transitions to Active
  • Click Disable → confirms removal at end of billing cycle; section transitions to Scheduled-for-removal
  • Click Keep Premium Geo DB while Scheduled-for-removal → returns to Active
  • On a plan that doesn't support the addon → shows Upgrade plan CTA / "not available" copy
  • On self-hosted mode → section is hidden

🤖 Generated with Claude Code

Adds a Premium Geo DB section to the project settings page so users
can enable and disable the premium geolocation addon per-project on
cloud. The section supports the full addon lifecycle:

- Upgrade prompt when the current plan does not support the addon
- Enable flow with optional 3DS payment authentication
- Pending state with cancel & retry option
- Active state with disable action
- Scheduled-for-removal state with re-enable action

Uses the new project-scoped SDK methods: listAddons, createPremiumGeoDBAddon,
and deleteAddon. Bumps the @appwrite.io/console SDK pin accordingly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 18, 2026

Greptile Summary

This PR adds a Premium Geo DB settings section to the project settings page, mirroring the existing BAA addon pattern at the organization level. The new UI handles the full addon lifecycle (enable with optional 3DS, pending/active/scheduled-for-removal states, disable/re-enable flows) and is correctly guarded behind isCloud.

  • handleReEnable silently ignores 3DS response: createPremiumGeoDBAddon can return a Models.PaymentAuthentication with a clientSecret, but handleReEnable discards the return value entirely — unlike the enable modal and BAA.svelte which both check 'clientSecret' in result and call confirmPayment. When re-enabling after a scheduled removal requires 3DS, the payment challenge is never initiated and the addon stays in pending state silently.
  • Missing onMount 3DS return handler: After Stripe redirects back to ?type=confirm-addon&addonId=..., there is no onMount equivalent (unlike BAA.svelte lines 41–117) to call confirmAddonPayment; the addon remains pending indefinitely with no recovery path except manual "Cancel & retry".
  • Potential duplicate billing rows in planSummary.svelte: the new per-project addon_ rows inside the project breakdown may duplicate the existing org-level addon_ top-level rows if the billing API surfaces the same resource in both currentAggregation.resources and breakdown[].resources.

Confidence Score: 2/5

Not safe to merge — two P1 3DS payment flow gaps leave addons stuck in pending state, and a potential billing row duplication needs confirmation

Multiple P1 defects: handleReEnable silently drops 3DS PaymentAuthentication responses (addon never activates when 3DS is required on re-enable), and there is no onMount handler to confirm the 3DS redirect on page load. Both are present in the BAA reference implementation but absent here. Together they break the payment flow for a meaningful subset of users.

src/routes/(console)/project-[region]-[project]/settings/premiumGeoDB.svelte (handleReEnable + missing onMount) and src/routes/(console)/organization-[organization]/billing/planSummary.svelte (potential duplicate addon rows)

Important Files Changed

Filename Overview
src/routes/(console)/project-[region]-[project]/settings/premiumGeoDB.svelte New Premium Geo DB settings card — missing onMount 3DS redirect handler and handleReEnable does not handle PaymentAuthentication response, leaving addon stuck in pending state
src/routes/(console)/project-[region]-[project]/settings/premiumGeoDBEnableModal.svelte Enable modal correctly handles 3DS PaymentAuthentication branching and 409-conflict recovery; uses Svelte 5 runes ($props/$state) while parent uses Svelte 4 legacy syntax
src/routes/(console)/project-[region]-[project]/settings/premiumGeoDBDisableModal.svelte Disable modal is straightforward — calls deleteAddon, invalidates dependencies, and closes; no logic issues
src/routes/(console)/project-[region]-[project]/settings/+page.ts Adds listAddons and getAddonPrice fetches behind isCloud guard using Promise.allSettled with .catch(() => null) fallback; returns addons and addonPrice to page
src/routes/(console)/project-[region]-[project]/settings/+page.svelte Wires PremiumGeoDB component under isCloud && canWriteProjects guard; minimal change, looks correct
src/routes/(console)/organization-[organization]/billing/planSummary.svelte Removes billingAddonNames hardcoded map in favour of addon.name; adds per-project addon_ rows in project breakdown — these may duplicate the existing org-level addon_ rows, and addon.name absence could degrade BAA display

Reviews (10): Last reviewed commit: "chore: update console SDK to 352239b" | Re-trigger Greptile

Comment on lines +64 to +83
async function handleReEnable() {
reEnabling = true;
try {
await sdk.forConsoleIn(page.params.region).projects.createPremiumGeoDBAddon({
projectId: page.params.project
});
await Promise.all([invalidate(Dependencies.ADDONS), invalidate(Dependencies.PROJECT)]);
addNotification({
message: 'Premium Geo DB addon has been re-enabled',
type: 'success'
});
} catch (e) {
addNotification({
message: e.message,
type: 'error'
});
} finally {
reEnabling = false;
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 handleReEnable silently drops 3DS response

createPremiumGeoDBAddon can return either a Models.Addon (immediate success) or a Models.PaymentAuthentication (3DS required). handleReEnable discards the return value entirely, so if re-enabling requires 3DS the payment challenge is never initiated — the notification fires as "re-enabled" while the addon actually sits in pending state waiting for a payment that will never complete.

The enable modal handles this correctly via the 'clientSecret' in result check and subsequent confirmPayment call. handleReEnable should mirror that same pattern, exactly as BAA.svelte's handleReEnable does.

lohanidamodar and others added 4 commits April 19, 2026 11:13
Mirrors the BAA addon UX by fetching the addon price via
organizations.getAddonPrice(Addon.Premiumgeodb) from the settings
page loader, passing it through to the Premium Geo DB card and
enable modal, and rendering the monthly/prorated breakdown with
formatCurrency alongside the Enable CTA.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…name

- Each project row in the organization billing breakdown now iterates
  its resources for addon_* entries (amount > 0) and renders them as
  child rows (e.g. Premium Geo DB under the project it was enabled on).
  The backend already filters project-scoped addons out of the
  team-level resources response, so the org "Addons" section shows only
  org-scoped addons (BAA, premiumGeoDBOrg) while project-scoped ones
  surface where they belong.
- Org-level addon labels now read addon.name from the UsageResource
  payload that the getAggregation endpoint populates from billingAddons
  config. Dropped the hard-coded billingAddonNames map so new addons
  surface with their proper name without a console update.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment on lines +268 to +269
: addon.name ||
`${addon.resourceId} overage (${formatNum(addon.value)})`,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 BAA label regression if API omits name

The hardcoded billingAddonNames map (addon_baa → 'HIPAA BAA') has been removed in favour of addon.name. If the billing-aggregation API response doesn't populate name on existing BAA resources, BAA will display as addon_baa overage (1) in the plan summary for current BAA subscribers. Make sure the cloud API (and the new SDK pin) actually includes name on billing resource objects, or keep a fallback map alongside the API-provided name as a safety net.

…geo-db-addon

# Conflicts:
#	bun.lock
#	package.json
#	src/routes/(console)/project-[region]-[project]/settings/+page.svelte
…geo-db-addon

# Conflicts:
#	bun.lock
#	package.json
…geo-db-addon

# Conflicts:
#	src/routes/(console)/project-[region]-[project]/settings/+page.svelte
#	src/routes/(console)/project-[region]-[project]/settings/+page.ts
Comment on lines +399 to +410
...resources
.filter((r) => r.resourceId?.startsWith('addon_') && (r.amount ?? 0) > 0)
.map((addon) =>
createRow({
id: `addon-${addon.resourceId}`,
label: addon.name || addon.resourceId,
resource: addon,
usageFormatter: ({ value }) => formatNum(value),
priceFormatter: ({ amount }) => formatCurrency(amount),
includeProgress: false
})
),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Possible double-counting of addon charges in plan summary

The top-level addons section (line 252–275) already creates a billing row for every addon_-prefixed resource found in currentAggregation.resources. If the billing API also surfaces those same addon resources inside projectData.resources (the per-project breakdown), each project-scoped addon (e.g. Premium Geo DB) will appear as both a top-level line item and a child row — showing the same charge twice to the user.

Before shipping, confirm whether the cloud billing API places project-level addon charges exclusively in breakdown[].resources (making the top-level filter skip them) or in both places. If the former, this code is correct; if the latter, the top-level addons filter needs to exclude resources that are already accounted for at the project level (or vice-versa).

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.

1 participant