Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qiwi/event-transmitter
Async adapter to save & deliver front-end events to some back-end
https://github.com/qiwi/event-transmitter
monitoring
Last synced: 4 days ago
JSON representation
Async adapter to save & deliver front-end events to some back-end
- Host: GitHub
- URL: https://github.com/qiwi/event-transmitter
- Owner: qiwi
- License: mit
- Created: 2020-02-26T14:59:10.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-09-29T12:11:53.000Z (about 1 year ago)
- Last Synced: 2024-09-22T17:45:55.495Z (about 2 months ago)
- Topics: monitoring
- Language: TypeScript
- Homepage:
- Size: 1.42 MB
- Stars: 3
- Watchers: 11
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @qiwi/event-transmitter
> Async adapter to save & deliver reasonable events to some endpoint[![CI](https://github.com/qiwi/event-transmitter/workflows/CI/badge.svg)](https://github.com/qiwi/event-transmitter/actions)
[![Maintainability](https://api.codeclimate.com/v1/badges/d72d92ed2e931dacecf9/maintainability)](https://codeclimate.com/github/qiwi/event-transmitter/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/d72d92ed2e931dacecf9/test_coverage)](https://codeclimate.com/github/qiwi/event-transmitter/test_coverage)## Install
```bash
yarn add @qiwi/event-transmitter
```## Usage
### FLP integration
```ts
import { createFrontLogProxyTransmitter } from '@qiwi/event-transmitter'const transmitter = createFrontLogProxyTransmitter({
appName: 'my-app',
url: 'https://example.qiwi.com/event'
})// logger-like interface
transmitter.error(new Error('some error'))
transmitter.info('some-event')
transmitter.debug('debug')
transmitter.warn('warn')
transmitter.trace('trace')
```### FLP integration with React
```javascript
import { createFrontLogProxyTransmitter } from '@qiwi/event-transmitter'const transmitter = createFrontLogProxyTransmitter({
appName: 'my=app',
url: 'https://example.qiwi.com/event'
})class ErrorBoundary extends Component {
public state = {
hasError: false
};public static getDerivedStateFromError() {
return { hasError: true };
}public componentDidCatch(error, errorInfo) {
transmitter.error({message: error, details: {errorInfo}})
}public render() {
if (this.state.hasError) {
returnSorry.. there was an error
;
}return this.props.children;
}
}
```### Custom usage
```ts
import {createTransmitter, createHttpPipe, IPipe} from '@qiwi/event-transmitter'const httpPipe: IPipe = createHttpPipe({
url: 'https://example.qiwi.com/event',
method: 'POST'
})const transmitter = createTransmitter({
pipeline: [httpPipe]
})
const event: IClientEventDto = {...}transmitter.push(event)
```
See also [https://github.com/qiwi/flp-njs](https://github.com/qiwi/flp-njs)## License
[MIT](LICENSE)