Initial commit
This commit is contained in:
24
packages/core-shared/src/instrumentation/reported-flag.ts
Normal file
24
packages/core-shared/src/instrumentation/reported-flag.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
// Non-enumerable flag used by every ILogger implementation to skip
|
||||
// already-reported errors. The flag is non-enumerable so JSON.stringify
|
||||
// and {...err} spread won't surface it.
|
||||
|
||||
const REPORTED = "__sentryReported" as const;
|
||||
|
||||
export function isReported(err: unknown): boolean {
|
||||
return (
|
||||
err !== null &&
|
||||
typeof err === "object" &&
|
||||
Boolean((err as Record<string, unknown>)[REPORTED])
|
||||
);
|
||||
}
|
||||
|
||||
export function markReported(err: unknown): void {
|
||||
if (err !== null && typeof err === "object" && !isReported(err)) {
|
||||
Object.defineProperty(err, REPORTED, {
|
||||
value: true,
|
||||
enumerable: false,
|
||||
configurable: false,
|
||||
writable: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user