Error Tracking (Sentry) — DevOps

Mengapa Perlu Error Tracking? Log file saja tidak cukup — kamu butuh tool yang bisa mengelompokkan error, menunjukkan stacktrace, dan memberi notifikasi saat er

Mengapa Perlu Error Tracking?

Log file saja tidak cukup — kamu butuh tool yang bisa mengelompokkan error, menunjukkan stacktrace, dan memberi notifikasi saat error baru muncul.

Sentry

Sentry adalah platform error tracking paling populer. Free tier cukup untuk project kecil-menengah.

Setup Sentry di React

// npm install @sentry/react
import * as Sentry from "@sentry/react";

Sentry.init({
  dsn: "https://[email protected]/123",
  environment: import.meta.env.MODE,
  tracesSampleRate: 0.1,    // 10% transactions untuk performance
});

// Error otomatis ter-capture
// Atau manual:
try {
  riskyOperation();
} catch (error) {
  Sentry.captureException(error, {
    tags: { feature: "checkout" },
    extra: { orderId: 123 },
  });
}

Setup Sentry di Laravel

# composer require sentry/sentry-laravel
# .env
SENTRY_LARAVEL_DSN=https://[email protected]/456

// app/Exceptions/Handler.php sudah otomatis report
// Manual capture:
\Sentry\captureException($exception);
\Sentry\captureMessage("Something happened");

Fitur Penting Sentry

Alternatif Sentry

Yang akan kamu pelajari