I want to add an error reporting in a nodejs app which will report errors to stackdriver api on GCP. I have followed all the steps required to report an error but when I report error I'm getting an error
ERROR:@google-cloud/error-reporting: Encountered an error while attempting to transmit an error to the Stackdriver Error Reporting API. ApiError: User not authorized.
The entire error stack is
ERROR:@google-cloud/error-reporting: Encountered an error while attempting to transmit an error to the Stackdriver Error Reporting API. ApiError: User not authorized.
at new ApiError (/Applications/XAMPP/xamppfiles/htdocs/web-dev/kiddopia.com/node_modules/@google-cloud/common/build/src/util.js:59:15)
at Util.parseHttpRespBody (/Applications/XAMPP/xamppfiles/htdocs/web-dev/kiddopia.com/node_modules/@google-cloud/common/build/src/util.js:194:38)
at Util.handleResp (/Applications/XAMPP/xamppfiles/htdocs/web-dev/kiddopia.com/node_modules/@google-cloud/common/build/src/util.js:135:117)
at /Applications/XAMPP/xamppfiles/htdocs/web-dev/kiddopia.com/node_modules/@google-cloud/common/build/src/util.js:434:22
at onResponse (/Applications/XAMPP/xamppfiles/htdocs/web-dev/kiddopia.com/node_modules/retry-request/index.js:214:7)
at /Applications/XAMPP/xamppfiles/htdocs/web-dev/kiddopia.com/node_modules/teeny-request/build/src/index.js:219:13
at processTicksAndRejections (node:internal/process/task_queues:94:5)
My error reporting helper is
const { ErrorReporting } = require('@google-cloud/error-reporting');
module.exports = class ErrorReportHelper {
constructor() {
this.errorReporter = new ErrorReporting({
projectId: 'project-id',
reportMode: 'always',
keyFilename: 'service.json'
});
}
report(message) {
this.errorReporter.report(message);
}
express() {
return this.errorReporter.express();
}
}
Any help appreciated. Thanks