From f422fd6779c54be123f4ff69a3f59ab7654402ce Mon Sep 17 00:00:00 2001 From: Till JS Date: Thu, 7 May 2026 02:34:54 +0200 Subject: [PATCH] fix(shared-error-tracking): point main at src/, strip dashes from Glitchtip DSN MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two real-world fixes from wiring mana-auth to Glitchtip: 1. The compiled dist/ folder was excluded from Docker builds via .dockerignore's '**/dist' rule, so any container that pnpm-installed the package found node_modules/@mana/shared-error-tracking but no loadable entry point ('Cannot find module' at startup). Match the pattern shared-hono uses — point main + types + exports straight at src/*.ts. Bun runs TS natively and the type-only consumers don't care. 2. Glitchtip projects expose UUID-format public keys (`556fbd2e-a720-…`) in their generated DSNs. @sentry/node v9 tightened its DSN regex to alphanumeric-only, so it silently rejects the DSN with "Invalid Sentry Dsn" and never sends events. Strip the dashes from the user/key portion before handing it to Sentry — the Glitchtip ingest endpoint accepts both forms over the wire, so no server change. Plus the missing Dockerfile COPY lines for shared-error-tracking and eslint-config (root package.json devDeps reference the latter, which breaks pnpm-filter installs that don't include it in the build context). Verified end-to-end: 4 issues now in Glitchtip from mana-auth (2 manual probes + 1 captureException + 1 401 from a real /api/v1/me/data request without auth). Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/shared-error-tracking/package.json | 22 +++++---------------- packages/shared-error-tracking/src/index.ts | 12 +++++++++-- services/mana-auth/Dockerfile | 4 ++++ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/shared-error-tracking/package.json b/packages/shared-error-tracking/package.json index 53c1284da..a1a47922c 100644 --- a/packages/shared-error-tracking/package.json +++ b/packages/shared-error-tracking/package.json @@ -2,25 +2,13 @@ "name": "@mana/shared-error-tracking", "version": "1.0.0", "description": "Error tracking integration for Mana apps (GlitchTip/Sentry-compatible)", - "main": "dist/index.js", - "types": "dist/index.d.ts", + "main": "./src/index.ts", + "types": "./src/index.ts", "exports": { - ".": { - "types": "./dist/index.d.ts", - "default": "./dist/index.js" - }, - "./nestjs": { - "types": "./dist/nestjs.d.ts", - "default": "./dist/nestjs.js" - }, - "./browser": { - "types": "./dist/browser.d.ts", - "default": "./dist/browser.js" - } + ".": "./src/index.ts", + "./nestjs": "./src/nestjs.ts", + "./browser": "./src/browser.ts" }, - "files": [ - "dist" - ], "scripts": { "build": "tsc", "type-check": "tsc --noEmit" diff --git a/packages/shared-error-tracking/src/index.ts b/packages/shared-error-tracking/src/index.ts index 73f3877d2..ee6a9deb3 100644 --- a/packages/shared-error-tracking/src/index.ts +++ b/packages/shared-error-tracking/src/index.ts @@ -46,15 +46,23 @@ let initialized = false; export function initErrorTracking(options: ErrorTrackingOptions): void { if (initialized) return; - const dsn = options.dsn || process.env.GLITCHTIP_DSN || process.env.SENTRY_DSN; + const rawDsn = options.dsn || process.env.GLITCHTIP_DSN || process.env.SENTRY_DSN; - if (!dsn) { + if (!rawDsn) { if (options.debug) { console.log(`[ErrorTracking] No DSN configured for ${options.serviceName} - disabled`); } return; } + // Glitchtip projects use UUID-format public_keys (`556fbd2e-a720-...`) + // but @sentry/node v9's DSN parser only accepts alphanumeric — dashes + // trip "Invalid Sentry Dsn" and silently disable transport. Strip them + // from the user/key portion only; the wire format accepts both. + const dsn = rawDsn.replace(/^(https?:\/\/)([\w-]+)(@.+)$/, (_, proto, key, rest) => { + return proto + key.replace(/-/g, '') + rest; + }); + Sentry.init({ dsn, environment: options.environment || process.env.NODE_ENV || 'development', diff --git a/services/mana-auth/Dockerfile b/services/mana-auth/Dockerfile index 6390702b4..e9f945a9f 100644 --- a/services/mana-auth/Dockerfile +++ b/services/mana-auth/Dockerfile @@ -14,6 +14,10 @@ COPY packages/shared-ai ./packages/shared-ai COPY packages/shared-logger ./packages/shared-logger COPY packages/shared-types ./packages/shared-types COPY packages/shared-error-tracking ./packages/shared-error-tracking +# Root package.json devDeps reference @mana/eslint-config; pnpm filter +# install still resolves the root, so the package needs to be present +# even though mana-auth itself doesn't import from it. +COPY packages/eslint-config ./packages/eslint-config # Install only mana-auth and its workspace deps RUN pnpm install --filter @mana/auth... --no-frozen-lockfile --ignore-scripts