GoogleCloudPlatform / stackdriver-errors-js

Client-side JavaScript exception reporting library for Cloud Error Reporting
https://cloud.google.com/error-reporting/
Apache License 2.0
362 stars 54 forks source link

Proposed API and build improvements #45

Open bz2 opened 6 years ago

bz2 commented 6 years ago

Thanks for publishing this library, have been using it a quite heavily over the last few months to record frontend errors in the same place as we track backend problems. Out of this, I'd like to submit some improvements, some of which may require some discussion and decisions, so this is a meta issue for tracking the proposed changes.

Library API

Currently StackdriverErrorReporter exposes a callback parameter in a few places, mostly to enable the testing. This allows some errors to be seen by callers, but does not expose the extracted stacktrace message and is somewhat awkward to use. As stacktrace-js already uses promises, I suggest the interface here should too. The promise api is widely available and there's a polyfill bundled in the build already (though this may want some tweaking, see below).

When calling report() directly from a logging framework, stacktraces for strings currently start inside the logger rather than at the caller.

Build and packaging

This is a simple library and doesn't need a complicated build, but there are a few niggles currently when embedding in a modern webapp, and the single file bundle could also been improved. Not sure how far to go on this front, but there are some simple improvements to make at least.

steren commented 6 years ago

Thanks for your contributions. They look good to me. I will be reviewing the changes within the next days.

bz2 commented 5 years ago

Thank you very much for review and landing so far!

Will put the next batch up for consideration later.

Main things to resolve are what specifically report() should resolve and reject into, and how to produce both a simple ES5 compatible bundled file and a clean module interface.

steren commented 5 years ago

I created a new release with all your existing improvements.

Thanks a lot for your contributions!

bz2 commented 5 years ago

@steren Thanks! Will update our code to use latest version and some of the new interfaces.