diff --git a/frontend/app/assets/integrations/pinia.svg b/frontend/app/assets/integrations/pinia.svg new file mode 100644 index 000000000..3a20cba15 --- /dev/null +++ b/frontend/app/assets/integrations/pinia.svg @@ -0,0 +1 @@ + diff --git a/frontend/app/components/Client/Integrations/Integrations.tsx b/frontend/app/components/Client/Integrations/Integrations.tsx index 8e301ac8a..cde34ed89 100644 --- a/frontend/app/components/Client/Integrations/Integrations.tsx +++ b/frontend/app/components/Client/Integrations/Integrations.tsx @@ -29,6 +29,7 @@ import AssistDoc from './AssistDoc'; import { PageTitle, Loader } from 'UI'; import AnimatedSVG, { ICONS } from 'Shared/AnimatedSVG/AnimatedSVG'; import withPageTitle from 'HOCs/withPageTitle'; +import PiniaDoc from './PiniaDoc' interface Props { fetch: (name: string, siteId: string) => void; @@ -162,6 +163,7 @@ const integrations = [ integrations: [ { title: 'Redux', slug: '', icon: 'integrations/redux', component: }, { title: 'VueX', slug: '', icon: 'integrations/vuejs', component: }, + { title: 'Pinia', slug: '', icon: 'integrations/pinia', component: }, { title: 'GraphQL', slug: '', icon: 'integrations/graphql', component: }, { title: 'NgRx', slug: '', icon: 'integrations/ngrx', component: }, { title: 'MobX', slug: '', icon: 'integrations/mobx', component: }, diff --git a/frontend/app/components/Client/Integrations/PiniaDoc/PiniaDoc.tsx b/frontend/app/components/Client/Integrations/PiniaDoc/PiniaDoc.tsx new file mode 100644 index 000000000..8a2033a2d --- /dev/null +++ b/frontend/app/components/Client/Integrations/PiniaDoc/PiniaDoc.tsx @@ -0,0 +1,102 @@ +import React from 'react'; +import Highlight from 'react-highlight'; +import ToggleContent from '../../../shared/ToggleContent'; +import DocLink from 'Shared/DocLink/DocLink'; +import { connect } from 'react-redux'; + +const PiniaDoc = (props) => { + const { projectKey } = props; + return ( +
+

VueX

+
+
+ This plugin allows you to capture Pinia mutations + state and inspect them later on while + replaying session recordings. This is very useful for understanding and fixing issues. +
+ +
Installation
+ {`npm i @openreplay/tracker-vuex --save`} + +
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 OpenReplay from '@openreplay/tracker'; +import trackerVuex from '@openreplay/tracker-vuex'; +//... +const tracker = new OpenReplay({ + projectKey: '${projectKey}' +}); +tracker.start(); +//... +const examplePiniaStore = useExamplePiniaStore() +// check list of available options below +const vuexPlugin = tracker.use(trackerVuex()) +// add a name to your store, optional +//(will be randomly generated otherwise) +const piniaStorePlugin = vuexPlugin('STORE NAME') + +// start tracking state updates +piniaStorePlugin(examplePiniaStore) +// now you can use examplePiniaStore as +// usual pinia store +// (destructure values or return it as a whole etc) +`} + + } + second={ + + {`import Vuex from 'vuex' +import OpenReplay from '@openreplay/tracker/cjs'; +import trackerVuex from '@openreplay/tracker-vuex/cjs'; +//... +const tracker = new OpenReplay({ + projectKey: '${projectKey}' +}); +//... + +// start tracker when the app is mounted +tracker.start(); + +//... +const examplePiniaStore = useExamplePiniaStore() +// check list of available options below +const vuexPlugin = tracker.use(trackerVuex()) +// add a name to your store, optional +// (will be randomly generated otherwise) +const piniaStorePlugin = vuexPlugin('STORE NAME') + +// start tracking state updates +piniaStorePlugin(examplePiniaStore) +// now you can use examplePiniaStore as +// usual pinia store +// (destructure values or return it as a whole etc) +}`} + + } + /> + + +
+
+ ); +}; + +PiniaDoc.displayName = 'PiniaDoc'; + +export default connect((state) => ({ + projectKey: state.getIn(['site', 'instance', 'projectKey']), +}))(PiniaDoc); diff --git a/frontend/app/components/Client/Integrations/PiniaDoc/index.js b/frontend/app/components/Client/Integrations/PiniaDoc/index.js new file mode 100644 index 000000000..730c76beb --- /dev/null +++ b/frontend/app/components/Client/Integrations/PiniaDoc/index.js @@ -0,0 +1 @@ +export { default } from './PiniaDoc'