Profiler

إضافة Profiler الخاصة بـ OpenReplay.

Profiler

تتيح لك إضافة profiler قياس أداء دوال JS الخاصة بك والتقاط كل من الوسائط والنتيجة لكل استدعاء.

npm i @openreplay/tracker-profiler

قم بتهيئة المتتبّع (tracker) وحمّل الإضافة داخله. ثم قم بتزيين أي دالة داخل شيفرتك باستخدام الدالة المُولَّدة.

إذا كان موقع الويب الخاص بك تطبيقًا أحادي الصفحة (SPA)

Section titled إذا كان موقع الويب الخاص بك تطبيقًا أحادي الصفحة (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

إذا كان تطبيق الويب الخاص بك يتم تصييره من جانب الخادم (SSR)

Section titled إذا كان تطبيق الويب الخاص بك يتم تصييره من جانب الخادم (SSR)

اتّبع المثال أدناه إذا كان تطبيقك يعتمد على SSR. تأكّد من استدعاء tracker.start() بمجرد بدء تشغيل التطبيق (في useEffect أو 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

هل تواجه صعوبة في إعداد هذه الإضافة؟ يُرجى الانضمام إلى Slack الخاص بنا أو الاطّلاع على المنتدى للحصول على المساعدة من مجتمعنا.