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
- Error grouping — Error yang sama dikelompokkan, tidak spam
- Breadcrumbs — Jejak aksi sebelum error (klik, navigasi, API call)
- Source maps — Lihat kode asli, bukan minified
- Release tracking — Tahu error muncul di release mana
- Performance monitoring — Deteksi slow API, slow query
Alternatif Sentry
- Bugsnag — Mirip Sentry, UI berbeda
- LogRocket — Session replay + error tracking
- Datadog — Full observability platform