VueX

OpenReplay 用の VueX プラグイン。

VueX

このプラグインを使用すると、VueX のミューテーションとステートをキャプチャし、セッション録画の再生中に後から確認できます。問題の把握と修正に非常に役立ちます。

npm i @openreplay/tracker-vuex

@openreplay/tracker パッケージを通常どおり初期化し、プラグインを読み込みます。次に、生成されたプラグインをストアの plugins フィールドに追加します。

Web サイトがシングルページアプリケーション(SPA)の場合

Section titled Web サイトがシングルページアプリケーション(SPA)の場合
import Vuex from 'vuex'
import trackerVuex from '@openreplay/tracker-vuex';
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
});

Web アプリがサーバーサイドレンダリング(SSR)の場合

Section titled Web アプリがサーバーサイドレンダリング(SSR)の場合

アプリが SSR の場合は、以下の例に従ってください。 トラッカーがブラウザ環境で実行されるようにしてください。 SSR でエラーが発生する場合は、トラブルシューティングセクションを参照してください。

import Vuex from 'vuex'
import OpenReplay from '@openreplay/tracker/cjs';
import trackerVuex from '@openreplay/tracker-vuex/cjs';
//...
const tracker = new OpenReplay({
  projectKey: PROJECT_KEY,
  ingestPoint: "https://openreplay.mydomain.com/ingest", // when dealing with the self-hosted version of OpenReplay
  // ... options
});

tracker-vuex のバージョンが 4.0.0 より高い場合

Section titled tracker-vuex のバージョンが 4.0.0 より高い場合
// check list of available options below
const vuexPlugin = tracker.use(trackerVuex(<options>)); 

// add a name to your store, optional (will be randomly generated otherwise)
const storeTracker = vuexPlugin('STORE NAME') 

const store = createStore({
  state,
  mutations,
  plugins: [storeTracker]
})

tracker-vuex のバージョンが 3.0.0 より低い場合

Section titled tracker-vuex のバージョンが 3.0.0 より低い場合
// check list of available options below
const vuexPlugin = tracker.use(trackerVuex(<options>));  

tracker.start();

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

プラグインの動作をオプションでカスタマイズして、データをサニタイズできます。これらは標準の 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;
  },
})

このプラグインを使用してセッションリプレイ内のステートの変更をキャプチャする実践的な例をお探しの場合は、詳細なチュートリアルをご覧ください。

ご質問はありますか?

Section titled ご質問はありますか?

このプラグインのセットアップで問題が発生した場合は、Slack に参加して、コミュニティのサポートを受けてください。