GoogleCloudPlatform / GoogleCloudPlatform/stackdriver-errors-js

Proposed API and build improvements

Abierto
#45 4 comentarios 2 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
360
Forks
54
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.