diff --git a/__tests__/__snapshots__/documentation.js.snap b/__tests__/__snapshots__/documentation.js.snap index 316982c25c22d..5295227196047 100644 --- a/__tests__/__snapshots__/documentation.js.snap +++ b/__tests__/__snapshots__/documentation.js.snap @@ -332,6 +332,7 @@ Array [ "platforms/node/index.html", "platforms/node/koa/index.html", "platforms/node/pluggable-integrations/index.html", + "platforms/node/serverless/index.html", "platforms/node/sourcemaps/index.html", "platforms/node/typescript/index.html", "platforms/php/default-integrations/index.html", diff --git a/src/collections/_documentation/platforms/node/serverless.md b/src/collections/_documentation/platforms/node/serverless.md new file mode 100644 index 0000000000000..694bccbba4c12 --- /dev/null +++ b/src/collections/_documentation/platforms/node/serverless.md @@ -0,0 +1,34 @@ +--- +title: Serverless +sidebar_order: 7 +--- + +## AWS Lambda + +To set up Sentry error logging for a Lambda function, build a wrapper. + +```javascript +"use strict"; + +const Sentry = require("@sentry/node"); + +Sentry.init({ + dsn: "YOUR DSN" +}); + +function sentryHandler(lambdaHandler) { + return async event => { + try { + return await lambdaHandler(event); + } catch (error) { + Sentry.captureException(error); + await Sentry.flush(2000); + return error; + } + }; +} + +module.exports.hello = sentryHandler(async event => { + throw new Error("asd"); +}); +```