Skip to content

Updated guides intro and side menu #1398

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

Merged
merged 5 commits into from
Oct 10, 2024
Merged

Updated guides intro and side menu #1398

merged 5 commits into from
Oct 10, 2024

Conversation

D-K-P
Copy link
Member

@D-K-P D-K-P commented Oct 10, 2024

Summary by CodeRabbit

  • New Features

    • Added comprehensive documentation for setting up Stripe webhooks, including environment variable requirements and code examples.
    • Introduced new sections in the Next.js and Remix guides linking to webhook resources.
    • Updated the overview guide to include new entries for using webhooks in various frameworks.
    • Added new cards in the webhooks overview for Stripe and Supabase webhook guides.
  • Bug Fixes

    • Improved formatting and structural consistency across various documentation files.
  • Documentation

    • Enhanced guides with additional resources and clarified instructions for users.
    • Removed a note encouraging users to request guides for their frameworks.

Copy link

changeset-bot bot commented Oct 10, 2024

⚠️ No Changeset found

Latest commit: b4b0651

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Oct 10, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request includes several updates to the documentation related to webhook handling in various frameworks such as Next.js and Remix. Key changes involve the addition of new sections and resources for Stripe and Supabase webhooks, structural adjustments for consistency, and enhancements to existing guides. Notably, the document on Stripe webhooks has been expanded to provide detailed instructions on setting up webhook handlers, while related guides have been updated to link to these new resources.

Changes

File Path Change Summary
docs/guides/examples/stripe-webhook.mdx Updated sidebar title, added detailed instructions for setting up a Stripe webhook handler, specified required environment variables, provided code examples, and included testing instructions with Stripe CLI.
docs/guides/frameworks/nextjs.mdx Added a new section for "Additional resources for Next.js," made minor formatting changes, and retained focus on setting up Trigger.dev in Next.js projects.
docs/guides/frameworks/remix.mdx Reformatted import statements, updated <Steps> component, clarified loader function implementation, and added a new section for "Additional resources for Remix."
docs/guides/frameworks/webhooks-guides-overview.mdx Added new cards for "Stripe webhooks" and "Supabase database webhooks guide," and removed a note about requesting guides for frameworks.
docs/guides/introduction.mdx Updated entries for "Using webhooks in Next.js," "Using webhooks in Remix," and "Stripe webhooks," rephrased descriptions, removed "Stripe webhook" from example tasks, and added a note for requesting guides via Discord.
docs/mint.json Added a new page entry for "guides/examples/stripe-webhook" in the "Webhooks" group and removed it from the "Example tasks" group, indicating a content reorganization.

Possibly related PRs

  • Supabase Storage and Stripe webhook examples #1345: This PR adds a "Stripe webhook" example that demonstrates how to trigger a task based on events from Stripe webhooks, which is directly related to the main PR's updates on Stripe webhook documentation.
  • Supabase database webhook example upgrade #1386: This PR upgrades the Supabase database webhook example, which aligns with the main PR's focus on webhook handling and task triggering, enhancing the overall documentation on webhooks.
  • Webhook guides #1396: This PR introduces comprehensive guides on setting up webhooks with Trigger.dev, which is closely related to the main PR's updates regarding webhook documentation and examples.

Suggested reviewers

  • matt-aitken
  • samejr

🐇 In the land of code where we hop and play,
New guides for webhooks brighten our day!
With Stripe and Supabase, we weave a fine tale,
Triggering tasks, we shall not fail!
So gather 'round, dear friends, and cheer,
For documentation's magic is finally here! 🌟


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Outside diff range and nitpick comments (14)
docs/guides/frameworks/webhooks-guides-overview.mdx (3)

34-40: Excellent addition of the Supabase database webhooks guide!

The new card for the Supabase database webhooks guide is a great addition to the documentation. It provides clear information about the guide's content and is consistent with the overall structure.

