From 8bde2daaf48d47a1c86eec55d18e5444821c1e27 Mon Sep 17 00:00:00 2001 From: Dominic Kramer Date: Mon, 19 Mar 2018 13:47:31 -0700 Subject: [PATCH] chore: update README to reflect the new API (#76) --- error-reporting/quickstart.js | 6 +++++- error-reporting/snippets.js | 24 ++++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/error-reporting/quickstart.js b/error-reporting/quickstart.js index 41cfb75b81c..c1cc209904f 100644 --- a/error-reporting/quickstart.js +++ b/error-reporting/quickstart.js @@ -25,8 +25,12 @@ function quickstart() { // On Node 6+ the following syntax can be used instead: // const {ErrorReporting} = require('@google-cloud/error-reporting'); + // With ES6 style imports via TypeScript or Babel, the following + // syntax can be used instead: + // import {ErrorReporting} from '@google-cloud/error-reporting'; + // Instantiates a client - const errors = ErrorReporting(); + const errors = new ErrorReporting(); // Reports a simple error errors.report('Something broke!'); diff --git a/error-reporting/snippets.js b/error-reporting/snippets.js index a1ae59c5c38..c6f27289501 100644 --- a/error-reporting/snippets.js +++ b/error-reporting/snippets.js @@ -24,8 +24,12 @@ function setupImplicit() { // On Node 6+ the following syntax can be used instead: // const {ErrorReporting} = require('@google-cloud/error-reporting'); + // With ES6 style imports via TypeScript or Babel, the following + // syntax can be used instead: + // import {ErrorReporting} from '@google-cloud/error-reporting'; + // Instantiates a client - const errors = ErrorReporting(); + const errors = new ErrorReporting(); // Reports a simple error errors.report('Something broke!'); @@ -41,8 +45,12 @@ function setupExplicit() { // On Node 6+ the following syntax can be used instead: // const {ErrorReporting} = require('@google-cloud/error-reporting'); + // With ES6 style imports via TypeScript or Babel, the following + // syntax can be used instead: + // import {ErrorReporting} from '@google-cloud/error-reporting'; + // Instantiates a client - const errors = ErrorReporting({ + const errors = new ErrorReporting({ projectId: 'your-project-id', keyFilename: '/path/to/key.json', }); @@ -61,8 +69,12 @@ function manual() { // On Node 6+ the following syntax can be used instead: // const {ErrorReporting} = require('@google-cloud/error-reporting'); + // With ES6 style imports via TypeScript or Babel, the following + // syntax can be used instead: + // import {ErrorReporting} from '@google-cloud/error-reporting'; + // Instantiates a client - const errors = ErrorReporting(); + const errors = new ErrorReporting(); // Use the error message builder to customize all fields ... const errorEvent = errors.event(); @@ -99,8 +111,12 @@ function express() { // On Node 6+ the following syntax can be used instead: // const {ErrorReporting} = require('@google-cloud/error-reporting'); + // With ES6 style imports via TypeScript or Babel, the following + // syntax can be used instead: + // import {ErrorReporting} from '@google-cloud/error-reporting'; + // Instantiates a client - const errors = ErrorReporting(); + const errors = new ErrorReporting(); const app = express();