MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / normalizeToSize

Function normalizeToSize

packages/core/src/utils/normalize.ts:65–80  ·  view source on GitHub ↗
(
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  object: { [key: string]: any },
  // Default Node.js REPL depth
  depth: number = 3,
  // 100kB, as 200kB is max payload size, so half sounds reasonable
  maxSize: number = 100 * 1024,
)

Source from the content-addressed store, hash-verified

63
64/** JSDoc */
65export function normalizeToSize<T>(
66 // eslint-disable-next-line @typescript-eslint/no-explicit-any
67 object: { [key: string]: any },
68 // Default Node.js REPL depth
69 depth: number = 3,
70 // 100kB, as 200kB is max payload size, so half sounds reasonable
71 maxSize: number = 100 * 1024,
72): T {
73 const normalized = normalize(object, depth);
74
75 if (jsonSize(normalized) > maxSize) {
76 return normalizeToSize(object, depth - 1, maxSize);
77 }
78
79 return normalized as T;
80}
81
82/**
83 * Visits a node to perform normalization on it

Callers 2

getExceptionFunction · 0.90
eventFromPlainObjectFunction · 0.85

Calls 2

jsonSizeFunction · 0.85
normalizeFunction · 0.70

Tested by

no test coverage detected