rubis/apps/api/start/sentry.ts
ordinarthur e5530930b3
Some checks failed
Build & Deploy API / build-and-deploy (push) Failing after 17s
Build & Deploy Web / build-and-deploy (push) Successful in 1m15s
Build & Deploy Landing / build-and-deploy (push) Failing after 3m43s
feat: refactor frontend en stack React unifiée (Astro + packages/ui)
Trois surfaces partagent désormais le même design system, Tailwind v4
et React 19 — au lieu d'avoir landing en HTML vanilla, app en React, et
blog en Adonis SSR :

* packages/ui — design system partagé (tokens Tailwind v4 + composants
  TSX) extrait depuis apps/web : Brand, Gem, Button, Card, Chip, Eyebrow,
  EmptyState. apps/web migre 41 imports vers @rubis/ui.

* apps/landing — nouvelle app Astro 6 SSR (rubis.pro), remplace l'ancienne
  landing nginx vanilla. Embarque :
  - Landing complète portée en sections React (Hero, Stats, Promise,
    HowItWorks, Gamification, Legal, Pricing, FAQ, FinalCTA, Footnotes)
  - Pages légales (mentions, confidentialité, CGV) via LegalLayout.astro
  - Blog SSR (/blog, /blog/:slug) qui consomme /api/v1/posts
  - sitemap.xml, blog/rss.xml, robots.txt en endpoints Astro
  - SEO complet (canonical, hreflang, OG, Twitter Card, JSON-LD
    Article/BreadcrumbList/Blog/SoftwareApplication)

* apps/api — BlogController réduit à 2 endpoints JSON (GET /api/v1/posts
  + GET /api/v1/posts/:slug). Suppression des templates SSR Adonis
  (apps/api/app/blog/), de l'alias #blog/*, des deps react-dom et
  @types/react-dom. PostTransformer + PostSummaryTransformer ajoutés.
  Le service blog_renderer + le seeder + les 3 articles fondateurs
  restent intacts (réutilisés par futurs admin + cron IA).

* Infra :
  - Dockerfile.landing (multi-stage Node 22 + tini, Astro standalone)
  - k3s/app/landing.yml (Deployment + Service rubis-landing:4321 +
    ConfigMap avec API_URL=http://rubis-api.rubis.svc.cluster.local:3333)
  - .gitea/workflows/deploy.yml mis à jour pour build rubis-landing
  - .gitea/workflows/deploy-web.yml + Dockerfile.web : prennent en
    compte packages/ui/ comme dépendance
  - Suppression du Dockerfile nginx legacy + k3s/{deployment,service}.yml
  - Suppression de landing/ (assets favicons migrés vers
    apps/landing/public/)

* Docs : architecture.md (vue d'ensemble + §4bis apps/landing complet,
  §3 endpoints JSON blog, layout monorepo), CLAUDE.md (stack technique,
  documents associés, déploiement).

Note infra : l'ancien Deployment "rubis" (nginx) et son Service ne sont
PAS supprimés par la CI — à nettoyer manuellement après validation que
Traefik a été repointé sur rubis-landing:4321 dans le repo proxmox.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-09 15:09:13 +02:00

52 lines
1.8 KiB
TypeScript

/*
|--------------------------------------------------------------------------
| Sentry — error monitoring & performance
|--------------------------------------------------------------------------
|
| Init au plus tôt dans le boot (avant Ignitor) pour capturer aussi les
| erreurs de bootstrap. Lit `process.env` directement car le service Env
| d'Adonis n'est pas encore chargé à ce stade.
|
| Si SENTRY_DSN_API n'est pas défini (dev local typique), Sentry est
| simplement no-op — aucun appel réseau, et `@sentry/profiling-node`
| n'est PAS importé (l'import eager déclenche le chargement de la
| binary native CPU profiler, qui n'est pas dispo pour toutes les
| versions Node — ex. Node 25 sur darwin-arm64).
|
| Cf. ADR-024 — choix Sentry SaaS, free tier, 2 projects
| (rubis-api / rubis-web).
*/
import * as Sentry from '@sentry/node'
const dsn = process.env.SENTRY_DSN_API
const environment = process.env.NODE_ENV ?? 'development'
const release = process.env.APP_VERSION ?? 'dev'
if (dsn) {
// Import dynamique : on ne charge le binding C++ que quand on en a
// vraiment besoin (prod avec DSN). En dev, l'absence de binaire pour
// l'ABI Node courant n'est pas un problème.
const { nodeProfilingIntegration } = await import('@sentry/profiling-node')
Sentry.init({
dsn,
environment,
release,
// 10% en prod, 100% en dev pour debug
tracesSampleRate: environment === 'production' ? 0.1 : 1.0,
profilesSampleRate: 1.0,
integrations: [nodeProfilingIntegration()],
// Filtre les erreurs 4xx attendues, garde les 5xx
beforeSend(event, hint) {
const error = hint.originalException as { status?: number } | undefined
if (error?.status && error.status >= 400 && error.status < 500) {
return null
}
return event
},
})
}
export { Sentry }