Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate code from googleapis/nodejs-error-reporting #2821

Merged
merged 72 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
7ec9157
Error reporting (#408)
jmdobry Jun 26, 2017
08ee4ba
Update dependencies + fix a few tests (#448)
Aug 5, 2017
4b64fe8
Build updates. (#462)
jmdobry Aug 23, 2017
405ecf7
Update dependencies (#468)
Aug 31, 2017
2fbaff8
Complete code migration (#18)
DominicKramer Dec 22, 2017
f763bb7
chore: fix the samples tests (#39)
DominicKramer Jan 11, 2018
6975b40
Fixing vulnerability reported by snyk (#51)
alexander-fenster Jan 24, 2018
7fcddf0
chore: update README to reflect the new API (#76)
DominicKramer Mar 19, 2018
bdf66a9
chore: release v0.4.0 (#109)
DominicKramer Apr 11, 2018
c4bea37
chore: lock files maintenance (#114)
alexander-fenster May 2, 2018
72240d7
chore: lock files maintenance (#118)
alexander-fenster May 16, 2018
92ffdbb
chore: update package locks (#122)
alexander-fenster May 16, 2018
26391d7
chore: upgrade to gts 0.6.0 (#123)
JustinBeckwith May 18, 2018
d516b8c
chore: lock files maintenance (#131)
alexander-fenster May 22, 2018
303d4b4
fix: upgrade to the latest @google-cloud/common (#128)
JustinBeckwith May 22, 2018
0af32c1
fix: update gts and typescript (#143)
JustinBeckwith Jun 22, 2018
44e84d5
chore: update sample lockfiles (#147)
JustinBeckwith Jun 25, 2018
78fcd07
refactor: drop repo-tool as an exec wrapper (#148)
JustinBeckwith Jun 26, 2018
f78a7ba
bump version to 0.5.0 (#149)
crwilcox Jun 27, 2018
5f2c1b2
chore(deps): update dependency sinon to v5.1.1 (#151)
renovate[bot] Jun 28, 2018
5c9380b
fix(deps): update dependency yargs to v12 (#154)
renovate[bot] Jun 29, 2018
1189fed
chore(deps): update dependency sinon to v6 (#153)
renovate[bot] Jun 29, 2018
b213f2d
chore(deps): update dependency nyc to v12 (#152)
renovate[bot] Jun 29, 2018
dbffef1
chore(deps): lock file maintenance (#156)
renovate[bot] Jul 3, 2018
2e8ca8f
chore(deps): lock file maintenance (#160)
renovate[bot] Jul 10, 2018
3960373
fix: drop support for nodejs 9.x (#161)
JustinBeckwith Jul 10, 2018
c8c4417
chore(deps): lock file maintenance (#163)
renovate[bot] Jul 10, 2018
22a82e5
chore(deps): lock file maintenance (#164)
renovate[bot] Jul 10, 2018
64cfa41
chore(deps): lock file maintenance (#169)
renovate[bot] Jul 17, 2018
7494bea
chore(deps): lock file maintenance (#172)
renovate[bot] Jul 24, 2018
d7fc961
chore: require node 8 for samples (#178)
JustinBeckwith Jul 30, 2018
e78e1a2
chore(deps): lock file maintenance (#181)
renovate[bot] Jul 31, 2018
ba45735
chore(deps): lock file maintenance (#191)
renovate[bot] Aug 7, 2018
74c7359
chore: ignore package-lock.json (#193)
JustinBeckwith Aug 7, 2018
bc131ad
chore(deps): update dependency nyc to v13 (#200)
renovate[bot] Aug 28, 2018
e0c589c
chore(deps): update dependency sinon to v7 (#223)
renovate[bot] Oct 15, 2018
2b77145
chore(deps): update dependency @google-cloud/nodejs-repo-tools to v3 …
renovate[bot] Nov 10, 2018
3dd87de
Update region tags in samples (#259)
fhinkel Nov 21, 2018
34de7eb
refactor(samples): convert sample tests from ava to mocha (#257)
nareshqlogic Nov 26, 2018
ed3bda6
Release v0.5.2 (#292)
DominicKramer Dec 20, 2018
0343d2e
Release v0.6.0 (#298)
JustinBeckwith Jan 22, 2019
e8d4345
fix(deps): update dependency yargs to v13 (#312)
renovate[bot] Feb 12, 2019
8771eab
chore(deps): update dependency mocha to v6
renovate[bot] Feb 19, 2019
68dd41b
Release v0.6.1 (#325)
JustinBeckwith Mar 14, 2019
41fbf12
Release v0.6.2 (#338)
bcoe Apr 9, 2019
afed739
Release v0.6.3 (#340)
bcoe Apr 11, 2019
384169b
docs(samples): modernize samples, sample tests (#346)
JustinBeckwith May 2, 2019
41fe5de
chore: release 1.0.0 (#360)
yoshi-automation May 18, 2019
114da2f
chore: release 1.1.0 (#378)
yoshi-automation Jun 20, 2019
26cf52c
chore: release 1.1.1 (#382)
yoshi-automation Jun 26, 2019
8e6ee5c
chore: update license headers
JustinBeckwith Nov 25, 2019
5060059
chore: release 1.1.3 (#414)
release-please[bot] Dec 5, 2019
b92df77
refactor: use explicit mocha imports (#425)
JustinBeckwith Dec 30, 2019
3db596a
chore(deps): update dependency mocha to v7 (#428)
renovate-bot Jan 6, 2020
ebebc4c
chore(deps): update dependency gaxios to v3 (#457)
renovate-bot Apr 11, 2020
72b8ade
build!: update to latest version of gts and typescript (#467)
sofisl Apr 12, 2020
306449e
chore: release 2.0.0 (#469)
release-please[bot] Jun 4, 2020
5f34cee
chore(deps): update dependency mocha to v8 (#485)
renovate-bot Jun 11, 2020
234a836
chore(deps): update dependency gaxios to v4 (#524)
renovate-bot Nov 3, 2020
8699991
chore: release 2.0.1 (#536)
release-please[bot] Jan 14, 2021
b822b7c
chore: release 2.0.2 (#573)
release-please[bot] May 12, 2021
84f222a
chore: release 2.0.3 (#594)
release-please[bot] Aug 26, 2021
ce7900f
chore: release 2.0.4 (#605)
release-please[bot] Oct 4, 2021
5fba9bd
chore(main): release 2.0.5 (#636)
release-please[bot] Apr 21, 2022
dd03ca3
chore(deps): update dependency gaxios to v5 (#638)
renovate-bot Apr 21, 2022
5114792
build!: update library to use Node 12 (#644)
sofisl May 20, 2022
f714636
chore(main): release 3.0.0 (#645)
release-please[bot] May 25, 2022
4b1a060
chore(main): release 3.0.1 (#649)
release-please[bot] Jun 11, 2022
bcaa858
chore(main): release 3.0.2 (#655)
release-please[bot] Aug 25, 2022
7635b48
chore(main): release 3.0.3 (#657)
release-please[bot] Sep 8, 2022
3505b5e
chore(main): release 3.0.4 (#677)
release-please[bot] Oct 13, 2022
77ba53f
docs: Add error-reporting samples
kweinmeister Nov 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/error-reporting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: error-reporting
on:
push:
branches:
- main
paths:
- "error-reporting/**"
pull_request:
paths:
- "error-reporting/**"
pull_request_target:
types: [labeled]
schedule:
- cron: "0 0 * * 0"
jobs:
test:
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }}
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: "write"
pull-requests: "write"
id-token: "write"
steps:
- uses: actions/checkout@v3.1.0
with:
ref: ${{github.event.pull_request.head.sha}}
- uses: "google-github-actions/auth@v0.8.3"
with:
workload_identity_provider: "projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider"
service_account: "kokoro-system-test@long-door-651.iam.gserviceaccount.com"
create_credentials_file: "true"
access_token_lifetime: 600s
- uses: actions/setup-node@v3.5.1
with:
node-version: 16
- run: npm install
working-directory: error-reporting
- run: npm test
working-directory: error-reporting
env:
MOCHA_REPORTER_SUITENAME: error_reporting
MOCHA_REPORTER_OUTPUT: error_reporting_sponge_log.xml
MOCHA_REPORTER: xunit
- if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.issues.removeLabel({
name: 'actions:force-run',
owner: 'GoogleCloudPlatform',
repo: 'nodejs-docs-samples',
issue_number: context.payload.pull_request.number
});
} catch (e) {
if (!e.message.includes('Label does not exist')) {
throw e;
}
}
- if: ${{ github.event_name == 'schedule'}}
run: |
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
chmod +x ./flakybot
./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
1 change: 1 addition & 0 deletions .github/workflows/workflows.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"datacatalog/quickstart",
"endpoints/getting-started",
"endpoints/getting-started-grpc",
"error-reporting",
"functions/firebase",
"functions/helloworld",
"functions/http",
Expand Down
3 changes: 3 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ monitoring/opencensus @GoogleCloudPlatform/nodejs-samples-reviewers
# Data & AI
contact-center-insights @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers
talent @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers

# DEE-PO
error-reporting @GoogleCloudPlatform/dee-platform-ops @GoogleCloudPlatform/nodejs-samples-reviewers
3 changes: 3 additions & 0 deletions error-reporting/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
rules:
no-console: off
38 changes: 38 additions & 0 deletions error-reporting/explicitSetup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// sample-metadata:
// title: Explicit setup
// description: Reports a simple error using explicit credentials.
// usage: node explicitSetup.js

'use strict';

function explicitSetup() {
// [START error_reporting_setup_nodejs_explicit]
// Imports the Google Cloud client library
const {ErrorReporting} = require('@google-cloud/error-reporting');

// Instantiates a client
const errors = new ErrorReporting({
projectId: 'your-project-id',
keyFilename: '/path/to/key.json',
});

// Reports a simple error
errors.report('Something broke!');
// [END error_reporting_setup_nodejs_explicit]
}

explicitSetup();
54 changes: 54 additions & 0 deletions error-reporting/express.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// sample-metadata:
// title: Express integration
// description: Starts and Express service with integrated error reporting.
// usage: node express.js

'use strict';

function express() {
// [START error_reporting_setup_nodejs_express]
const express = require('express');

// Imports the Google Cloud client library
const {ErrorReporting} = require('@google-cloud/error-reporting');

// Instantiates a client
const errors = new ErrorReporting();

const app = express();

app.get('/error', (req, res, next) => {
res.send('Something broke!');
next(new Error('Custom error message'));
});

app.get('/exception', () => {
JSON.parse('{"malformedJson": true');
});

// Note that express error handling middleware should be attached after all
// the other routes and use() calls. See the Express.js docs.
app.use(errors.express);

const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
console.log('Press Ctrl+C to quit.');
});
// [END error_reporting_setup_nodejs_express]
}
express();
35 changes: 35 additions & 0 deletions error-reporting/implicitSetup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// sample-metadata:
// title: Implicit setup
// description: Reports a simple error using implicit credentials.
// usage: node implicitSetup.js

'use strict';

function setupImplicit() {
// [START error_reporting_setup_nodejs_implicit]
// Imports the Google Cloud client library
const {ErrorReporting} = require('@google-cloud/error-reporting');

// Instantiates a client
const errors = new ErrorReporting();

// Reports a simple error
errors.report('Something broke!');
// [END error_reporting_setup_nodejs_implicit]
}

setupImplicit();
53 changes: 53 additions & 0 deletions error-reporting/manual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// sample-metadata:
// title: Manual reporting
// description: Manually reports errors.
// usage: node manual.js

'use strict';

function manual() {
// [START error_reporting_setup_nodejs_manual]
// Imports the Google Cloud client library
const {ErrorReporting} = require('@google-cloud/error-reporting');

// Instantiates a client
const errors = new ErrorReporting();

// Use the error message builder to customize all fields ...
const errorEvent = errors.event();

// Add error information
errorEvent.setMessage('My error message');
errorEvent.setUser('root@nexus');

// Report the error event
errors.report(errorEvent, () => {
console.log('Done reporting error event!');
});

// Report an Error object
errors.report(new Error('My error message'), () => {
console.log('Done reporting Error object!');
});

// Report an error by provided just a string
errors.report('My error message', () => {
console.log('Done reporting error string!');
});
// [END error_reporting_setup_nodejs_manual]
}
manual();
26 changes: 26 additions & 0 deletions error-reporting/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "nodejs-docs-samples-error-reporting",
"private": true,
"license": "Apache-2.0",
"author": "Google Inc.",
"repository": "googleapis/nodejs-error-reporting",
"files": [
"*.js",
"!test/"
],
"engines": {
"node": ">=12.0.0"
},
"scripts": {
"test": "mocha --timeout=600000"
},
"dependencies": {
"@google-cloud/error-reporting": "^3.0.4",
"express": "^4.16.3"
},
"devDependencies": {
"chai": "^4.2.0",
"gaxios": "^5.0.0",
"mocha": "^8.0.0"
}
}
29 changes: 29 additions & 0 deletions error-reporting/quickstart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

function quickstart() {
// [START error_reporting_quickstart]
// Imports the Google Cloud client library
const {ErrorReporting} = require('@google-cloud/error-reporting');

// Instantiates a client
const errors = new ErrorReporting();

// Reports a simple error
errors.report('Something broke!');
// [END error_reporting_quickstart]
}
quickstart();
Loading