feat(core-testing): R49 guard — block real Sentry SDK init in test processes
This commit is contained in:
@@ -1,8 +1,24 @@
|
||||
import type {
|
||||
ILogger,
|
||||
Breadcrumb,
|
||||
CaptureContext,
|
||||
} from "@repo/core-shared/instrumentation";
|
||||
// Local type aliases matching the contracts in @repo/core-shared/instrumentation.
|
||||
// Kept inline to avoid a build-graph cycle between core-testing and core-shared.
|
||||
type Breadcrumb = {
|
||||
category: string;
|
||||
message: string;
|
||||
level?: "info" | "warning" | "error";
|
||||
data?: Record<string, unknown>;
|
||||
};
|
||||
|
||||
type CaptureContext = {
|
||||
tags?: Record<string, string>;
|
||||
extras?: Record<string, unknown>;
|
||||
fingerprint?: string[];
|
||||
};
|
||||
|
||||
interface ILogger {
|
||||
captureException(err: unknown, ctx?: CaptureContext): void;
|
||||
captureMessage(msg: string, level?: "info" | "warning" | "error", ctx?: CaptureContext): void;
|
||||
addBreadcrumb(b: Breadcrumb): void;
|
||||
setUser(user: { id: string } | null): void;
|
||||
}
|
||||
|
||||
export type RecordedCapture =
|
||||
| { kind: "exception"; err: unknown; ctx?: CaptureContext }
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
import type {
|
||||
ITracer,
|
||||
ISpan,
|
||||
SpanOpts,
|
||||
AttributeValue,
|
||||
} from "@repo/core-shared/instrumentation";
|
||||
// Local type aliases matching the contracts in @repo/core-shared/instrumentation.
|
||||
// Kept inline to avoid a build-graph cycle between core-testing and core-shared.
|
||||
type AttributeValue = string | number | boolean | null;
|
||||
|
||||
type SpanOpts = {
|
||||
name: string;
|
||||
op?: string;
|
||||
attributes?: Record<string, AttributeValue>;
|
||||
};
|
||||
|
||||
interface ISpan {
|
||||
setAttribute(key: string, value: AttributeValue): void;
|
||||
setStatus(status: "ok" | "error", message?: string): void;
|
||||
}
|
||||
|
||||
interface ITracer {
|
||||
startSpan<T>(opts: SpanOpts, fn: (span: ISpan) => Promise<T>): Promise<T>;
|
||||
}
|
||||
|
||||
export type RecordedSpan = {
|
||||
name: string;
|
||||
@@ -14,6 +26,7 @@ export type RecordedSpan = {
|
||||
durationMs: number;
|
||||
};
|
||||
|
||||
// Exported so callers can use it as a compatible ITracer via structural typing.
|
||||
export class RecordingTracer implements ITracer {
|
||||
spans: RecordedSpan[] = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user