Skip to content

A Next.js app that sends Lemon Squeezy webhook events to LogSnag.

License

Notifications You must be signed in to change notification settings

lmsqueezy/logsnag-nextjs

Repository files navigation

Lemon Squeezy x LogSnag

A Next.js app that sends webhook events to LogSnag.

LogSnag is a logging and event tool, letting you keep track of events, insights and analytics from all of your apps in a dedicated space.

Read our tutorial to learn how the code works.

Get set up

  1. Create a Lemon Squeezy store.
  2. Sign up to LogSnag.
  3. Create an API token.
  4. Deploy this app (see below) and add environment variables from Lemon Squeezy and LogSnag.
  5. Create a webhook in Lemon Squeezy, selecting the events you want to track in LogSnag. The webhook endpoint is at /webhook.

Now any events you selected in step 2 will appear in LogSnag as soon as they occur.

Note: The catch-all subscription_updated event is not implemented to avoid receiving duplicate events. Don't select it when creating a webhook in Lemon Squeezy.

Helpful links

Deploy to Vercel

Deploy with Vercel

Environment variables

As part of the deployment you need to set

  • LEMONSQUEEZY_WEBHOOK_SECRET - The signing secret you added in the webhook creation form. (Go to Lemon Squeezy webhook settings)
  • LOGSNAG_TOKEN - API token from LogSnag (Go to LogSnag API settings)
  • LOGSNAG_PROJECT - Name of the project in LogSnag that you want events sent to.
  • LOGSNAG_CHANNEL - Name of the channel in your LogSnag project that you want events sent to.

Test the integration

If you want to test this app, switch your Lemon Squeezy to "test mode" then create a product or two and set up webhooks pointing to this app's /webhook endpoint.

Make a test channel in LogSnag where you can send events during testing (you can delete this channel when you're done) and use this as your LOGSNAG_CHANNEL enviroinment variable.

Now make purchases with your test mode products. You can use test cards to mimic real purchases.

Webhook events will be sent for all test mode purchases, just as they will for live purchases.

About

A Next.js app that sends Lemon Squeezy webhook events to LogSnag.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published