openreplay/tracker/tracker-vuex
2022-09-27 16:12:09 +02:00
..
src change(tracker): 4.1.2 2022-09-27 16:12:09 +02:00
.gitignore feat: tracker init 2021-05-03 13:31:55 +02:00
.npmignore feat: tracker init 2021-05-03 13:31:55 +02:00
LICENSE MIT license for OpenReplay protocol 2022-08-30 19:04:32 +02:00
package.json change(tracker): update tracker peerdep for plugins; versions: assist v4.0.1, axios v3.6.1, fetch v3.6.1, graphql v3.0.1, mobx v3.0.1, ngrx v3.4.9, profiler v3.0.1, redux v3.5.1, vuex v4.0.2 2022-09-13 12:32:35 +02:00
README.md Fix typos (#15) 2021-06-04 11:02:53 +02:00
tsconfig-cjs.json feat: tracker init 2021-05-03 13:31:55 +02:00
tsconfig.json feat(tracker-vuex): 3.4.8: webpack 5 fully specified imports 2021-11-29 19:14:51 +01:00

OpenReplay Tracker Vuex plugin

A Vuex plugin for OpenReplay Tracker. This plugin allows you to see the application state during session replay.

Installation

npm i @openreplay/tracker-vuex

Usage

Initialize the @openreplay/tracker package as usual and load the plugin into it. Then put the generated plugin into your plugins field of your store.

import Vuex from 'vuex'
import Tracker from '@openreplay/tracker';
import trackerVuex from '@openreplay/tracker-vuex';

const tracker = new Tracker({
  projectKey: YOUR_PROJECT_KEY,
});

const store = new Vuex.Store({
  // ...
  plugins: [tracker.plugin(trackerVuex())],
});

You can customize the plugin behavior with options to sanitize your data. They are similar to the ones from the standard createLogger plugin.

trackerVuex({
  filter (mutation, state) {
    // returns `true` if a mutation should be logged
    // `mutation` is a `{ type, payload }`
    return mutation.type !== "aBlacklistedMutation";
  },
  transformer (state) {
    // transform 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;
  },
})