🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@qiwi/event-transmitter

Package Overview
Dependencies
Maintainers
3
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qiwi/event-transmitter

Async adapter to save & deliver reasonable events to some endpoint

latest
Source
npmnpm
Version
1.19.1
Version published
Maintainers
3
Created
Source

@qiwi/event-transmitter

Async adapter to save & deliver reasonable events to some endpoint

CI Maintainability Test Coverage

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

MIT

Keywords

pipe

FAQs

Package last updated on 29 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts