1.19.1 • Published 8 months ago
@qiwi/event-transmitter v1.19.1
@qiwi/event-transmitter
Async adapter to save & deliver reasonable events to some endpoint
Install
yarn add @qiwi/event-transmitter
Usage
FLP integration
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
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) {
return <h1>Sorry.. there was an error</h1>;
}
return this.props.children;
}
}
Custom usage
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
License
1.19.1
8 months ago
1.19.0
1 year ago
1.18.2
1 year ago
1.18.1
1 year ago
1.18.0
1 year ago
1.17.5
2 years ago
1.17.2
2 years ago
1.17.1
2 years ago
1.17.0
2 years ago
1.17.4
2 years ago
1.17.3
2 years ago
1.16.1
2 years ago
1.16.0
2 years ago
1.15.2
3 years ago
1.15.1
3 years ago
1.15.0
3 years ago
1.14.2
3 years ago
1.14.1
3 years ago
1.14.0
4 years ago
1.13.0
4 years ago
1.12.1
4 years ago
1.12.0
4 years ago
1.11.0
4 years ago
1.10.0
4 years ago
1.9.0
4 years ago
1.8.0
4 years ago
1.7.2
4 years ago
1.7.1
4 years ago
1.7.0
4 years ago
1.6.1
4 years ago
1.6.0
4 years ago
1.5.0
4 years ago
1.4.0
4 years ago
1.2.0
4 years ago
1.3.0
4 years ago
1.1.0
4 years ago
1.0.0
4 years ago