0Pricing
Next.js 15 Fullstack (App Router + Server Actions) · درس

المراقبة وتتبع الأخطاء في بيئة الإنتاج

حافظ على سلامة تطبيق Next.js المنشور عبر التسجيل المنظم، وتتبع الأخطاء باستخدام Sentry، وتحليلات الأداء، ومراقبة التوافر.

المراقبة وتتبع الأخطاء في بيئة الإنتاج درس مجاني في Next.js 15 Fullstack (App Router + Server Actions) على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Next.js 15 Fullstack (App Router + Server Actions)، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Next.js 15 Fullstack (App Router + Server Actions) 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Why Monitor Production?

Once your app is live, you cannot reproduce every user's environment. Monitoring tells you when something breaks, how often, and for whom — so you fix issues before they spread.

The Three Pillars

Observability rests on:

  • Logs: discrete events
  • Metrics: numbers over time (latency, error rate)
  • Traces: the path of a request across services

Structured Logging

Plain text logs are hard to search. Emit structured JSON logs with consistent fields so tools can filter and aggregate them.

console.log(JSON.stringify({
  level: 'error',
  route: '/api/checkout',
  userId: 42,
  msg: 'payment failed'
}));

Installing Sentry

Sentry captures unhandled errors with stack traces and context. The wizard wires it into both server and client.

npx @sentry/wizard@latest -i nextjs

Capturing Errors

Sentry catches uncaught exceptions automatically, but you can also report handled errors with extra context.

import * as Sentry from '@sentry/nextjs';
try {
  await charge();
} catch (e) {
  Sentry.captureException(e, { tags: { feature: 'billing' } });
}

Error Boundaries with error.tsx

An error.tsx file catches render errors in a route segment and shows a fallback instead of a white screen. It is a Client Component.

'use client';
export default function Error({ error, reset }) {
  return <button onClick={reset}>Try again</button>;
}

Performance with Web Vitals

Track real user experience with Core Web Vitals — LCP, CLS, INP. Next.js exposes them through a reporting hook.

export function reportWebVitals(metric) {
  if (metric.name === 'LCP') sendToAnalytics(metric);
}

Vercel Analytics & Speed Insights

On Vercel, the Analytics and Speed Insights packages collect real-world metrics with one component each, no extra config.

import { SpeedInsights } from '@vercel/speed-insights/next';
// render <SpeedInsights /> in your root layout

Uptime Monitoring

An uptime monitor pings a health endpoint at intervals and alerts you if it fails. Expose a lightweight route for this.

// app/api/health/route.ts
export function GET() {
  return Response.json({ status: 'ok' });
}

Setting Up Alerts

Data is useless if no one looks. Configure alerts: notify the team on Slack when error rate spikes or latency crosses a threshold. Alert on symptoms users feel, not noise.

Best Practices

Stay on top of production:

  • Emit structured logs
  • Track errors with Sentry and error.tsx
  • Watch Core Web Vitals
  • Add an uptime check and meaningful alerts

Quick Check

Test your monitoring knowledge.

Recap

You learned to monitor production:

  • Logs, metrics, and traces form observability
  • Use structured logging and Sentry for error tracking
  • Catch render errors with error.tsx
  • Track Web Vitals, add a health endpoint, and set alerts

Now you find and fix problems before users complain.

الأسئلة الشائعة

هل درس «المراقبة وتتبع الأخطاء في بيئة الإنتاج» مجاني؟

نعم — نص درس «المراقبة وتتبع الأخطاء في بيئة الإنتاج» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Next.js 15 Fullstack (App Router + Server Actions)، انتقل إلى CoddyKit PRO. تتضمن دورة Next.js 15 Fullstack (App Router + Server Actions) 4 دروس في المجموع.

ماذا ستتعلم في «المراقبة وتتبع الأخطاء في بيئة الإنتاج»؟

حافظ على سلامة تطبيق Next.js المنشور عبر التسجيل المنظم، وتتبع الأخطاء باستخدام Sentry، وتحليلات الأداء، ومراقبة التوافر. تتمرن على Next.js 15 Fullstack (App Router + Server Actions) مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Next.js 15 Fullstack (App Router + Server Actions)؟

لا تُشترط خبرة سابقة. Next.js 15 Fullstack (App Router + Server Actions) على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.

كم من الوقت يستغرق درس «المراقبة وتتبع الأخطاء في بيئة الإنتاج»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Next.js 15 Fullstack (App Router + Server Actions) هذا؟

نعم. كل درس في Next.js 15 Fullstack (App Router + Server Actions) يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. النشر على Vercel
  2. بناء تطبيق متكامل
  3. مراجعة المشروع وأفضل الممارسات
  4. المراقبة وتتبع الأخطاء في بيئة الإنتاج
← العودة إلى Next.js 15 Fullstack (App Router + Server Actions)