Skip to content

Commit 249a313

Browse files
authored
feat(google-cloud): Add @sentry/google-cloud package (#10993)
in the first step to our serverless changes, introduce a `@sentry/google-cloud` package that contains all google cloud functions related functionality. No migration guide yet, will write that after I merge this in and open a PR for the aws changes.
1 parent 0caddec commit 249a313

File tree

33 files changed

+1888
-1
lines changed

33 files changed

+1888
-1
lines changed

.craft.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ targets:
9191
- name: npm
9292
id: '@sentry/serverless'
9393
includeNames: /^sentry-serverless-\d.*\.tgz$/
94+
- name: npm
95+
id: '@sentry/google-cloud'
96+
includeNames: /^sentry-google-cloud-\d.*\.tgz$/
9497
- name: npm
9598
id: '@sentry/bun'
9699
includeNames: /^sentry-bun-\d.*\.tgz$/

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ body:
4343
- '@sentry/react'
4444
- '@sentry/remix'
4545
- '@sentry/serverless'
46+
- '@sentry/google-cloud'
4647
- '@sentry/svelte'
4748
- '@sentry/sveltekit'
4849
- '@sentry/vue'

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@sentry/astro": "latest || *",
2020
"@sentry/nextjs": "latest || *",
2121
"@sentry/serverless": "latest || *",
22+
"@sentry/google-cloud": "latest || *",
2223
"@sentry/bun": "latest || *",
2324
"@sentry/types": "latest || *",
2425
"@types/node": "18.15.1",

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as SentryAstro from '@sentry/astro';
22
import * as SentryBun from '@sentry/bun';
3+
import * as SentryGoogleCloud from '@sentry/google-cloud';
34
import * as SentryNextJs from '@sentry/nextjs';
45
import * as SentryNode from '@sentry/node';
56
import * as SentryNodeExperimental from '@sentry/node-experimental';
@@ -81,6 +82,12 @@ const DEPENDENTS: Dependent[] = [
8182
exports: Object.keys(SentryServerless),
8283
ignoreExports: ['cron', 'hapiErrorPlugin'],
8384
},
85+
{
86+
package: '@sentry/google-cloud',
87+
compareWith: nodeExports,
88+
exports: Object.keys(SentryGoogleCloud),
89+
ignoreExports: ['makeMain'],
90+
},
8491
{
8592
package: '@sentry/sveltekit',
8693
compareWith: nodeExperimentalExports,

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ packages:
140140
unpublish: $all
141141
# proxy: npmjs # Don't proxy for E2E tests!
142142

143+
'@sentry/google-cloud':
144+
access: $all
145+
publish: $all
146+
unpublish: $all
147+
# proxy: npmjs # Don't proxy for E2E tests!
148+
143149
'@sentry/svelte':
144150
access: $all
145151
publish: $all

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"postpublish": "lerna run --stream --concurrency 1 postpublish",
3434
"test": "lerna run --ignore \"@sentry-internal/{browser-integration-tests,e2e-tests,integration-shims,node-integration-tests,overhead-metrics}\" test",
3535
"test:unit": "lerna run --ignore \"@sentry-internal/{browser-integration-tests,e2e-tests,integration-shims,node-integration-tests,overhead-metrics}\" test:unit",
36-
"test-ci-browser": "lerna run test --ignore \"@sentry/{bun,deno,node,node-experimental,profiling-node,serverless,nextjs,remix,gatsby,sveltekit,vercel-edge}\" --ignore \"@sentry-internal/{browser-integration-tests,e2e-tests,integration-shims,node-integration-tests,overhead-metrics}\"",
36+
"test-ci-browser": "lerna run test --ignore \"@sentry/{bun,deno,node,node-experimental,profiling-node,serverless,google-cloud,nextjs,remix,gatsby,sveltekit,vercel-edge}\" --ignore \"@sentry-internal/{browser-integration-tests,e2e-tests,integration-shims,node-integration-tests,overhead-metrics}\"",
3737
"test-ci-node": "ts-node ./scripts/node-unit-tests.ts",
3838
"test-ci-bun": "lerna run test --scope @sentry/bun",
3939
"test:update-snapshots": "lerna run test:update-snapshots",
@@ -56,6 +56,7 @@
5656
"packages/eslint-plugin-sdk",
5757
"packages/feedback",
5858
"packages/gatsby",
59+
"packages/google-cloud",
5960
"packages/integration-shims",
6061
"packages/nextjs",
6162
"packages/node",

packages/google-cloud/.eslintrc.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
env: {
3+
node: true,
4+
},
5+
extends: ['../../.eslintrc.js'],
6+
rules: {
7+
'@sentry-internal/sdk/no-optional-chaining': 'off',
8+
},
9+
overrides: [
10+
{
11+
files: ['scripts/**/*.ts'],
12+
parserOptions: {
13+
project: ['../../tsconfig.dev.json'],
14+
},
15+
},
16+
{
17+
files: ['test/**'],
18+
parserOptions: {
19+
sourceType: 'module',
20+
},
21+
},
22+
],
23+
};

packages/google-cloud/LICENSE

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Copyright (c) 2024 Sentry (https://sentry.io) and individual contributors. All rights reserved.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
4+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
5+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
6+
persons to whom the Software is furnished to do so, subject to the following conditions:
7+
8+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
9+
Software.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
13+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
14+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

packages/google-cloud/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<p align="center">
2+
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
3+
<img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84">
4+
</a>
5+
</p>
6+
7+
# Official Sentry SDK for Google Cloud Functions
8+
9+
## Links
10+
11+
- [Official SDK Docs](https://docs.sentry.io/)
12+
- [TypeDoc](http://getsentry.github.io/sentry-javascript/)
13+
14+
## General
15+
16+
This package is a wrapper around `@sentry/node`, with added functionality related to various Serverless solutions. All
17+
methods available in `@sentry/node` can be imported from `@sentry/google-cloud`.
18+
19+
To use this SDK, call `Sentry.init(options)` at the very beginning of your JavaScript file.
20+
21+
```javascript
22+
import * as Sentry from '@sentry/google-cloud';
23+
24+
Sentry.init({
25+
dsn: '__DSN__',
26+
tracesSampleRate: 1.0,
27+
// ...
28+
});
29+
30+
// For HTTP Functions:
31+
32+
exports.helloHttp = Sentry.wrapHttpFunction((req, res) => {
33+
throw new Error('oh, hello there!');
34+
});
35+
36+
// For Background Functions:
37+
38+
exports.helloEvents = Sentry.wrapEventFunction((data, context, callback) => {
39+
throw new Error('oh, hello there!');
40+
});
41+
42+
// For CloudEvents:
43+
44+
exports.helloEvents = Sentry.wrapCloudEventFunction((context, callback) => {
45+
throw new Error('oh, hello there!');
46+
});
47+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../../jest/jest.config.js');

0 commit comments

Comments
 (0)