SizeBudgetSanitizer class

Limits the size of the UTF-8 encoded JSON object to maxBytes.

The largest optional values are replaced with overflowMarker first. If the markers do not fit, optional entries are removed. pinnedTopLevelKeys undergo the same trimming only after all optional entries are gone. A one-byte budget returns an empty map, the smallest JSON object (two bytes).

Implemented types
Available extensions

Constructors

SizeBudgetSanitizer({required int maxBytes, Set<String> pinnedTopLevelKeys = const {'exception', 'timestamp', 'fingerprints'}, String overflowMarker = '<redacted:size>'})
Creates a size budget sanitizer that trims payloads to maxBytes.

Properties

hashCode → int
The hash code for this object.
no setterinherited
maxBytes → int
Maximum payload size in UTF-8 bytes, including keys and JSON punctuation.
final
overflowMarker → String
Replacement for an oversized value when the marker fits.
final
pinnedTopLevelKeys → Set<String>
Top-level keys to retain as long as the budget allows.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sanitize(Map<String, dynamic> data) → Map<String, dynamic>
Returns a new sanitized map. The input is never mutated.
override
sanitizeEvent(ReportEvent event) → ReportEvent

Available on Sanitizer, provided by the ReportEventSanitizer extension

Returns a copy of event with the sanitized payload embedded.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited