Profiler

Plugin Profiler pour OpenReplay.

Profiler

Le plugin profiler vous permet de mesurer les performances de vos fonctions JS et de capturer à la fois les arguments et le résultat de chaque appel.

npm i @openreplay/tracker-profiler

Initialisez le tracker et chargez-y le plugin. Ensuite, décorez n’importe quelle fonction de votre code avec la fonction générée.

Si votre site web est une application monopage (SPA)

Section titled Si votre site web est une application monopage (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

Si votre application web est rendue côté serveur (SSR)

Section titled Si votre application web est rendue côté serveur (SSR)

Suivez l’exemple ci-dessous si votre application est en SSR. Assurez-vous que tracker.start() soit appelé une fois l’application démarrée (dans useEffect ou 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

Vous rencontrez des difficultés pour configurer ce plugin ? Rejoignez notre Slack ou consultez notre Forum et obtenez de l’aide auprès de notre communauté.