Skip to content

Commit 4a1b499

Browse files
Apply suggestions from code review
Co-authored-by: Katie Byers <lobsterkatie@gmail.com>
1 parent 96b9ce5 commit 4a1b499

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

packages/types/src/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export interface Options {
102102
normalizeDepth?: number;
103103

104104
/**
105-
* Maximum number of properties or elements that the normalization algorithm will output.
105+
* Maximum number of properties or elements that the normalization algorithm will output in any single array or object included in the normalized event.
106106
* Used when normalizing an event before sending, on all of the listed attributes:
107107
* - `breadcrumbs.data`
108108
* - `user`

packages/utils/src/object.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,20 +300,26 @@ function makeSerializable<T>(value: T, key?: any): T | string {
300300
return value;
301301
}
302302

303-
type UnknownMaybeToJson = unknown & { toJSON?: () => string };
303+
type UnknownMaybeWithToJson = unknown & { toJSON?: () => string };
304304

305305
/**
306-
* normalize()
306+
* Recursively normalizes the given object.
307307
*
308308
* - Creates a copy to prevent original input mutation
309-
* - Skip non-enumerable
310-
* - Calls `toJSON` if implemented
309+
* - Skips non-enumerable properties
310+
* - When stringifying, calls `toJSON` if implemented
311311
* - Removes circular references
312-
* - Translates non-serializable values (undefined/NaN/Functions) to serializable format
313-
* - Translates known global objects/Classes to a string representations
314-
* - Takes care of Error objects serialization
315-
* - Optionally limit depth of final output
316-
* - Optionally limit max number of properties/elements for each object/array
312+
* - Translates non-serializable values (`undefined`/`NaN`/functions) to serializable format
313+
* - Translates known global objects/classes to a string representations
314+
* - Takes care of `Error` object serialization
315+
* - Optionally limits depth of final output
316+
* - Optionally limits number of properties/elements included in any single object/array
317+
*
318+
* @param input The object to be normalized.
319+
* @param depth The max depth to which to normalize the object. (Anything deeper stringified whole.)
320+
* @param maxProperties The max number of elements or properties to be included in any single array or
321+
* object in the normallized output..
322+
* @returns A normalized version of the object, or `"**non-serializable**"` if any errors are thrown during normaliztion.
317323
*/
318324
export function normalize(input: unknown, depth: number = +Infinity, maxProperties: number = +Infinity): any {
319325
const [memoize, unmemoize] = memoBuilder();

0 commit comments

Comments
 (0)