Skip to content

Commit d026fdf

Browse files
betegonclaude
andcommitted
feat(init): add detect-sentry local-op for cross-language Sentry detection
The server's check-existing-sentry step was hardcoded for JS/TS only. This adds a detect-sentry local-op that delegates to the CLI's existing detectDsn() — which already scans source code, .env files, and env vars across all 140+ supported platforms. Closes getsentry/cli-init-api#30 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 915f2bc commit d026fdf

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/lib/init/local-ops.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { resolveOrgPrefetched } from "./prefetch.js";
2929
import type {
3030
ApplyPatchsetPayload,
3131
CreateSentryProjectPayload,
32+
DetectSentryPayload,
3233
DirEntry,
3334
FileExistsBatchPayload,
3435
ListDirPayload,
@@ -324,6 +325,8 @@ export async function handleLocalOp(
324325
return await applyPatchset(payload, options.dryRun);
325326
case "create-sentry-project":
326327
return await createSentryProject(payload, options);
328+
case "detect-sentry":
329+
return await detectSentry(payload);
327330
default:
328331
return {
329332
ok: false,
@@ -789,6 +792,30 @@ export async function detectExistingProject(cwd: string): Promise<{
789792
return null;
790793
}
791794

795+
async function detectSentry(
796+
payload: DetectSentryPayload
797+
): Promise<LocalOpResult> {
798+
try {
799+
const { detectDsn } = await import("../dsn/index.js");
800+
const dsn = await detectDsn(payload.cwd);
801+
802+
if (!dsn) {
803+
return { ok: true, data: { status: "none", signals: [] } };
804+
}
805+
806+
const signals = [
807+
`dsn: ${dsn.source}${dsn.sourcePath ? ` (${dsn.sourcePath})` : ""}`,
808+
];
809+
810+
return {
811+
ok: true,
812+
data: { status: "installed", signals, dsn: dsn.raw },
813+
};
814+
} catch {
815+
return { ok: true, data: { status: "none", signals: [] } };
816+
}
817+
}
818+
792819
async function createSentryProject(
793820
payload: CreateSentryProjectPayload,
794821
options: WizardOptions

src/lib/init/types.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export type LocalOpPayload =
2525
| FileExistsBatchPayload
2626
| RunCommandsPayload
2727
| ApplyPatchsetPayload
28-
| CreateSentryProjectPayload;
28+
| CreateSentryProjectPayload
29+
| DetectSentryPayload;
2930

3031
export type ListDirPayload = {
3132
type: "local-op";
@@ -91,6 +92,15 @@ export type CreateSentryProjectPayload = {
9192
};
9293
};
9394

95+
export type DetectSentryPayload = {
96+
type: "local-op";
97+
operation: "detect-sentry";
98+
/** Human-readable spinner hint from the server (≤ 120 chars, sensitive values redacted). */
99+
detail?: string;
100+
cwd: string;
101+
params: Record<string, never>;
102+
};
103+
94104
export type LocalOpResult = {
95105
ok: boolean;
96106
error?: string;

0 commit comments

Comments
 (0)