Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion landing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/mdx": "^4.3.13",
"@astrojs/vercel": "^9.0.2",
"@polar-sh/sdk": "^0.20.2",
"@polar-sh/astro": "^0.7.3",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 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 f

Repository: shipshapecode/shepherd

Length of output: 101


🏁 Script executed:

# Look at the package.json structure to understand context
cat -n landing/package.json | head -30

Repository: 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.ts

Repository: 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.

"astro": "^5.17.1",
"shepherd.js": "workspace:*"
},
Expand Down
35 changes: 0 additions & 35 deletions landing/src/actions/index.ts

This file was deleted.

8 changes: 8 additions & 0 deletions landing/src/pages/api/checkout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Checkout } from '@polar-sh/astro';

export const prerender = false;

export const GET = Checkout({
accessToken: import.meta.env.POLAR_ACCESS_TOKEN ?? '',
successUrl: 'https://docs.shepherdjs.dev'
});
70 changes: 44 additions & 26 deletions landing/src/pages/pricing.astro
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';
<button
class="button bg-white border-2 border-navy p-6 text-navy whitespace-nowrap w-full"
aria-describedby="purchase business license"
data-pricing-id="4d72f490-47e5-4b83-b6e7-5fde0d0ee009"
data-pricing-id="5dea1175-6e19-4613-bf7a-a0ae4354ccf9"
type="button"
>
Purchase
Expand Down Expand Up @@ -140,7 +140,7 @@ import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';
<button
class="button bg-white border-2 border-navy p-6 text-navy whitespace-nowrap w-full"
aria-describedby="purchase enterprise license"
data-pricing-id="c27eb1ec-bc59-446e-8aab-6adf920f9962"
data-pricing-id="713b19cd-7fbf-41fb-9bf7-b5c25c318406"
type="button"
>
Purchase
Expand Down Expand Up @@ -339,18 +339,50 @@ import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';
</html>

<script>
import { actions } from 'astro:actions';
import { navigate } from 'astro:transitions/client';
document.addEventListener('astro:page-load', () => {
const buttons = document.querySelectorAll('[data-pricing-id]');

// Store original button texts
const buttonStates = new Map();
buttons.forEach((button) => {
if (button instanceof HTMLButtonElement) {
buttonStates.set(button, button.innerHTML);
}
});

// Reset button states when user navigates back
const resetButtons = () => {
buttons.forEach((button) => {
if (button instanceof HTMLButtonElement) {
const originalText = buttonStates.get(button);
if (originalText) {
button.disabled = false;
button.innerHTML = originalText;
}
}
});
};

// Listen for page visibility changes (when user comes back from checkout)
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') {
resetButtons();
}
});

// Also reset on page show event (handles browser back button)
window.addEventListener('pageshow', (event) => {
// Reset buttons if coming back via browser navigation
resetButtons();
});

buttons.forEach((button) => {
button.addEventListener('click', async (event) => {
if (!(event.target instanceof HTMLButtonElement)) {
return;
}
const btn = event.target;
const originalText = btn.innerHTML;
const originalText = buttonStates.get(btn);
btn.disabled = true;
btn.innerHTML = `
<span class="inline-flex items-center">
Expand All @@ -363,31 +395,17 @@ import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';
</span>
`;

const productPriceId = event.target?.dataset.pricingId;
const productId = event.target?.dataset.pricingId;

if (!productPriceId) {
console.warn('No pricing ID found for this button');
if (!productId) {
console.warn('No product ID found for this button');
btn.disabled = false;
btn.innerHTML = originalText || '';
return;
}

try {
const { data, error } = await actions.checkout({
productPriceId
});

console.log('Checkout result:', data, error, productPriceId);

if (!error) {
navigate(data);
} else {
console.error('Checkout error:', error);
}
} catch (error) {
console.error('An error occurred during checkout:', error);
} finally {
btn.disabled = false;
btn.innerHTML = originalText;
}
// Use full-page navigation to follow server-side redirect to external Polar checkout
window.location.href = `/api/checkout?products=${productId}`;
});
});
});
Expand Down
31 changes: 24 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.