diff --git a/.kokoro/debugger.cfg b/.kokoro/debugger.cfg deleted file mode 100644 index 5cbed05585..0000000000 --- a/.kokoro/debugger.cfg +++ /dev/null @@ -1,13 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Set the folder in which the tests are run -env_vars: { - key: "PROJECT" - value: "debugger" -} - -# Tell the trampoline which build file to use. -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/nodejs-docs-samples/.kokoro/build.sh" -} diff --git a/.kokoro/trace.cfg b/.kokoro/trace.cfg deleted file mode 100644 index 3ffa03ab1b..0000000000 --- a/.kokoro/trace.cfg +++ /dev/null @@ -1,13 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Set the folder in which the tests are run -env_vars: { - key: "PROJECT" - value: "trace" -} - -# Tell the trampoline which build file to use. -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/nodejs-docs-samples/.kokoro/build.sh" -} diff --git a/error-reporting/README.md b/error-reporting/README.md deleted file mode 100644 index e0e444986a..0000000000 --- a/error-reporting/README.md +++ /dev/null @@ -1,57 +0,0 @@ -Google Cloud Platform logo - -# Stackdriver Error Reporting Node.js Samples - -[![Build](https://storage.googleapis.com/cloud-docs-samples-badges/GoogleCloudPlatform/nodejs-docs-samples/nodejs-docs-samples-logging.svg)]() - -[Stackdriver Error Reporting](https://cloud.google.com/error-reporting/docs/) aggregates and displays errors produced in your running cloud services. - -## Table of Contents - -* [Setup](#setup) -* [Samples](#samples) - * [Examples](#examples) -* [Running the tests](#running-the-tests) - -## Setup - -1. Read [Prerequisites][prereq] and [How to run a sample][run] first. -1. Install dependencies: - - npm install - - -[prereq]: ../README.md#prerequisites -[run]: ../README.md#how-to-run-a-sample - -## Samples - -### Examples - -View the [documentation][snippets_0_docs] or the [source code][snippets_0_code]. - -__Usage:__ `node snippets.js --help` - -``` -Commands: - manual Manually reports errors. - -Options: - --help Show help [boolean] - -Examples: - node snippets.js manual Manually report some errors. - -For more information, see https://cloud.google.com/error-reporting/docs -``` - -[snippets_0_docs]: https://cloud.google.com/error-reporting/docs -[snippets_0_code]: snippets.js - -## Running the tests - -1. Set the **GCLOUD_PROJECT** and **GOOGLE_APPLICATION_CREDENTIALS** environment variables. - -1. Run the tests: - - npm test diff --git a/error-reporting/package.json b/error-reporting/package.json deleted file mode 100644 index 596aa76211..0000000000 --- a/error-reporting/package.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "nodejs-docs-samples-logging", - "version": "0.0.1", - "private": true, - "license": "Apache-2.0", - "author": "Google Inc.", - "repository": { - "type": "git", - "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" - }, - "engines": { - "node": ">=6" - }, - "scripts": { - "lint": "semistandard '**/*.js'", - "pretest": "npm run lint", - "error-test": "repo-tools test app --msg \"Something broke!\" --url \"http://localhost:33332/error\" --port 33332 -- snippets.js express", - "exception-test": "repo-tools test app --code 500 --msg SyntaxError --url \"http://localhost:33333/exception\" --port 33333 -- snippets.js express", - "system-test": "ava -T 1m --verbose system-test/*.test.js", - "all-test": "npm run system-test && npm run error-test && npm run exception-test", - "test": "repo-tools test run --cmd npm -- run all-test" - }, - "dependencies": { - "@google-cloud/error-reporting": "0.2.3", - "express": "4.16.4", - "yargs": "11.0.0" - }, - "devDependencies": { - "@google-cloud/nodejs-repo-tools": "^3.0.0", - "ava": "0.25.0", - "proxyquire": "2.0.0", - "semistandard": "^12.0.1", - "sinon": "4.4.2" - }, - "cloud-repo-tools": { - "requiresKeyFile": true, - "requiresProjectId": true, - "product": "error_reporting", - "samples": [ - { - "id": "snippets", - "name": "Examples", - "file": "snippets.js", - "docs_link": "https://cloud.google.com/error-reporting/docs", - "usage": "node snippets.js --help" - } - ] - } -} diff --git a/error-reporting/snippets.js b/error-reporting/snippets.js deleted file mode 100644 index 3ee41a85f9..0000000000 --- a/error-reporting/snippets.js +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Copyright 2017, Google, Inc. - * 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 setupImplicit () { - // [START error_reporting_setup_implicit] - // Imports the Google Cloud client library - const ErrorReporting = require('@google-cloud/error-reporting'); - - // Instantiates a client - const errors = ErrorReporting(); - - // Reports a simple error - errors.report('Something broke!'); - // [END error_reporting_setup_implicit] -} - -function setupExplicit () { - // [START error_reporting_setup_explicit] - // Imports the Google Cloud client library - const ErrorReporting = require('@google-cloud/error-reporting'); - - // Instantiates a client - const errors = ErrorReporting({ - projectId: 'your-project-id', - keyFilename: '/path/to/key.json' - }); - - // Reports a simple error - errors.report('Something broke!'); - // [END error_reporting_setup_explicit] -} - -function manual () { - // [START error_reporting_manual] - // Imports the Google Cloud client library - const ErrorReporting = require('@google-cloud/error-reporting'); - - // Instantiates a client - const errors = 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_manual] -} - -function express () { - // [START error_reporting_express] - const express = require('express'); - - // Imports the Google Cloud client library - const ErrorReporting = require('@google-cloud/error-reporting'); - - // Instantiates a client - const errors = 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_express] -} - -// The command-line program -const cli = require(`yargs`) - .demand(1) - .command('setup-implicit', 'Reports a simple error using implicit credentials.', {}, setupImplicit) - .command('setup-explicit', 'Reports a simple error using explicit credentials.', {}, setupExplicit) - .command('manual', 'Manually reports errors.', {}, manual) - .command('express', 'Starts and Express service with integrated error reporting.', {}, express) - .example('node $0 setup-implicit', 'Reports a simple error using implicit credentials.') - .example('node $0 setup-explicit', 'Reports a simple error using explicit credentials.') - .example('node $0 manual', 'Manually report some errors.') - .example('node $0 express', 'Starts and Express service with integrated error reporting.') - .wrap(120) - .recommendCommands() - .epilogue(`For more information, see https://cloud.google.com/error-reporting/docs`) - .help() - .strict(); - -if (module === require.main) { - cli.parse(process.argv.slice(2)); -} diff --git a/error-reporting/system-test/snippets.test.js b/error-reporting/system-test/snippets.test.js deleted file mode 100644 index c830419619..0000000000 --- a/error-reporting/system-test/snippets.test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2017, Google, Inc. - * 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'; - -const path = require(`path`); -const test = require(`ava`); -const tools = require(`@google-cloud/nodejs-repo-tools`); - -const cwd = path.join(__dirname, `..`); -const cmd = `node snippets.js`; - -test.before(tools.checkCredentials); - -test.serial(`should setup using implicit credentials`, async (t) => { - t.plan(0); - // There's no output, the command should just succeed - await tools.runAsync(`${cmd} setup-implicit`, cwd); -}); - -test.serial(`should report errors manually`, async (t) => { - const output = await tools.runAsync(`${cmd} manual`, cwd); - t.is(output.includes('Done reporting error event!'), true); - t.is(output.includes('Done reporting Error object!'), true); - t.is(output.includes('Done reporting error string!'), true); -});