Profiler

Plugin Profiler per OpenReplay.

Profiler

Il plugin profiler ti consente di misurare le prestazioni delle tue funzioni JS e di catturare sia gli argomenti sia il risultato di ogni chiamata.

npm i @openreplay/tracker-profiler

Inizializza il tracker e carica al suo interno il plugin. Poi decora qualsiasi funzione del tuo codice con la funzione generata.

Se il tuo sito web è una Single Page Application (SPA)

Section titled Se il tuo sito web è una Single Page Application (SPA)
import trackerProfiler from '@openreplay/tracker-profiler';
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 profiler = tracker.use(trackerProfiler());

tracker.start();

// ...
const fn = profiler('MyFunction')(() => {
  // Inspecting function body
}, thisArg); // thisArg is optional

Se la tua web app usa il Server-Side Rendering (SSR)

Section titled Se la tua web app usa il Server-Side Rendering (SSR)

Segui l’esempio qui sotto se la tua app usa l’SSR. Assicurati che tracker.start() venga chiamato una volta avviata l’app (in useEffect o componentDidMount).

import trackerProfiler from '@openreplay/tracker-profiler/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 profiler = tracker.use(trackerProfiler());

//...
function MyApp() {
  useEffect(() => { // use componentDidMount in case of React Class Component
    tracker.start();
  }, [])
}
//...
const fn = profiler('MyFunction')(() => {
  // Inspecting function body
}, thisArg); // thisArg is optional

Hai difficoltà a configurare questo plugin? Unisciti al nostro Slack e ricevi aiuto dalla nostra community.