Skip to content

Commit dcb6c24

Browse files
authored
feat(v8): Add @sentry/aws-serverless package (#11052)
This change renames the `@sentry/serverless` SDK to be `@sentry/aws-serverless` and removes all GCP related code. It also adds a migration note detailing the changes we made. It also updates the package to only emit CJS, because it relies on monkeypatching via `require` calls. We can add back ESM at a later point, will create follow up issue for it. This PR does not touch any of the lambda layer code, I will come back and refactor it afterwards (too scary to think about right now) We will rename the `@sentry/google-cloud` package to `@sentry/google-cloud-serverless` in a follow up PR
1 parent 963c3de commit dcb6c24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+220
-1706
lines changed

.craft.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ targets:
8989

9090
## 5. Node-based Packages
9191
- name: npm
92-
id: '@sentry/serverless'
93-
includeNames: /^sentry-serverless-\d.*\.tgz$/
92+
id: '@sentry/aws-serverless'
93+
includeNames: /^sentry-aws-serverless-\d.*\.tgz$/
9494
- name: npm
9595
id: '@sentry/google-cloud'
9696
includeNames: /^sentry-google-cloud-\d.*\.tgz$/

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ body:
3434
- '@sentry/astro'
3535
- '@sentry/angular'
3636
- '@sentry/angular-ivy'
37+
- '@sentry/aws-serverless'
3738
- '@sentry/bun'
3839
- '@sentry/deno'
3940
- '@sentry/ember'
@@ -42,7 +43,6 @@ body:
4243
- '@sentry/node'
4344
- '@sentry/react'
4445
- '@sentry/remix'
45-
- '@sentry/serverless'
4646
- '@sentry/google-cloud'
4747
- '@sentry/svelte'
4848
- '@sentry/sveltekit'

MIGRATION.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ We've removed the following packages:
4848
- [@sentry/hub](./MIGRATION.md#sentryhub)
4949
- [@sentry/tracing](./MIGRATION.md#sentrytracing)
5050
- [@sentry/integrations](./MIGRATION.md#sentryintegrations)
51+
- [@sentry/serverless](./MIGRATION.md#sentryserverless)
5152

5253
#### @sentry/hub
5354

@@ -167,6 +168,55 @@ Integrations that are now exported from `@sentry/node` and `@sentry/browser` (or
167168

168169
The `Transaction` integration has been removed from `@sentry/integrations`. There is no replacement API.
169170

171+
#### @sentry/serverless
172+
173+
`@sentry/serverless` has been removed and will no longer be published. The serverless package has been split into two
174+
different packages, `@sentry/aws-serverless` and `@sentry/google-cloud`. These new packages have smaller bundle size
175+
than `@sentry/serverless`, which should improve your serverless cold-start times.
176+
177+
`@sentry/aws-serverless` and `@sentry/google-cloud` has also been changed to only emit CJS builds. The ESM build for the
178+
`@sentry/serverless` package was always broken and we decided to remove it entirely. ESM support will be re-added at a
179+
later date.
180+
181+
In `@sentry/serverless` you had to use a namespace import to initialize the SDK. This has been removed so that you can
182+
directly import from the SDK instead.
183+
184+
```js
185+
// v7
186+
const Sentry = require('@sentry/serverless');
187+
188+
Sentry.AWSLambda.init({
189+
dsn: '__DSN__',
190+
tracesSampleRate: 1.0,
191+
});
192+
193+
// v8
194+
const Sentry = require('@sentry/aws-serverless');
195+
196+
Sentry.init({
197+
dsn: '__DSN__',
198+
tracesSampleRate: 1.0,
199+
});
200+
```
201+
202+
```js
203+
// v7
204+
const Sentry = require('@sentry/serverless');
205+
206+
Sentry.GCPFunction.init({
207+
dsn: '__DSN__',
208+
tracesSampleRate: 1.0,
209+
});
210+
211+
// v8
212+
const Sentry = require('@sentry/google-cloud');
213+
214+
Sentry.init({
215+
dsn: '__DSN__',
216+
tracesSampleRate: 1.0,
217+
});
218+
```
219+
170220
## 3. Performance Monitoring Changes
171221

172222
- [Performance Monitoring API](./MIGRATION.md#performance-monitoring-api)

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ package. Please refer to the README and instructions of those SDKs for more deta
5757
- [`@sentry/gatsby`](https://github.com/getsentry/sentry-javascript/tree/master/packages/gatsby): SDK for Gatsby
5858
- [`@sentry/nextjs`](https://github.com/getsentry/sentry-javascript/tree/master/packages/nextjs): SDK for Next.js
5959
- [`@sentry/remix`](https://github.com/getsentry/sentry-javascript/tree/master/packages/remix): SDK for Remix
60-
- [`@sentry/serverless`](https://github.com/getsentry/sentry-javascript/tree/master/packages/serverless): SDK for
61-
Serverless Platforms (AWS, GCP)
60+
- [`@sentry/aws-serverless`](https://github.com/getsentry/sentry-javascript/tree/master/packages/aws-serverless): SDK
61+
for AWS Lambda Functions
62+
- [`@sentry/google-cloud`](https://github.com/getsentry/sentry-javascript/tree/master/packages/google-cloud): SDK for
63+
Google Cloud Functions
6264
- [`@sentry/electron`](https://github.com/getsentry/sentry-electron): SDK for Electron with support for native crashes
6365
- [`@sentry/react-native`](https://github.com/getsentry/sentry-react-native): SDK for React Native with support for
6466
native crashes

dev-packages/e2e-tests/test-applications/node-exports-test-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@sentry/remix": "latest || *",
1919
"@sentry/astro": "latest || *",
2020
"@sentry/nextjs": "latest || *",
21-
"@sentry/serverless": "latest || *",
21+
"@sentry/aws-serverless": "latest || *",
2222
"@sentry/google-cloud": "latest || *",
2323
"@sentry/bun": "latest || *",
2424
"@sentry/types": "latest || *",

dev-packages/e2e-tests/test-applications/node-exports-test-app/scripts/consistentExports.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import * as SentryNextJs from '@sentry/nextjs';
55
import * as SentryNode from '@sentry/node';
66
import * as SentryNodeExperimental from '@sentry/node-experimental';
77
import * as SentryRemix from '@sentry/remix';
8-
import * as SentryServerless from '@sentry/serverless';
98
import * as SentrySvelteKit from '@sentry/sveltekit';
109

10+
// SentryAWS is CJS only
11+
const SentryAWS = require('@sentry/aws-serverless');
12+
1113
/* List of exports that are safe to ignore / we don't require in any depending package */
1214
const NODE_EXPERIMENTAL_EXPORTS_IGNORE = [
1315
'default',
@@ -77,10 +79,10 @@ const DEPENDENTS: Dependent[] = [
7779
exports: Object.keys(SentryRemix),
7880
},
7981
{
80-
package: '@sentry/serverless',
81-
compareWith: nodeExperimentalExports,
82-
exports: Object.keys(SentryServerless),
83-
ignoreExports: ['cron', 'hapiErrorPlugin'],
82+
package: '@sentry/aws-serverless',
83+
compareWith: nodeExports,
84+
exports: Object.keys(SentryAWS),
85+
ignoreExports: ['makeMain'],
8486
},
8587
{
8688
package: '@sentry/google-cloud',

dev-packages/e2e-tests/verdaccio-config/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ packages:
134134
unpublish: $all
135135
# proxy: npmjs # Don't proxy for E2E tests!
136136

137-
'@sentry/serverless':
137+
'@sentry/aws-serverless':
138138
access: $all
139139
publish: $all
140140
unpublish: $all

dev-packages/rollup-utils/bundleHelpers.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
makeCleanupPlugin,
1212
makeCommonJSPlugin,
1313
makeIsDebugBuildPlugin,
14+
makeJsonPlugin,
1415
makeLicensePlugin,
1516
makeNodeResolvePlugin,
1617
makeRrwebBuildPlugin,
@@ -40,6 +41,8 @@ export function makeBaseBundleConfig(options) {
4041
// at all, and without `transformMixedEsModules`, they're only included if they're imported, not if they're required.)
4142
const commonJSPlugin = makeCommonJSPlugin({ transformMixedEsModules: true });
4243

44+
const jsonPlugin = makeJsonPlugin();
45+
4346
// used by `@sentry/browser`
4447
const standAloneBundleConfig = {
4548
output: {
@@ -84,12 +87,12 @@ export function makeBaseBundleConfig(options) {
8487
plugins: [rrwebBuildPlugin, markAsBrowserBuildPlugin],
8588
};
8689

87-
// used by `@sentry/serverless`, when creating the lambda layer
90+
// used by `@sentry/aws-serverless`, when creating the lambda layer
8891
const nodeBundleConfig = {
8992
output: {
9093
format: 'cjs',
9194
},
92-
plugins: [commonJSPlugin],
95+
plugins: [jsonPlugin, commonJSPlugin],
9396
// Don't bundle any of Node's core modules
9497
external: builtinModules,
9598
};

dev-packages/rollup-utils/npmHelpers.mjs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,16 @@ export function makeBaseNPMConfig(options = {}) {
120120
});
121121
}
122122

123-
export function makeNPMConfigVariants(baseConfig) {
124-
const variantSpecificConfigs = [
125-
{ output: { format: 'cjs', dir: path.join(baseConfig.output.dir, 'cjs') } },
126-
{ output: { format: 'esm', dir: path.join(baseConfig.output.dir, 'esm'), plugins: [makePackageNodeEsm()] } },
127-
];
123+
export function makeNPMConfigVariants(baseConfig, options = {}) {
124+
const { emitEsm = true } = options;
125+
126+
const variantSpecificConfigs = [{ output: { format: 'cjs', dir: path.join(baseConfig.output.dir, 'cjs') } }];
127+
128+
if (emitEsm) {
129+
variantSpecificConfigs.push({
130+
output: { format: 'esm', dir: path.join(baseConfig.output.dir, 'esm'), plugins: [makePackageNodeEsm()] },
131+
});
132+
}
128133

129134
return variantSpecificConfigs.map(variant => deepMerge(baseConfig, variant));
130135
}

dev-packages/rollup-utils/plugins/npmPlugins.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Sucrase plugin docs: https://github.com/rollup/plugins/tree/master/packages/sucrase
88
*/
99

10+
import json from '@rollup/plugin-json';
1011
import replace from '@rollup/plugin-replace';
1112
import sucrase from '@rollup/plugin-sucrase';
1213
import cleanup from 'rollup-plugin-cleanup';
@@ -18,11 +19,17 @@ import cleanup from 'rollup-plugin-cleanup';
1819
*/
1920
export function makeSucrasePlugin(options = {}) {
2021
return sucrase({
22+
// Required for bundling OTEL code properly
23+
exclude: ['**/*.json'],
2124
transforms: ['typescript', 'jsx'],
2225
...options,
2326
});
2427
}
2528

29+
export function makeJsonPlugin() {
30+
return json();
31+
}
32+
2633
/**
2734
* Create a plugin which can be used to pause the build process at the given hook.
2835
*

0 commit comments

Comments
 (0)