Pinia
Este plugin permite capturar as mutações e o estado do Pinia 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-vuex
Inicialize o pacote @openreplay/tracker normalmente e carregue o plugin nele. Chame o plugin para definir o nome do store; isso retornará uma instância de tracker nomeada para o store, que você pode chamar passando o seu store como argumento para habilitar o rastreamento desse store.
Se o seu site é uma Single Page Application (SPA)
Section titled Se o seu site é uma Single Page Application (SPA)import OpenReplay from '@openreplay/tracker';
import trackerVuex from '@openreplay/tracker-vuex';
Se o seu web app usa Server-Side Rendering (SSR)
Section titled Se o seu web app usa Server-Side Rendering (SSR)import OpenReplay from '@openreplay/tracker/cjs';
import trackerVuex from '@openreplay/tracker-vuex/cjs';
Rastreando o store do Pinia
Section titled Rastreando o store do Pinia
//...
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 examplePiniaStore = useExamplePiniaStore()
const vuexPlugin = tracker.use(trackerVuex(<options>)) // check list of available options below
const piniaStorePlugin = vuexPlugin('STORE NAME') // add a name to your store,
// optional (will be randomly generated otherwise)
piniaStorePlugin(examplePiniaStore) // start tracking state updates
// now you can use examplePiniaStore as usual pinia store (destructure values or return it as a whole etc)
Opções
Section titled OpçõesVocê pode personalizar o comportamento do plugin com opções para sanitizar seus dados. Elas são semelhantes às do plugin padrão createLogger.
trackerVuex({
filter (mutation, state) {
// returns `true` if a mutation should be logged
// `mutation` is a `{ type, payload }`
return mutation.type !== "aBlacklistedMutation";
},
transformer (state) {
// transforms the state before logging it.
// for example return only a specific sub-tree
return state.subTree;
},
mutationTransformer (mutation) {
// mutations are logged in the format of `{ type, payload }`
// we can format it any way we want.
return mutation.type;
},
})
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.