Skip to content

feat: Sentry SDK の導入 - #489

Draft
Ojoxux wants to merge 2 commits into
mainfrom
cursor/sentry-sdk-integration-9850
Draft

feat: Sentry SDK の導入#489
Ojoxux wants to merge 2 commits into
mainfrom
cursor/sentry-sdk-integration-9850

Conversation

@Ojoxux

@Ojoxux Ojoxux commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Pull Request 概要

Sentry SDK を導入し、ブラウザ・API のエラーを環境変数経由で Sentry に送信できるようにする。DSN 未設定時は SDK を初期化せず、既存動作への影響を避ける。

テレメトリ基盤(createClientLogger)を含む。#487 と同一内容。

変更内容

  • apps/web@sentry/nextjs を追加(instrumentation、global-error、withSentryConfig)
  • apps/api@sentry/hono / @sentry/cloudflare を追加(Hono ミドルウェア、500 エラー送信)
  • packages/utilscreateLogger テレメトリ基盤を追加
  • apps/web/src/lib/telemetry にクライアント向けロガーと Sentry シンクを追加
  • .env.example に Sentry 関連の環境変数を追記(値は空欄)

動作確認

  1. DSN 未設定で npm run build --workspace=@sonory/web が成功すること
  2. DSN 未設定で npm run type-check --workspace=@sonory/api が成功すること
  3. マージ後、各自が環境変数を設定して staging でエラーが Sentry に届くことを確認(DSN の共有は不要)

環境変数の設定(マージ後・各自で実施)

  • ローカル: .envNEXT_PUBLIC_SENTRY_DSN
  • API: wrangler secret put SENTRY_DSN --env staging
  • Web (CF): NEXT_PUBLIC_SENTRY_DSN を wrangler vars またはダッシュボードで設定

関連Issue

レビューポイント

  • DSN がリポジトリに含まれていないこと
  • sendDefaultPii: false で位置情報等の自動送信を無効にしていること
  • 本番の tracesSampleRate が 0.1 であること
  • Sentry プロジェクト作成はレビュアー側で実施(DSN 共有不要)
Open in Web Open in Cursor 

Add shared createLogger utility and client-side telemetry sinks so
debug console.log can be replaced with environment-aware logging.
Sentry hooks are stubbed for web (window.Sentry) and API (SENTRY_DSN)
until DSN is configured. Document observability env vars in .env.example.
Add @sentry/nextjs with instrumentation hooks and global error boundary.
Add @sentry/hono middleware for the Cloudflare Workers API. DSN is read
only from environment variables so secrets stay out of the repository.
@Ojoxux Ojoxux changed the title feat: Sentry SDK 導入(DSN は環境変数のみ・共有不要) feat: Sentry SDK の導入 Jun 9, 2026
@cursor cursor Bot mentioned this pull request Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants