Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughMigrates checkout from client-side Astro actions to a server-side API route, swaps the Polar dependency from Changes
Sequence DiagramsequenceDiagram
participant User as User
participant PricingPage as Pricing Page
participant APIRoute as /api/checkout
participant Polar as Polar Service
User->>PricingPage: Click pricing button
PricingPage->>PricingPage: disable button, show loading
PricingPage->>APIRoute: Navigate to /api/checkout?products=<productId>
APIRoute->>Polar: Create checkout session (productId, successUrl)
Polar-->>APIRoute: Return checkout URL
APIRoute-->>User: Redirect to returned checkout URL
PricingPage->>PricingPage: on visibility/pageshow restore button state
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
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. Comment |
|
Coverage Impact This PR will not change total coverage. 🚦 See full report on Qlty Cloud »🛟 Help
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@landing/package.json`:
- Line 16: package.json lists a non-existent "@polar-sh/astro" version "0.7.3"
which breaks npm install and the Checkout import in
landing/src/pages/api/checkout.ts; update the dependency entry for
"@polar-sh/astro" to a valid published version such as "^0.4.6" (or the latest
available) so the package resolves correctly and the Checkout import can be
found during build.
In `@landing/src/pages/pricing.astro`:
- Around line 376-377: The client-side call using navigate() to hit the server
endpoint /api/checkout with products=${productId} should be replaced with a
full-page browser navigation so the server-side redirect to Polar's external
checkout can be followed; locate the call to navigate(...) (using the productId
variable) in pricing.astro and replace it with a standard browser navigation
method (e.g., window.location.href or location.assign) so the request performs a
full-page load and the server redirect is honored.
🧹 Nitpick comments (3)
landing/src/pages/api/checkout.ts (1)
5-8: Silent fallback to empty access token could cause confusing runtime errors.If
POLAR_ACCESS_TOKENis unset, the empty-string fallback will let the request reach Polar's API, which will likely reject it with an opaque auth error. Consider failing fast at startup or at least logging a clear message.Proposed improvement
+const accessToken = import.meta.env.POLAR_ACCESS_TOKEN; +if (!accessToken) { + throw new Error('POLAR_ACCESS_TOKEN environment variable is not set'); +} + export const GET = Checkout({ - accessToken: import.meta.env.POLAR_ACCESS_TOKEN ?? '', + accessToken, successUrl: 'https://docs.shepherdjs.dev' });landing/src/pages/pricing.astro (2)
366-366: Usebtninstead of re-readingevent.target.
btnwas already assigned fromevent.targetat line 352 after theinstanceofguard. Usingbtn.dataset.pricingIdis cleaner and avoids the unnecessary optional chaining.Proposed fix
- const productId = event.target?.dataset.pricingId; + const productId = btn.dataset.pricingId;
56-56: Product IDs are hardcoded in the template.These UUIDs will need to change per environment (staging vs. production). Consider sourcing them from environment variables or a config to avoid code changes when IDs rotate.
Also applies to: 143-143
| "@astrojs/mdx": "^4.3.13", | ||
| "@astrojs/vercel": "^9.0.2", | ||
| "@polar-sh/sdk": "^0.20.2", | ||
| "@polar-sh/astro": "^0.7.3", |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
@polar-sh/astro npm package version 0.7.3
💡 Result:
@polar-sh/astro does not have an npm release 0.7.3. The npm package page shows @polar-sh/astro at 0.4.6 (latest) and indicates its published versions are in the 0.4.x line, not 0.7.x. [1]
If you were trying to install a Polar adapter at 0.7.3, that version does exist for @polar-sh/sveltekit (Polar’s SvelteKit adapter), which is listed as 0.7.3. [2]
Polar’s Astro adapter docs show the package name to install is @polar-sh/astro. [3]
Sources: [1] [2] [3]
🏁 Script executed:
# Check if checkout.ts file exists and examine Checkout usage
find . -name "checkout.ts" -path "*/landing/src/pages/api/*" -type fRepository: shipshapecode/shepherd
Length of output: 101
🏁 Script executed:
# Look at the package.json structure to understand context
cat -n landing/package.json | head -30Repository: shipshapecode/shepherd
Length of output: 1011
🏁 Script executed:
# Examine the checkout.ts file to see what is imported
cat -n landing/src/pages/api/checkout.tsRepository: shipshapecode/shepherd
Length of output: 334
Update @polar-sh/astro to a valid version.
@polar-sh/astro v0.7.3 does not exist on npm. The latest available version is 0.4.6. Update the dependency to a valid version (e.g., "^0.4.6"), otherwise npm install will fail and Checkout import in landing/src/pages/api/checkout.ts will not resolve.
🤖 Prompt for AI Agents
In `@landing/package.json` at line 16, package.json lists a non-existent
"@polar-sh/astro" version "0.7.3" which breaks npm install and the Checkout
import in landing/src/pages/api/checkout.ts; update the dependency entry for
"@polar-sh/astro" to a valid published version such as "^0.4.6" (or the latest
available) so the package resolves correctly and the Checkout import can be
found during build.

Summary by CodeRabbit
Refactor
Chores