# How to you integrate Sentry with Netlify Functions?

**URL:** <https://answers.netlify.com/t/how-to-you-integrate-sentry-with-netlify-functions/43500>\
**Category:** Support\
**Tags:** lambda-functions, events, deployment\
**Created:** [September 2, 2021, 6:59am UTC](https://answers.netlify.com/t/how-to-you-integrate-sentry-with-netlify-functions/43500 "2021-09-02T06:59:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![proton](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@proton](https://answers.netlify.com/u/proton)\
**Post date:** [September 2, 2021, 6:59am UTC](https://answers.netlify.com/t/how-to-you-integrate-sentry-with-netlify-functions/43500/1 "2021-09-02T06:59:44Z")

</div>

Hey there,

I’ve got a Gatsby + Netlify site and would like to integrate Sentry to monitor lambda functions. I’m a little confused because I’ve seen a tutorial here and there where they use `@sentry/node`, but there’s also `@sentry/serverless` for AWS Lambda functions.

I know Netlify uses AWS under the hood for functions, so my assumption was to follow Sentry’s AWS Lambda integration docs.

However, when I follow their guide, no errors are being reported. I’m basically doing this

```auto
const Sentry = require("@sentry/serverless");

const {
  SENTRY_DSN
} = require('./config')

Sentry.AWSLambda.init({
  dsn: SENTRY_DSN,
  tracesSampleRate: 1.0,
});

exports.handler = Sentry.AWSLambda.wrapHandler(async (event, context) => {
  // ... some code here
  let someVariable
  try {
      someVariable = await someFetchRequest()

      throw new Error('this is a Sentry test error')
    } catch (err) {
      return statusReturn(500, { error: err.message })
    }
});

```

Yet, no issues are coming in. The docs say that this is all you need to start capturing error events within the handler.

Am I taking the wrong approach?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [September 2, 2021, 7:37am UTC](https://answers.netlify.com/t/how-to-you-integrate-sentry-with-netlify-functions/43500/2 "2021-09-02T07:37:52Z")

</div>

I haven’t used Sentry myself, though this issue here: [Sentry.AWSLambda.init doesn't work with Netlify dev · Issue #3000 · getsentry/sentry-javascript · GitHub](https://github.com/getsentry/sentry-javascript/issues/3000#issue-728927605) confirms that it should work fine.

Quoted:

> It works great when deployed to Netlify, …

> On a side note, the `Sentry.AWSLambda.wrapHandler` works fine with Netlify dev.

So it appears your approach is correct, but then I can’t say why it won’t work.

---

<div class="post-metadata">

**Author:** ![proton](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@proton](https://answers.netlify.com/u/proton)\
**Post date:** [September 13, 2021, 10:51am UTC](https://answers.netlify.com/t/how-to-you-integrate-sentry-with-netlify-functions/43500/3 "2021-09-13T10:51:06Z")

</div>

Thx @hrishikesh, I finally realized that it only automatically picks up errors that halt the execution of the handler.

I had some try/catch blocks inside that didn’t necessarily stop the execution of the entire function, so when I started using `Sentry.captureException(error)` errors got picked up.

---

<div class="post-metadata">

**Author:** ![hillary](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hillary/32/21132_2.png) [@hillary](https://answers.netlify.com/u/hillary)\
**Post date:** [September 13, 2021, 3:23pm UTC](https://answers.netlify.com/t/how-to-you-integrate-sentry-with-netlify-functions/43500/4 "2021-09-13T15:23:10Z")

</div>

Thanks for coming back and letting us know what you found, @proton! We appreciate it :netlisparkles:
