Async adapter to save & deliver reasonable events to some endpoint
yarn add @qiwi/event-transmitter
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')
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;
}
}
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