Skip to content

feat(dsn): add multi-language DSN detection#12

Merged
betegon merged 3 commits intomainfrom
feat/dsn-auto-detection
Jan 16, 2026
Merged

feat(dsn): add multi-language DSN detection#12
betegon merged 3 commits intomainfrom
feat/dsn-auto-detection

Conversation

@betegon
Copy link
Member

@betegon betegon commented Jan 16, 2026

Summary

Extends DSN auto-detection to support 6 programming languages, not just JavaScript/TypeScript.

Changes

  • New LanguageDetector interface - Common type for all language-specific detectors
  • Unified scanner - Single glob scan dispatching to correct extractor by extension
  • 6 language detectors:
    • JavaScript/TypeScript (refactored to implement interface)
    • Python (sentry_sdk.init, SENTRY_DSN settings)
    • PHP (Sentry\init, DSN in config arrays)
    • Ruby (Sentry.init blocks, config.dsn)
    • Go (sentry.Init, sentry.ClientOptions)
    • Java/Kotlin (Sentry.init, setDsn, sentry.properties)
  • Comprehensive tests - 111 new test cases covering all languages

Architecture

src/lib/dsn/languages/
├── types.ts          # LanguageDetector interface
├── index.ts          # Registry + unified scanner
├── javascript.ts     # JS/TS detector
├── python.ts         # Python detector
├── php.ts            # PHP detector
├── ruby.ts           # Ruby detector
├── go.ts             # Go detector
└── java.ts           # Java/Kotlin detector

Each detector specifies:

  • name: Display name
  • extensions: File extensions to scan
  • skipDirs: Directories to ignore (e.g., node_modules, vendor)
  • extractDsn: Function to extract DSN from file content

Test Results

205 pass, 0 fail
281 expect() calls
14 test files

Add LanguageDetector interface and registry pattern for scanning
source code across multiple languages:
- JavaScript/TypeScript (refactored to implement interface)
- Python (sentry_sdk.init, SENTRY_DSN settings)
- PHP (Sentry\init, DSN in config arrays)
- Ruby (Sentry.init, config.dsn)
- Go (sentry.Init, sentry.ClientOptions)
- Java/Kotlin (Sentry.init, SentryOptions)

The unified scanner builds a combined glob from all detectors,
scans all files once, and dispatches to the correct extractor
based on file extension.
Add comprehensive test coverage for DSN extraction from:
- JavaScript/TypeScript (Sentry.init, config objects)
- Python (sentry_sdk.init, dict configs)
- PHP (Sentry\init, array configs)
- Ruby (Sentry.init blocks, hash configs)
- Go (struct fields, assignments)
- Java/Kotlin (setDsn, properties files)

Each test suite covers:
- Common SDK initialization patterns
- Generic config patterns
- Edge cases (env vars, empty content, no DSN)
- Detector configuration (extensions, skip dirs)
- Fix Go DSN_PATTERN_STRUCT to validate DSN format (https://, @)
- Remove invalid glob pattern '*.egg-info' from Python skipDirs
- Remove unused re-exports from languages/index.ts (fixes barrel file warning)
- Add proper JSDoc to shouldSkipPath and getDetectorForFile
@betegon betegon merged commit 1e0fc46 into main Jan 16, 2026
2 checks passed
@betegon betegon deleted the feat/dsn-auto-detection branch January 16, 2026 19:25
BYK added a commit that referenced this pull request Mar 4, 2026
…parallelize cleanup

Review Round 3 — 15 human review comments addressed:

#1: login.ts — Replace await .catch() with proper try/await/catch blocks
#2: whoami.ts + all commands — Export FRESH_ALIASES constant from list-command.ts
    to reduce boilerplate; update 15 command files to use it
#3: response-cache.ts — Bump immutable TTL from 1hr to 24hr (events/traces
    never change once created)
#4–6: response-cache.ts — Restructure URL_TIER_PATTERNS as Record<TtlTier, RegExp[]>,
    combine duplicate regex patterns into single alternations
#7: response-cache.ts — Replace localeCompare with simple < comparison for
    ASCII URL query param sorting
#8: response-cache.ts — Remove try-catch in normalizeUrl (URLs reaching the
    cache already came from a fetch, always valid)
#9: response-cache.ts — Link immutableMinTimeToLive to FALLBACK_TTL_MS.immutable
    instead of hardcoded magic number
#10: response-cache.ts — Use Object.fromEntries(headers.entries()) instead of
    manual forEach loop
#11: response-cache.ts — Remove unnecessary await on fire-and-forget unlink in
    catch block
#12: response-cache.ts — Add expiresAt field to CacheEntry for O(1) expiry
    checks during cleanup (no CachePolicy deserialization needed)
#13–15: response-cache.ts — Parallelize cache I/O (collectEntryMetadata,
    deleteExpiredEntries, evictExcessEntries) using p-limit-style concurrency
    limiter (max 8 concurrent)
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.

1 participant