gcp-report

1.0.2 • Public • Published

gcp-report

allows simple error reporting for "Stack Driver: Error Reporting"

import gcpReport from 'gcp-report';

const report = gcpReport({
    // enable this to automatically report uncaught errors
    catchUncaughtErrors: true,

    service: 'service-name', // option (default "node")
    version: '0.0.1',// optional (default "latest")
    options: { // optional
        context: {
            user: 'example'
        }
    }
});

report(new Error('test')).then(() => {
    // done reporting error
});

report(new Error('test'), { // optional
    context: {
        user: 'example'
    }
}).then(() => {
    // done reporting error
});

extendable report event options

{
    "eventTime": "",
    "serviceContext": {
        "service": "",
        "version": ""
    },
    "message": "",
    "context": {
        "httpRequest": {
            "method": "",
            "url": "",
            "userAgent": "",
            "referrer": "",
            "responseStatusCode": 0,
            "remoteIp": ""
        },
        "user": "",
        "reportLocation": {
            "filePath": "",
            "lineNumber": 0,
            "functionName": ""
        }
    },
    "_autoGeneratedStackTrace": ""
}

Readme

Keywords

none

Package Sidebar

Install

npm i gcp-report

Weekly Downloads

2

Version

1.0.2

License

MIT

Unpacked Size

4.72 kB

Total Files

3

Last publish

Collaborators

  • icodeforlove