feat: dont set default plan for new user#300
Conversation
WalkthroughThe changes in this pull request primarily focus on the Changes
Possibly related PRs
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (3)
src/app/api/clerk/webhooks/route.ts (3)
Line range hint
20-26: Enhance error messaging for missing headersConsider providing more specific error messages to identify which header is missing. This will help with debugging webhook issues.
- if (!svix_id || !svix_timestamp || !svix_signature) { - return new Response('An error occurred while getting svix headers', { - status: 400 - }) - } + const missingHeaders = []; + if (!svix_id) missingHeaders.push('svix-id'); + if (!svix_timestamp) missingHeaders.push('svix-timestamp'); + if (!svix_signature) missingHeaders.push('svix-signature'); + + if (missingHeaders.length > 0) { + return new Response(`Missing required Svix headers: ${missingHeaders.join(', ')}`, { + status: 400 + }) + }
Line range hint
31-42: Add type safety for webhook payloadConsider adding type validation for the webhook payload to ensure type safety at runtime.
+ interface WebhookPayload { + type: string; + data: { + id: string; + user_id?: string; + }; + } + const payload = await req.json() + if (!payload || typeof payload !== 'object' || !('type' in payload)) { + return new Response('Invalid webhook payload structure', { status: 400 }) + } const body = JSON.stringify(payload)
Line range hint
43-77: Refactor duplicate activity creation logicThe activity creation logic is duplicated across all event handlers. Consider extracting this into a reusable function.
+ const createActivity = async (type: string, description: string, userId: string, userAgent: string | null) => { + try { + await pocketbase.collection('activities').create({ + type, + description, + user_id: userId, + device: getDeviceType(userAgent || '') + }) + } catch (error) { + console.error(`Failed to create activity for ${type}:`, error) + throw error + } + } + if (evt.type === 'user.created') { - const activity = { - type: 'account_created', - description: 'User account created', - user_id: evt.data.id, - device: getDeviceType(req.headers.get('user-agent') || '') - } - await pocketbase.collection('activities').create(activity) + await createActivity( + 'account_created', + 'User account created', + evt.data.id, + req.headers.get('user-agent') + ) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
src/app/api/clerk/webhooks/route.ts(1 hunks)
🔇 Additional comments (1)
src/app/api/clerk/webhooks/route.ts (1)
Line range hint 43-77: Verify the impact of removing subscription creation
The AI summary indicates that subscription creation logic was removed. Let's verify if this change aligns with the business requirements and doesn't break existing functionality.
This is an automated pull request for branch develop
Summary by CodeRabbit
New Features
Bug Fixes