@ohbug/redux-middleware
TypeScript icon, indicating that this package has built-in type declarations

1.0.13 • Public • Published

@ohbug/redux-middleware

npm npm bundle size Code style

English | 简体中文

Installation

yarn add @ohbug/browser @ohbug/redux-middleware

Usage

import Ohbug from '@ohbug/browser'
import { createStore, applyMiddleware } from 'redux'
import createOhbugMiddleware from '@ohbug/redux-middleware'
import reducer from './reducer'

Ohbug.init({ apiKey: 'YOUR_API_KEY' })

const store = createStore(reducer, applyMiddleware(createOhbugMiddleware()))

API

import type { Action, MiddlewareAPI } from 'redux'
type CreateOhbugMiddlewareOption = (
  action: Action,
  store: MiddlewareAPI
) => Action | false

example

import type { Action, MiddlewareAPI } from 'redux'
function before(action: Action, store: MiddlewareAPI) {
  if (action.type === 'foo') {
    // You can filter on certain sensitive information, which will not be collected
    // Just return false
    return false
  } else if (action.type === 'bar') {
    // If you want to collect some data after processing
    return {
      type: action.type,
      payload: store.getState() + action.payload,
    }
  }
  return action
}

// ...
const store = createStore(
  reducer,
  applyMiddleware(createOhbugMiddleware(before))
)

Readme

Keywords

none

Package Sidebar

Install

npm i @ohbug/redux-middleware

Weekly Downloads

0

Version

1.0.13

License

Apache-2.0

Unpacked Size

24.4 kB

Total Files

11

Last publish

Collaborators

  • yuebanla