Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
233 changes: 0 additions & 233 deletions .do/app.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ jobs:
run: vapor deploy ${{ env.VAPOR_ENV }}
env:
VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }}
SENTRY_RELEASE: ${{ github.sha }}

frontend:
name: Deploy Frontend
Expand Down
8 changes: 8 additions & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ CORS_ALLOWED_ORIGINS=*
LOG_CHANNEL=stderr
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
LOG_STACK=single

SENTRY_DSN=
SENTRY_ENVIRONMENT=
SENTRY_ENABLE_LOGS=false
SENTRY_LOG_LEVEL=info
SENTRY_RELEASE=
SENTRY_TRACES_SAMPLE_RATE=0

DB_CONNECTION=pgsql
DB_HOST=pgsql
Expand Down
7 changes: 6 additions & 1 deletion backend/config/logging.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
'channels' => array_values(array_filter(array_map('trim', explode(',', (string) env('LOG_STACK', 'single'))))) ?: ['single'],
'ignore_exceptions' => false,
],

Expand Down Expand Up @@ -118,6 +118,11 @@
'replace_placeholders' => true,
],

'sentry_logs' => [
'driver' => 'sentry_logs',
'level' => env('SENTRY_LOG_LEVEL', 'info'),
],

'null' => [
'driver' => 'monolog',
'handler' => NullHandler::class,
Expand Down
3 changes: 3 additions & 0 deletions backend/config/sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
// @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#send-default-pii
'send_default_pii' => env('SENTRY_SEND_DEFAULT_PII', false),

// @see: https://docs.sentry.io/platforms/php/guides/laravel/logs/
'enable_logs' => filter_var(env('SENTRY_ENABLE_LOGS', false), FILTER_VALIDATE_BOOLEAN),

// @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#ignore-exceptions
// 'ignore_exceptions' => [],

Expand Down
9 changes: 8 additions & 1 deletion frontend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@ VITE_API_URL_CLIENT=https://localhost:8443/api
VITE_API_URL_SERVER=http://backend:80/api

VITE_FRONTEND_URL=https://localhost:8443
VITE_STRIPE_PUBLISHABLE_KEY=pk_test_51Ofu1CJKnXOyGeQuDPUHiZcJxZozRuERiv4vQRBtCscwTbxOL574cxUjAoNRL2YLCumgC5160pl6kvTIiAc9mOeM0058KAWQ55
VITE_STRIPE_PUBLISHABLE_KEY=pk_test_51Ofu1CJKnXOyGeQuDPUHiZcJxZozRuERiv4vQRBtCscwTbxOL574cxUjAoNRL2YLCumgC5160pl6kvTIiAc9mOeM0058KAWQ55

SENTRY_SSR_DSN=
SENTRY_ENVIRONMENT=
SENTRY_ENABLE_LOGS=false
SENTRY_LOG_LEVEL=info
SENTRY_RELEASE=
SENTRY_TRACES_SAMPLE_RATE=0
2 changes: 1 addition & 1 deletion frontend/Dockerfile.ssr
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ WORKDIR /app

COPY --from=prod-deps /app/node_modules ./node_modules
COPY --from=build /app/dist ./dist
COPY package.json yarn.lock server.js ./
COPY package.json yarn.lock server.js instrument.mjs ./
COPY src ./src
COPY public ./public

Expand Down
54 changes: 54 additions & 0 deletions frontend/instrument.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import "dotenv/config";
import * as Sentry from "@sentry/node";

const LOG_SEVERITY_ORDER = ["trace", "debug", "info", "warn", "error", "fatal"];

const LOG_LEVEL_ALIASES = {
warning: "warn",
notice: "info",
critical: "fatal",
alert: "fatal",
emergency: "fatal",
};

const isTruthy = (value) => /^(1|true|yes|on)$/i.test(value ?? "");

const resolveMinimumSeverity = (value) => {
const normalised = LOG_LEVEL_ALIASES[String(value).toLowerCase()] ?? String(value).toLowerCase();
const index = LOG_SEVERITY_ORDER.indexOf(normalised);

return index === -1 ? LOG_SEVERITY_ORDER.indexOf("info") : index;
};

const dsn = process.env.SENTRY_SSR_DSN;

if (dsn) {
const environment = process.env.SENTRY_ENVIRONMENT;

if (!environment) {
console.warn(
`[sentry] SENTRY_ENVIRONMENT is not set, so events will be reported as "${process.env.NODE_ENV || "production"}". ` +
"Set it per deployment so staging and production stay separate."
);
}

const enableLogs = isTruthy(process.env.SENTRY_ENABLE_LOGS);
const minimumSeverity = resolveMinimumSeverity(process.env.SENTRY_LOG_LEVEL ?? "info");

Sentry.init({
dsn,
environment: environment || process.env.NODE_ENV || "production",
release: process.env.SENTRY_RELEASE,
enableLogs,
integrations: enableLogs ? [Sentry.consoleLoggingIntegration()] : [],
beforeSendLog: (log) => (LOG_SEVERITY_ORDER.indexOf(log.level) >= minimumSeverity ? log : null),
tracesSampleRate: Number(process.env.SENTRY_TRACES_SAMPLE_RATE) || 0,
dataCollection: {
userInfo: false,
cookies: false,
httpHeaders: { request: false, response: false },
httpBodies: [],
urlQueryParams: false,
},
});
}
5 changes: 3 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"build:csr": "vite build",
"build-strict:csr": "tsc && npm run build:csr",
"preview:csr": "vite preview",
"dev:ssr": "cross-env NODE_ENV=development node server.js --port 5678",
"dev:ssr": "cross-env NODE_ENV=development node --import ./instrument.mjs server.js --port 5678",
"build:ssr:client": "vite build --ssrManifest --outDir dist/client",
"build:ssr:server": "vite build --ssr src/entry.server.tsx --outDir dist/server",
"start": "cross-env NODE_ENV=production node server.js",
"start": "cross-env NODE_ENV=production node --import ./instrument.mjs server.js",
"build": "npm run messages:extract && npm run messages:compile && npm run build:ssr:client && npm run build:ssr:server",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"messages:extract": "lingui extract",
Expand Down Expand Up @@ -39,6 +39,7 @@
"@react-pdf/renderer": "^4.5.1",
"@react-router/node": "^7.1.5",
"@remix-run/node": "^2.16.8",
"@sentry/node": "^10.73.0",
"@stripe/react-stripe-js": "^2.1.1",
"@stripe/stripe-js": "^1.54.1",
"@tabler/icons-react": "^3.35.0",
Expand Down
Loading
Loading