MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / sanitizeLogAttributes

Function sanitizeLogAttributes

packages/core/src/logs/internal.ts:235–246  ·  view source on GitHub ↗

* Sanitizes serialized log attributes by replacing lone surrogates in both * keys and string values with U+FFFD.

(attributes: Attributes)

Source from the content-addressed store, hash-verified

233 * keys and string values with U+FFFD.
234 */
235function sanitizeLogAttributes(attributes: Attributes): Attributes {
236 const sanitized: Attributes = {};
237 for (const [key, attr] of Object.entries(attributes)) {
238 const sanitizedKey = _removeLoneSurrogates(key);
239 if (attr.type === 'string') {
240 sanitized[sanitizedKey] = { ...attr, value: _removeLoneSurrogates(attr.value) };
241 } else {
242 sanitized[sanitizedKey] = attr;
243 }
244 }
245 return sanitized;
246}
247
248/**
249 * Replaces unpaired UTF-16 surrogates with U+FFFD (replacement character).

Callers 1

_INTERNAL_captureLogFunction · 0.85

Calls 2

_removeLoneSurrogatesFunction · 0.85
entriesMethod · 0.65

Tested by

no test coverage detected