diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile index 201b2ce9..3ffede0d 100644 --- a/apps/api/Dockerfile +++ b/apps/api/Dockerfile @@ -15,8 +15,7 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile RUN apt-get update -qq && apt-get install -y ca-certificates && update-ca-certificates RUN pnpm install RUN --mount=type=secret,id=SENTRY_AUTH_TOKEN \ - SENTRY_AUTH_TOKEN="$(cat /run/secrets/SENTRY_AUTH_TOKEN)" \ - bash -c "if [ -z $SENTRY_AUTH_TOKEN ]; then pnpm run build:nosentry; else pnpm run build; fi" + bash -c 'export SENTRY_AUTH_TOKEN="$(cat /run/secrets/SENTRY_AUTH_TOKEN)"; if [ -z $SENTRY_AUTH_TOKEN ]; then pnpm run build:nosentry; else pnpm run build; fi' # Install packages needed for deployment diff --git a/apps/api/src/scraper/WebScraper/crawler.ts b/apps/api/src/scraper/WebScraper/crawler.ts index af3a9d69..02894cfc 100644 --- a/apps/api/src/scraper/WebScraper/crawler.ts +++ b/apps/api/src/scraper/WebScraper/crawler.ts @@ -267,9 +267,18 @@ export class WebCrawler { public filterURL(href: string, url: string): string | null { let fullUrl = href; if (!href.startsWith("http")) { - fullUrl = new URL(href, this.baseUrl).toString(); + try { + fullUrl = new URL(href, this.baseUrl).toString(); + } catch (_) { + return null; + } + } + let urlObj; + try { + urlObj = new URL(fullUrl); + } catch (_) { + return null; } - const urlObj = new URL(fullUrl); const path = urlObj.pathname; if (this.isInternalLink(fullUrl)) { // INTERNAL LINKS diff --git a/apps/api/src/services/sentry.ts b/apps/api/src/services/sentry.ts index 04a0b1e4..1292773a 100644 --- a/apps/api/src/services/sentry.ts +++ b/apps/api/src/services/sentry.ts @@ -1,14 +1,17 @@ // Import with `import * as Sentry from "@sentry/node"` if you are using ESM import * as Sentry from "@sentry/node"; import { nodeProfilingIntegration } from "@sentry/profiling-node"; +import { Logger } from "../lib/logger"; if (process.env.SENTRY_DSN) { + Logger.info("Setting up Sentry..."); Sentry.init({ dsn: process.env.SENTRY_DSN, integrations: [ nodeProfilingIntegration(), ], - tracesSampleRate: 1.0, + tracesSampleRate: 0.045, profilesSampleRate: 1.0, + serverName: process.env.FLY_MACHINE_ID, }); } diff --git a/apps/api/tsconfig.json b/apps/api/tsconfig.json index 239d9b3a..dd7f0ed2 100644 --- a/apps/api/tsconfig.json +++ b/apps/api/tsconfig.json @@ -17,12 +17,7 @@ "*": ["node_modules/*", "src/types/*"], }, - "inlineSources": true, - - // Set `sourceRoot` to "/" to strip the build path prefix - // from generated source code references. - // This improves issue grouping in Sentry. - "sourceRoot": "/" + "inlineSources": true }, "include": ["src/","src/**/*", "services/db/supabase.ts", "utils/utils.ts", "services/db/supabaseEmbeddings.ts", "utils/EventEmmitter.ts", "src/services/queue-service.ts"] }