Redux
Este plugin permite capturar as ações e o estado do Redux e inspecioná-los depois ao reproduzir as gravações de sessões. Isso é muito útil para entender e corrigir problemas.
Instalação
Section titled Instalaçãonpm i @openreplay/tracker-redux --save
Inicialize o tracker e coloque o middleware gerado na sua cadeia do Redux.
Se o seu site é uma Single Page Application (SPA)
Section titled Se o seu site é uma Single Page Application (SPA)import { applyMiddleware, createStore } from 'redux';
import trackerRedux from '@openreplay/tracker-redux';
import { tracker } from '@openreplay/tracker';
tracker.configure({
projectKey: 'YOUR_PROJECT_KEY',
ingestPoint: "https://openreplay.mydomain.com/ingest", // when dealing with the self-hosted version of OpenReplay
});
tracker.start();
const openReplayMiddleware = tracker.use(trackerRedux(<options>)); // check list of available options below
//...
const store = createStore(
reducer,
applyMiddleware(openReplayMiddleware)
);
Se o seu web app usa Server-Side Rendering (SSR)
Section titled Se o seu web app usa Server-Side Rendering (SSR)Siga o exemplo abaixo se o seu app usa SSR. Garanta que o tracker seja executado assim que o app estiver no ambiente do navegador.
'use client'
import { applyMiddleware, createStore } from 'redux';
import trackerRedux from '@openreplay/tracker-redux/cjs';
import { tracker } from '@openreplay/tracker';
tracker.configure({
projectKey: 'YOUR_PROJECT_KEY',
ingestPoint: "https://openreplay.mydomain.com/ingest", // when dealing with the self-hosted version of OpenReplay
});
const openReplayMiddleware = tracker.use(trackerRedux(<options>)); // check list of available options below
const store = createStore( // You can define/use it anywhere in response handlers
reducer,
applyMiddleware(openReplayMiddleware)
);
//...
function MyApp() {
useEffect(() => { // use componentDidMount in case of React Class Component
tracker.start();
}, []);
//... Use store here
}
Opções
Section titled OpçõesVocê pode personalizar o comportamento do middleware com opções para sanitizar seus dados.
trackerRedux({
actionFilter: action => action.type !== 'DRAW', // only actions which pass this test will be recorded
actionTransformer: action => action.type === 'LOGIN' ? null : action,
actionType: action => action.type // action type for search, that's the default one
stateTransformer: state => {
const { jwt, ..._state } = state;
return _state;
},
})
Tutorial
Section titled TutorialSe você procura um exemplo prático de como usar este plugin para capturar mudanças de estado nos seus session replays, confira nosso tutorial detalhado aqui.
Tem dúvidas?
Section titled Tem dúvidas?Está com dificuldade para configurar este plugin? Conecte-se ao nosso Slack e receba ajuda da nossa comunidade.