Repository navigation
feat(sentry): mulai Sentry backend sebelum Express dan aktifkan tracing browser - #6
Merged
Merged
Conversation
…tracing - backend/src/instrument.ts is now the first import in index.ts, so Sentry initializes before express, http and pg are required. Before this, errors reached Sentry through the error handler but request tracing recorded nothing because the instrumentation loaded after express. - The web app adds browserTracingIntegration and propagates traces to api.kaffepos.my.id when VITE_SENTRY_TRACES_SAMPLE_RATE > 0. The backend's CORS reflects requested headers, so sentry-trace and baggage pass preflight (checked against the live API). Verified with the new Sentry projects kaffe-pos/kaffepos-api and kaffe-pos/kaffepos-web: test errors KAFFEPOS-API-1 and KAFFEPOS-WEB-1 and a trace from each arrived. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ringkasan
Menyambungkan KaffePOS ke project Sentry baru (
kaffe-pos/kaffepos-webdankaffe-pos/kaffepos-api) dan memperbaiki tracing backend yang selama ini tidak merekam apa pun.Yang berubah
backend/src/instrument.tssekarang jadi import pertama dibackend/src/index.ts. Build backend memakai CommonJS, jadi urutan import adalah urutan load. SebelumnyainitBackendErrorTracking()dipanggil setelahexpressdimuat: error tetap masuk lewat error handler, tapi instrumentasi OpenTelemetry tidak sempat memasang hook ke express, http, dan pg, sehingga tracing kosong.src/lib/errorTracking.ts: saatVITE_SENTRY_TRACES_SAMPLE_RATE > 0, web memakaibrowserTracingIntegration()dan meneruskan trace keapi.kaffepos.my.id(tracePropagationTargets), sehingga satu request terlihat dari web sampai backend.Catatan untuk reviewer
sentry-tracedanbaggagelolos preflight. Sudah dicek dengan preflight sungguhan ke API live: 204 dengan header itu diizinkan.sendDefaultPiitetap mati. SDK tetap di versi 10 (@sentry/react10.51,@sentry/node10.62); upgrade major ke 11 bisa menyusul.SENTRY_DSN,SENTRY_ENVIRONMENT=staging, danSENTRY_TRACES_SAMPLE_RATE=0.1(API, runtime);VITE_SENTRY_DSNdanVITE_SENTRY_TRACES_SAMPLE_RATE=0.1(Web, build-time). Error dari production sudah masuk sebelum PR ini; tracing backend baru jalan setelah PR ini di-merge dan di-deploy.Tes
npm run check: lint, typecheck, 454 tes, build web dan backend: lolosPOST /api/auth/demo-logindan page load/kaffepos.my.idmasuk sebagai KAFFEPOS-WEB-2;system-statusmelaporkanbackendErrorTracking: true🤖 Generated with Claude Code