Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | 183x 183x 183x | /**
* DSN Types
*
* All types related to DSN parsing, detection, and caching.
*/
import { z } from "zod";
/**
* Source where DSN was detected from
*
* - env: SENTRY_DSN or framework-prefixed environment variable (e.g., NEXT_PUBLIC_SENTRY_DSN)
* - env_file: .env file
* - config: Language-specific config file (e.g., sentry.properties)
* - code: Source code patterns (e.g., Sentry.init)
* - inferred: Inferred from directory name matching project slugs
*/
export type DsnSource = "env" | "env_file" | "config" | "code" | "inferred";
/**
* Parsed DSN components
*
* DSN Format: {PROTOCOL}://{PUBLIC_KEY}@{HOST}/{PROJECT_ID}
* Example: https://abc123@o1169445.ingest.us.sentry.io/4505229541441536
*/
export type ParsedDsn = {
protocol: string;
publicKey: string;
host: string;
projectId: string;
/** Extracted from oXXX.ingest... pattern in host (SaaS only) */
orgId?: string;
};
/**
* Detected DSN with source information
*/
export type DetectedDsn = ParsedDsn & {
/** Original DSN string */
raw: string;
/** Where the DSN was found */
source: DsnSource;
/**
* Context-dependent source identifier:
* - For `"env"`: the env var name (e.g., `"NEXT_PUBLIC_SENTRY_DSN"`)
* - For `"env_file"`, `"config"`, `"code"`: file path relative to cwd
* - For `"inferred"`: undefined
*/
sourcePath?: string;
/** Package/app directory path for monorepo grouping (e.g., "packages/frontend", "apps/web") */
packagePath?: string;
/** Cached resolution info if available */
resolved?: ResolvedProjectInfo;
};
/** Resolved project information from Sentry API */
export type ResolvedProjectInfo = {
orgSlug: string;
orgName: string;
projectSlug: string;
projectName: string;
};
/** Full resolved project with DSN and source info */
export type ResolvedProject = ResolvedProjectInfo & {
dsn: DetectedDsn;
/** Human-readable description of where DSN was found */
sourceDescription: string;
};
/**
* Cached DSN entry with full resolution info
*
* Stored in ~/.sentry/cli.db in the dsn_cache table
*/
export type CachedDsnEntry = {
/** The raw DSN string */
dsn: string;
/** Project ID extracted from DSN */
projectId: string;
/** Org ID extracted from DSN (SaaS only) */
orgId?: string;
/** Where the DSN was found */
source: DsnSource;
/** Source identifier: env var name for `"env"`, relative file path for file-based sources */
sourcePath?: string;
/** Resolved project info (avoids API call on cache hit) */
resolved?: ResolvedProjectInfo;
/** All resolved targets (for inferred source with multiple matches) */
allResolved?: ResolvedProjectInfo[];
/** Timestamp when this entry was cached */
cachedAt: number;
};
/** Zod schema for ResolvedProjectInfo */
export const ResolvedProjectInfoSchema = z.object({
orgSlug: z.string(),
orgName: z.string(),
projectSlug: z.string(),
projectName: z.string(),
});
/** Zod schema for cached DSN entries (for config validation) */
export const CachedDsnEntrySchema = z.object({
dsn: z.string(),
projectId: z.string(),
orgId: z.string().optional(),
source: z.enum(["env", "env_file", "config", "code", "inferred"]),
sourcePath: z.string().optional(),
resolved: ResolvedProjectInfoSchema.optional(),
allResolved: z.array(ResolvedProjectInfoSchema).optional(),
cachedAt: z.number(),
});
/**
* Result of DSN detection with support for monorepos.
*
* In monorepos, multiple DSNs are valid (different packages/apps may have different Sentry projects).
* The `primary` DSN is always the first one found, and `all` contains every detected DSN.
*/
export type DsnDetectionResult = {
/** Primary DSN to use (first found, null only if none found) */
primary: DetectedDsn | null;
/** All detected DSNs across the codebase */
all: DetectedDsn[];
/** Whether multiple different DSNs were found (common in monorepos) */
hasMultiple: boolean;
/** Pre-computed fingerprint for alias validation (sorted org:project pairs) */
fingerprint: string;
/** Detected project language (for future use) */
language?: string;
};
/**
* Common monorepo root directories to scan for packages/apps with their own DSN.
* Used by both env-file detection and package path inference.
*/
export const MONOREPO_ROOTS = [
"packages",
"apps",
"libs",
"services",
"modules",
"projects",
"plugins",
"sites",
"workers",
"functions",
] as const;
|