openui5-error-collector
A UI5 library that collects a running app's JavaScript errors, unhandled Promise rejections and UI5 log events, and can post them to a backend with navigator.sendBeacon.
Errors in a browser app are visible only in the user's console unless something gathers them. This library collects plain JavaScript errors, unhandled Promise rejections, UI5 log events from sap/base/Log and Reporting API errors, keeps them behind ui5ErrorCollector.getErrors() and, once serverUrl is set through setConfiguration, posts them with navigator.sendBeacon. An onSyncHook callback replaces that sender, which is the route for IE11, where sendBeacon is unsupported, or for sending to several backends. The script is loaded before sap-ui-bootstrap, so errors raised while UI5 itself boots are collected too. It is a client-side collector only: the receiving backend is not part of it.
Facts
Where it sits
Who is behind it
In the atlas: maintains 16, contributes to 41, wrote 4@mauriciolauffermaintainer
Before choosing this
Signals
ActivityQuietRelease and repository quiet for 43 months
Both observable publication channels have been quiet for at least 24 full months. This may be normal for stable software; check whether its current state still fits your use.
What it declares
Every artifact
- Type
- Package
- Origin
- Independently maintained
As a package
- Where it runs
- Inside its host
- Distributed through
- npm
Connections
Seeing what a running service did, in a readable form
Download
Install
npm add openui5-error-collectorDerived from the package name. No recipe recorded; the README has the configuration.
README
quoted from mauriciolauffer/openui5-error-collector under MIT, readopenui5-error-collector
This library collects javascript errors and can send them to a backend, if errors need to be logged and saved for further analysis:
- vanilla js errors (reference, syntax, type, etc)
- Promises with unhandled rejections
- UI5 log events from sap/base/Log
- errors from Report API
Demo
You can check out a live demo here:
https://mauriciolauffer.github.io/openui5-error-collector/demo/index.html
Project Structure
- demo - Library's live demo
- dist - Distribution folder which contains the library ready to use
- src - Development folder
- test - Testing framework for the library
Getting started
Installation
Install openui5-error-collector as an npm module
$ npm install openui5-error-collector
How to use
Import openui5-error-collector to your UI5 application as a regular javascript file. You should import it before sap-ui-bootstrap to capture UI5 bootstrap errors as well.
<script async src="dist/ui5ErrorCollector.min.js"></script>
<script async id="sap-ui-bootstrap" src="/resources/sap-ui-core.js" ... ></script>
Once imported, all errors will be automatically captured. It also exposes a global variable ui5ErrorCollector, eg, window.ui5ErrorCollector which can be used to get the errors and to set the details to send them to a backend server.
Sending errors to a backend
Developers can send all errors to a backend server setting serverUrl with method ui5ErrorCollector.setConfiguration. Once serverUrl is set, errors'll be sent to it using navigator.sendBeacon (this is not supported by IE11).
ui5ErrorCollector.setConfiguration({
serverUrl: 'https://my-backend-server.com'
});
To make it compatible with IE11, or to add any extra logic when synchronizing (transform the payload, send to multiple backends, etc), a callback onSyncHook can be passed to method ui5ErrorCollector.setConfiguration. This'll replace the default behaviour and use the provided callback onSyncHook rather than navigator.sendBeacon.
/**
* Callback provided to replace default sync with backend server
*
* @param {string} serverUrl - Server URL
* @param {UI5ErrorLogEvent[]} errors - List of captured errors, same as ui5ErrorCollector.getErrors() results
*/
function myCustomOnSyncHook(serverUrl, errors) {
// Go crazy, do whatever you wanna here...
const payload = JSON.stringify(errors);
fetch(serverUrl, {body: payload, method: 'POST'});
$.ajax(serverUrl, {body: payload, method: 'POST'});
}
ui5ErrorCollector.setConfiguration({
serverUrl: 'https://my-backend-server.com',
onSyncHook: myCustomOnSyncHook
});
Retrieving errors
Mehod ui5ErrorCollector.getErrors will return all captured errors.
ui5ErrorCollector.getErrors(); // Which returns an array of the following object:
/**
* @type {object}
* @property {string} type - Log event type
* @property {string} timestamp - When event was logged
* @property {string} uri - Where event was logged
* @property {?string} stack - Error stack
* @property {string} message - Error message
* @property {?string} component - UI5 Log component
* @property {number} level - Log level
* @property {?number} elapsedTimestamp - Elapsed time since page load
* @property {?string} filename - File which triggered the error
*/
// Some data sample:
[
{
"type": "error",
"timestamp": "2022-02-14T05:59:02.987Z",
"uri": "http://localhost:3000/test/webapp/index.html",
"stack": "TypeError: Cannot read properties of undefined (reading 'substring')\n at http://localhost:3000/test/webapp/index.html:30:40",
"message": "Uncaught TypeError: Cannot read properties of undefined (reading 'substring')",
"component": null,
"level": 1,
"elapsedTimestamp": 755.1999999880791,
"filename": "http://localhost:3000/test/webapp/index.html"
},
{
"type": "deprecation",
"timestamp": "2022-02-14T05:59:03.294Z",
"uri": "http://localhost:3000/test/webapp/index.html",
"stack": null,
"message": "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.",
"component": "XMLHttpRequestSynchronousInNonWorkerOutsideBeforeUnload",
"level": 1,
"elapsedTimestamp": null,
"filename": "https://openui5.hana.ondemand.com/resources/sap-ui-core.js"
},
{
"type": "ui5",
"timestamp": "2022-02-14T05:59:03.880Z",
"uri": "http://localhost:3000/test/webapp/index.html",
"stack": "Error: failed to load JavaScript resource: openui5/errorcollector/Component-preload.js\n at mapUi5LogEntry (http://localhost:3000/src/ui5ErrorCollector.js:39:17)\n at Object.logUi5LogEntry [as onLogEntry] (http://localhost:3000/src/ui5ErrorCollector.js:26:24)\n at Object.onLogEntry (https://openui5.hana.ondemand.com/resources/sap-ui-core.js:124:143)\n at f (https://openui5.hana.ondemand.com/resources/sap-ui-core.js:135:551)\n at Object.L.error (https://openui5.hana.ondemand.com/resources/sap-ui-core.js:126:27)\n at h.error (https://openui5.hana.ondemand.com/resources/sap-ui-core.js:141:109)\n at HTMLScriptElement.p (https://openui5.hana.ondemand.com/resources/sap-ui-core.js:60:413)",
"message": "failed to load JavaScript resource: openui5/errorcollector/Component-preload.js",
"component": "sap.ui.ModuleSystem",
"level": 1,
"elapsedTimestamp": null,
"filename": null
},
{
"type": "unhandledrejection",
"timestamp": "2022-02-14T05:59:05.316Z",
"uri": "http://localhost:3000/test/webapp/index.html",
"stack": null,
"message": 12345,
"component": null,
"level": 1,
"elapsedTimestamp": 3084.199999988079,
"filename": null
}
]
Author
Mauricio Lauffer
History
Others providing
Compare all 20 on the Logging page →- ABAP-LoggerABAP-LoggerA logging library for ABAP that records messages into the standard Application Log (BC-SRV-BAL) and displays them from there, installed through abapGit on ABAP 702 or higher.independent, abapLogging library for ABAP over the Application Logfrom ABAP
- abap-log-exporterabap-log-exporterExports SAP NetWeaver logs from the Business Application Log to an external log system such as Graylog or Loki, converting entries to GELF or Loki format through a separately configured reader, converter and connector.independent, abapExports Business Application Log entries to Graylog or Lokifrom ABAP
- ABAP-PRCABAP-PRCA framework for custom multi-step ABAP processes: a process class declares the states, and the framework runs each document through them and monitors the run.independent, abapFramework for multi-step ABAP processes with monitoringfrom ABAP
- SAP Application Logging service for SAP BTPSAP Application Logging service for SAP BTPCollects an application's log lines from Cloud Foundry or Kyma into a searchable Kibana, for the retention the plan sets.sap official, btpCollects Cloud Foundry or Kyma logs into a searchable Kibanafrom BTP/BAIP
- SAP Cloud LoggingSAP Cloud LoggingAn instance-based observability service built on OpenSearch that stores and analyses logs, metrics and traces from Cloud Foundry, Kyma, Kubernetes and other runtime environments.sap official, btpOpenSearch-based store for logs, metrics and tracesfrom BTP/BAIP
- com.sap.cds:cds-services-bomcom.sap.cds:cds-services-bomThe Maven bill of materials for CAP Java, pinning every com.sap.cds module in a release, from the API and core runtime to the Spring Boot starters and the CQN engine, to the same version.sap official, capMaven bill of materials pinning CAP Java module versionsfrom CAP
- @cap-js/audit-logging@cap-js/audit-loggingIntegration with the SAP Audit Log service, so operations on personal data are recorded in the form an auditor expects without the application writing the entries.sap official, capCAP integration with the SAP Audit Log servicefrom CAP
- abap-logabap-logA logging library for ABAP with one logger interface in front of several targets, from the Application Log and the job log to database tables, files and the Eclipse console.independent, abapABAP logging library with one interface across output targetsfrom ABAP
- ABAP_LOGGINGABAP_LOGGINGAn object-oriented wrapper around SAP's Business Application Log (BAL) for ABAP NetWeaver, chaining texts, messages and exceptions onto a log header that persists in its own or the same connection.independent, abapObject-oriented wrapper around the Business Application Logfrom ABAP
- abap-cloud-loggerabap-cloud-loggerA logging library for ABAP Cloud that wraps the released class CL_BALI_LOG in a chainable logger, collecting exceptions, messages and tables, with a stopwatch and a sticky context tag.independent, abapChainable logger for ABAP Cloud around CL_BALI_LOGfrom ABAP
- abap-fm-loggerabap-fm-loggerA logger for ABAP function modules (RFC) that stores each call's parameters as JSON in one table, with a viewer report to search the log and reprocess a record, akin to WE10 and WE19.independent, abapLogger storing RFC function module call parameters as JSONfrom ABAP
- open-abap-balopen-abap-balApplication logging for ABAP code transpiled to JavaScript and run on Node.js, one of the runtime libraries open-abap.org lists.community org, abapApplication logging for ABAP transpiled to JavaScript on Node.jsfrom ABAP
- @openui5/sap.ui.core@openui5/sap.ui.coreThe OpenUI5 core: the module loader, the MVC runtime, data binding, routing, theming and the test stack, which is everything a UI5 app does before a single community package is added.sap official, ui5Framework core: module loader, MVC runtime, binding, routing, themingfrom UI5
- abap-fluentdabap-fluentdA Fluentd client written in ABAP for sending log lines from an ABAP system to a Fluentd collector, where entries are flushed with an explicit COMMIT WORK.independent, abapFluentd client in ABAP for sending log lines to a collectorfrom ABAP
- @saptools/cf-logs@saptools/cf-logsA command line and typed Node.js library that fetches and streams the logs of one Cloud Foundry app and parses them into structured rows.independent, btpLog fetcher and parser for one Cloud Foundry appfrom BTP/BAIP
- @saptools/cf-tail@saptools/cf-tailA command line that tails every started app in a Cloud Foundry space at once and merges their logs into one timeline by timestamp, with filters by level, tenant, router status and time window.independent, btpMerged log tail of every started app in a Cloud Foundry spacefrom BTP/BAIP
- sap-usi-logging-apisap-usi-logging-apiAn object-oriented encapsulation around SAP's Application Log (transaction SLG1), controlled by customizing, with attachable data containers that SLG1 shows behind a detail button.independent, abapObject-oriented wrapper around SAP's Application Log (SLG1)from ABAP
- srbjsloggersrbjsloggerA browser JavaScript logger whose log, warn and error calls write prominent output to the console, loaded into a UI5 app through index.html or the manifest's resources.independent, ui5A browser JavaScript logger whose log, warn and error calls write prominent output to the console, loaded into a UI5 app through index.html or the manifest's resources.from UI5
- abap-message-loggerabap-message-loggerA message logger for ABAP Cloud that collects T100 messages, BAPIRET2 structures, exceptions and plain text before saving them to the Application Log.independent, abapMessage logger for ABAP Cloud that saves to the Application Logfrom ABAP
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
History in the atlas
- First seen.
For your agent
- Ref
artifact:mauriciolauffer-openui5-error-collector- JSON
- /artifacts/mauriciolauffer-openui5-error-collector.json
- MCP
- Connecting an agent