For better consistency with the other cards, consider adjusting the formatting slightly:

  <Card
    title="Supabase database webhooks guide"
    icon="webhook"
-   href="/guides/frameworks/supabase-edge-functions-database-webhooks"
-  >
-    Learn how to trigger a task from a Supabase edge function when an event occurs in your database.
-  </Card>
+   href="/guides/frameworks/supabase-edge-functions-database-webhooks">
+   Learn how to trigger a task from a Supabase edge function when an event occurs in your database.
+  </Card>

This change will make the Supabase card formatting consistent with the Stripe card above it.


40-40: Consider keeping a channel open for user feedback

The AI summary mentions that a note encouraging users to request guides has been removed. While the current set of guides may be comprehensive, it's often beneficial to maintain an open channel for user feedback and requests.

Consider adding a more general invitation for feedback at the end of the document, such as:

We're always looking to improve our documentation. If you have any suggestions or requests for additional guides, please let us know in our [Discord server](https://trigger.dev/discord).

This keeps the door open for user input without specifically focusing on requesting new framework guides.


Line range hint 1-40: Overall, excellent updates to the webhook guides overview!

The changes in this file significantly improve the documentation by adding new guides for Stripe and Supabase webhooks. These additions align well with the PR objectives and provide users with more comprehensive coverage of webhook-related topics.

The structure remains clear and consistent, making it easy for users to navigate and find relevant information. The new cards fit seamlessly into the existing layout.

As the number of guides grows, consider organizing them into categories (e.g., "Payment Integrations", "Database Integrations") if more are added in the future. This will help maintain the document's readability and ease of navigation as it expands.

docs/guides/introduction.mdx (2)

27-35: Excellent additions and formatting improvements!

The new entries for webhook handling in Next.js, Remix, and Stripe are valuable additions to the documentation. The table formatting changes improve readability and align with common Markdown practices.

Consider standardizing the descriptions to start with "How to" for consistency:

-| [Using webhooks in Next.js](/guides/frameworks/nextjs-webhooks)                            | Trigger tasks from a webhook in Next.js           |
-| [Using webhooks in Remix](/guides/frameworks/remix-webhooks)                               | Trigger tasks from a webhook in Remix             |
-| [Stripe webhooks](/guides/examples/stripe-webhook)                                         | Trigger tasks from incoming Stripe webhook events |
+| [Using webhooks in Next.js](/guides/frameworks/nextjs-webhooks)                            | How to trigger tasks from a webhook in Next.js    |
+| [Using webhooks in Remix](/guides/frameworks/remix-webhooks)                               | How to trigger tasks from a webhook in Remix      |
+| [Stripe webhooks](/guides/examples/stripe-webhook)                                         | How to trigger tasks from Stripe webhook events   |
🧰 Tools
🪛 LanguageTool

