@neptune.digital/sentry-netlify-v2
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

netlify-sentry-v2

npm package

Installation

  1. Either: a) Set the SENTRY_DSN environment variable in your site configuration, or b) Enable the Netlify Sentry Integration, and make sure your DSN is set in the UI. (This does the same thing.)

  2. npm i @neptune.digital/netlify-sentry-v2

  3. Use it in your functions as shown below.

Usage

At the top of your Netlify Functions file:

import { withSentry } from "@neptune.digital/netlify-sentry-v2";
import type { Context } from "@netlify/functions";

export default withSentry(async (req: Request, context: Context) => {
    // blah blah function goes here
    return new Response("wow", {status: 200});
});

Background Functions

There's also a withSentryAsBackgroundTask:

import { withSentryAsBackgroundTask } from "@neptune.digital/netlify-sentry-v2";
import type { Config, Context } from "@netlify/functions";

export default withSentryAsBackgroundTask(
    "your-sentry-cron-slug",
    async (req: Request, context: Context) => {
        return new Response("wow, at some scheduled time", {status: 200});
});


export const config: Config = {
  schedule: "*/5 * * * *", // cron format. every 5 minutes
};

Note that this doesn't change anything about the function, so you can use it on any function that you want to do a cron check-in call to Sentry.

Package Sidebar

Install

npm i @neptune.digital/sentry-netlify-v2

Weekly Downloads

1

Version

1.1.1

License

AGPL-3.0-only

Unpacked Size

92.1 kB

Total Files

9

Last publish

Collaborators

  • mgillis