Skip to content

Commit 312534d

Browse files
committed
more
1 parent 9a516b2 commit 312534d

File tree

1 file changed

+10
-4
lines changed
  • docs/platforms/javascript/guides/aws-lambda/install

1 file changed

+10
-4
lines changed

docs/platforms/javascript/guides/aws-lambda/install/npm.mdx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ To set environment variables, navigate to your Lambda function, select **Configu
104104

105105
![](./img/env_vars.png)
106106

107-
**For ESM functions only:** You'll also need to manually wrap your handler as shown below:
107+
<Alert level="info" title="For ESM Lambda Functions">
108+
109+
You'll also need to manually wrap your handler as shown below:
108110

109111
```javascript {tabTitle:ESM} {filename:index.mjs}{1,3}
110112
import * as Sentry from "@sentry/aws-serverless";
@@ -114,13 +116,15 @@ export const handler = Sentry.wrapHandler(async (event, context) => {
114116
});
115117
```
116118

119+
</Alert>
120+
117121
That's it - make sure to re-deploy your function and you're all set!
118122

119123
### Option B: Manual Setup
120124

121125
To further customize the SDK setup, you can also manually initialize the SDK in your lambda function. The benefit of this installation method is that you can fully customize your Sentry SDK setup in a `Sentry.init` call.
122126

123-
#### For CommonJS Functions
127+
#### For CommonJS Lambda Functions
124128

125129
You can initialize the SDK directly in your main handler file:
126130

@@ -155,14 +159,16 @@ Sentry.init({
155159
// ___PRODUCT_OPTION_END___ profiling
156160
});
157161

162+
// Your package imports
163+
158164
exports.handler = Sentry.wrapHandler(async (event, context) => {
159165
// Your handler code
160166
});
161167
```
162168

163-
It's important to add both, the `Sentry.init` call outside the handler function and the `Sentry.wrapHandler` wrapper around your function to automatically catch errors and performance data.
169+
It's important to add both, the `Sentry.init` call outside the handler function and the `Sentry.wrapHandler` wrapper around your function to automatically catch errors and performance data. Make sure that the `Sentry.init` call and the import statement are at the very top of your file before any other imports.
164170

165-
#### For ESM Functions
171+
#### For ESM Lambda Functions
166172

167173
First, wrap your handler:
168174

0 commit comments

Comments
 (0)