GoogleCloudPlatform / GoogleCloudPlatform/stackdriver-errors-js

Proposed API and build improvements

未关闭
#45 4 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
360
派生
54
PR 合并指标
30 天内没有已合并 PR

描述

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](https://github.com/stacktracejs/stacktrace.js) already uses promises, I suggest the interface here should too. The [promise api is widely available](https://caniuse.com/#feat=promises) and there's a polyfill bundled in the build already (though this may want some tweaking, see below).

- [x] Return a Promise from `report()` and `sendErrorPayload()` #50
- [x] Propagate `payload` (or just `payload.message`) when promise is fulfilled #59
- [ ] Add config option to output message to `console.log` #6
- [x] Handle non-200 HTTP responses #32

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

- [x] Expose `firstFrameIndex` as an argument to `report()` #58

## 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.

- [x] Update devDependencies to latest versions #49
- [x] Remove 'dist' folder from version control #48
- [x] Make `npm start` launch the demo in a browser window #52
- [x] Enable ES6 import without hack #2

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。