-
Notifications
You must be signed in to change notification settings - Fork 10
fix: add optional metadata prop for checkout link #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe changes add an optional Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this 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 (1)
README.md (1)
422-422: Consider adding a usage example for the metadata prop.The documentation accurately describes the
metadataprop, but an example would help users understand how to use it. The PR description includes an example withorganizationIdandplanTypethat could be incorporated here.Consider adding an example like:
-- `metadata`: (Optional) Metadata for additional information to the checkout +- `metadata`: (Optional) Metadata for additional information to the checkout. + Example: `metadata={{ organizationId: "org_123", planType: "enterprise" }}`
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
README.md(1 hunks)src/client/index.ts(4 hunks)src/react/index.tsx(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/react/index.tsx (1)
src/client/index.ts (1)
PolarComponentApi(48-50)
🔇 Additional comments (3)
src/client/index.ts (2)
309-333: LGTM!The metadata parameter is correctly threaded through the
generateCheckoutLinkaction tocreateCheckoutSession. The typing and schema validation are consistent with the method signature.
99-161: Verify metadata parameter support in Polar SDK's checkoutsCreate function.The code passes a
metadataparameter tocheckoutsCreatefrom@polar-sh/sdk(v0.41.5), but the available SDK documentation does not explicitly showmetadataas a supported field in the CheckoutCreate request object. WhilecustomersCreatesupports metadata, verify thatcheckoutsCreatealso accepts this parameter to ensure compatibility with the current SDK version.src/react/index.tsx (1)
37-81: LGTM!The
metadataprop is correctly integrated into theCheckoutLinkcomponent:
- Properly typed as optional
Record<string, string>- Forwarded to
generateCheckoutLink- Included in the
useEffectdependency array to trigger re-fetch when metadata changes
|
A more detailed example of what it can be used for // convex/http.ts
import { httpRouter } from "convex/server";
import { polar } from "./example";
const http = httpRouter();
polar.registerRoutes(http, {
path: "/polar/events",
onSubscriptionCreated: async (ctx, event) => {
const metadata = event.data.metadata;
if (metadata?.organizationId) {
console.log("New subscription for org:", metadata.organizationId);
}
},
onSubscriptionUpdated: async (ctx, event) => {
const metadata = event.data.metadata;
if (metadata?.organizationId) {
console.log("Updated subscription for org:", metadata.organizationId);
}
},
});
export default http; |
Adds an optional
metadataprop to the Checkout link.This improves flexibility and is especially useful for large and complex projects.