[uncategorized] ~33-~33: ‘In’ is unnecessary in most cases before the expression ‘next .’.
Context: ... | Trigger tasks from a webhook in Next.js | | [Using webhooks in Rem...

(CONFUSION_OF_NN_IN_NEXT_NNP)


Line range hint 37-54: Great updates to the Example tasks section!

The changes improve the overall consistency and value of the documentation. The addition of the Supabase database operations example is a valuable inclusion, and the refinements to the descriptions enhance clarity.

For consistency, consider adjusting the description of the Supabase database operations entry to match the style of other entries:

-| [Supabase database operations](/guides/examples/supabase-database-operations) | Run basic CRUD operations on a table in a Supabase database using Trigger.dev. |
+| [Supabase database operations](/guides/examples/supabase-database-operations) | How to run basic CRUD operations on a Supabase database table using Trigger.dev. |
docs/guides/examples/stripe-webhook.mdx (3)

Line range hint 7-11: Consider adding a note about securing the webhook endpoint

In the Overview or Key features section, it would be beneficial to mention the importance of securing the webhook endpoint. This could include a brief note about using HTTPS and validating the Stripe signature to ensure the integrity and authenticity of incoming webhook events.


Line range hint 30-95: Recommend including information about error handling

In the webhook handler examples for both Next.js and Remix, consider adding more robust error handling. This could include try-catch blocks around the signature verification and task triggering processes, with appropriate error responses. This would make the examples more production-ready and help users handle potential issues.

Here's an example of how you could enhance the error handling in the Next.js example:

 export async function POST(request: Request) {
   const signature = request.headers.get("stripe-signature");
   const payload = await request.text();

   if (!signature || !payload) {
     return NextResponse.json(
       { error: "Invalid Stripe payload/signature" },
       {
         status: 400,
       }
     );
   }

+  try {
     const event = Stripe.webhooks.constructEvent(
       payload,
       signature,
       process.env.STRIPE_WEBHOOK_SECRET as string
     );

     // Perform the check based on the event type
     switch (event.type) {
       case "checkout.session.completed": {
         // Trigger the task only if the event type is "checkout.session.completed"
         const { id } = await tasks.trigger<typeof stripeCheckoutCompleted>(
           "stripe-checkout-completed",
           event.data.object
         );
         return NextResponse.json({ runId: id });
       }
       default: {
         // Return a response indicating that the event is not handled
         return NextResponse.json(
           { message: "Event not handled" },
           {
             status: 200,
           }
         );
       }
     }
+  } catch (err) {
+    console.error('Error processing webhook:', err);
+    return NextResponse.json(
+      { error: "Webhook error" },
+      {
+        status: 400,
+      }
+    );
+  }
 }

Line range hint 121-121: Suggest adding a section on deploying the webhook handler

The document provides excellent information on setting up and testing the webhook handler locally. However, it would be beneficial to include a section on deploying the webhook handler to a production environment. This could cover topics such as:

  1. Configuring environment variables in production
  2. Ensuring HTTPS is used for the webhook endpoint
  3. Updating the webhook URL in the Stripe dashboard
  4. Best practices for monitoring and logging webhook events in production

Adding this information would provide a more complete guide for users implementing Stripe webhooks with Trigger.dev.

docs/guides/frameworks/remix.mdx (4)

49-60: LGTM: Code snippet formatting improved

The code snippet has been reformatted for better readability, and the loader function implementation has been adjusted to be more concise without changing its functionality. These changes improve the overall quality of the documentation.

Consider adding a comment explaining the purpose of the loader function for readers who might be less familiar with Remix conventions.


81-82: Excellent addition: Note on type-only import for edge runtime

The new note about using a type-only import for edge runtime compatibility is a valuable addition. It helps prevent potential runtime errors and provides important guidance for users deploying to Vercel Edge Functions.

Consider adding a brief explanation of why type-only imports are necessary for edge runtime compatibility. This could help users better understand the reasoning behind this requirement.


Line range hint 95-109: LGTM: Code updated for edge runtime compatibility

The code snippet has been successfully updated to use the edge runtime, and the action function has been reformatted and adjusted for better readability and conciseness. These changes are crucial for ensuring compatibility with Vercel Edge Functions.

Consider adding a brief comment explaining the purpose of the action function and how it differs from the previous loader function. This could help readers understand the transition from the standard Remix setup to the edge runtime setup.


200-208: Great addition: Additional resources section

The new "Additional resources for Remix" section with a card linking to a guide on triggering tasks using webhooks is a valuable enhancement to the documentation. It provides users with easy access to related information and improves the overall usefulness of the guide.

Consider adding a brief introductory sentence before the card to provide context for the additional resources. For example: "To further expand your knowledge of using Trigger.dev with Remix, check out the following guide:"

docs/guides/frameworks/nextjs.mdx (1)

257-266: Great addition of resources, consider expanding.

The new "Additional resources for Next.js" section is a valuable addition to the guide. It provides users with relevant information on webhook handling, which aligns well with the overall content.

Suggestion: Consider adding more resources to this section in the future, such as links to official Next.js documentation or other related Trigger.dev guides, to make it even more comprehensive.

docs/mint.json (1)

296-297: LGTM! Consider adding an overview page for consistency.

The addition of the Stripe webhook guide to the "Webhooks" group improves the organization of the documentation. This change makes it easier for users to find webhook-related content.

For consistency with other sections, consider adding an overview page for webhooks. You could create a new page like "guides/frameworks/webhooks-overview" and add it as the first item in the "Webhooks" group.

 {
   "group": "Webhooks",
   "icon": "webhook",
   "iconType": "solid",
   "pages": [
+    "guides/frameworks/webhooks-overview",
     "guides/frameworks/nextjs-webhooks",
     "guides/frameworks/remix-webhooks",
     "guides/examples/stripe-webhook"
   ]
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a6dbf84 and 4677adc.

📒 Files selected for processing (6)
  • docs/guides/examples/stripe-webhook.mdx (1 hunks)
  • docs/guides/frameworks/nextjs.mdx (1 hunks)
  • docs/guides/frameworks/remix.mdx (7 hunks)
  • docs/guides/frameworks/webhooks-guides-overview.mdx (1 hunks)
  • docs/guides/introduction.mdx (2 hunks)
  • docs/mint.json (1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/guides/introduction.mdx

[uncategorized] ~33-~33: ‘In’ is unnecessary in most cases before the expression ‘next .’.
Context: ... | Trigger tasks from a webhook in Next.js | | [Using webhooks in Rem...

(CONFUSION_OF_NN_IN_NEXT_NNP)

🔇 Additional comments (7)
docs/guides/frameworks/webhooks-guides-overview.mdx (1)

30-33: Great addition of the Stripe webhooks guide!

The new card for Stripe webhooks is a valuable addition to the documentation. It's consistent with the existing structure and provides clear information about the guide's content.

docs/guides/introduction.mdx (1)

56-59: Excellent addition of the community engagement note!

The new note at the end of the document is a great way to encourage user feedback and participation. It helps the Trigger.dev team understand user needs and prioritize future documentation efforts.

docs/guides/examples/stripe-webhook.mdx (1)

3-3: Approved: Improved sidebar title accuracy

The change from "Stripe webhook" to "Stripe webhooks" in the sidebarTitle is appropriate. It better reflects the content of the document, which covers handling multiple types of Stripe webhook events.

docs/guides/frameworks/remix.mdx (3)

8-13: LGTM: Import statements reformatted for consistency

The import statements have been updated to use double quotes, which is consistent with common JavaScript/TypeScript style guides. The slight reordering of imports improves readability without affecting functionality.


23-26: LGTM: Steps component formatting improved

The Steps component has been reformatted with proper indentation, which enhances readability and aligns with best practices for JSX/MDX syntax.


171-174: Excellent addition: Reminder to deploy Trigger.dev task

The new note reminding users to deploy their Trigger.dev task is a valuable addition to the documentation. It ensures that users complete all necessary steps for a successful integration, and the included link provides easy access to the relevant instructions.

docs/guides/frameworks/nextjs.mdx (1)

Line range hint 1-246: LGTM: Existing content and component updates.

The existing content of the guide is well-structured and informative. The updates to the <AddEnvironmentVariables /> and <DeployingYourTask /> components are appropriate and maintain consistency with the rest of the document.

Also applies to: 247-247, 249-249

@D-K-P D-K-P merged commit 25c7ff1 into main Oct 10, 2024
2 of 3 checks passed
@D-K-P D-K-P deleted the docs/guides-side-menu-update branch October 10, 2024 11:55
@coderabbitai coderabbitai bot mentioned this pull request Oct 11, 2024
This was referenced Oct 23, 2024
@coderabbitai coderabbitai bot mentioned this pull request Dec 13, 2024
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