module documentation

Undocumented

Function sanitize_properties Sanitize event properties before emitting telemetry.
Constant DEFAULT_BLOCKED_KEYS Undocumented
Constant DEFAULT_REDACT_KEYS Undocumented
Constant MAX_MAPPING_ITEMS Undocumented
Constant MAX_SEQUENCE_ITEMS Undocumented
Function _safe_mapping Serialize a mapping while redacting nested secrets.
Function _safe_serialize Convert values into a safe, JSON-friendly representation.
Function _safe_string Keep enum-like strings while redacting risky free-form values.
Function _should_block_key Return True for keys that are forbidden in coarse telemetry.
Function _should_redact Return True if the key should be redacted.
Function _truncate Truncate long strings to keep payload size reasonable.
Constant _EMAIL_PATTERN Undocumented
Constant _PATH_PATTERN Undocumented
Constant _URL_PATTERN Undocumented
def sanitize_properties(properties: Mapping[str, Any] | None, *, allowlist: set[str] | None = None, redact_keys: set[str] | None = None) -> dict[str, Any]:

Sanitize event properties before emitting telemetry.

Applies an allowlist, redacts secret-like keys, and converts values to JSON-friendly types.

Parameters
properties:Mapping[str, Any] | NoneInput properties to sanitize.
allowlist:set[str] | NoneIf set, only these keys are included.
redact_keys:set[str] | NoneKey substrings that should be redacted.
Returns
dict[str, Any]The sanitized property mapping.
DEFAULT_BLOCKED_KEYS: set[str] =

Undocumented

Value
set(['account_id',
     'anonymous_analytics_id',
     'app_id',
     'device_id',
     'email',
     'file_path',
     'hostname',
...
DEFAULT_REDACT_KEYS: set[str] =

Undocumented

Value
set(['password',
     'passwd',
     'secret',
     'token',
     'api_key',
     'apikey',
     'api-key',
...
MAX_MAPPING_ITEMS: int =

Undocumented

Value
50
MAX_SEQUENCE_ITEMS: int =

Undocumented

Value
20
def _safe_mapping(value: Mapping[Any, Any], *, redact_keys: set[str]) -> dict[str, Any]:

Serialize a mapping while redacting nested secrets.

def _safe_serialize(value: Any, *, redact_keys: set[str]) -> Any:

Convert values into a safe, JSON-friendly representation.

def _safe_string(value: str) -> str:

Keep enum-like strings while redacting risky free-form values.

def _should_block_key(key: str) -> bool:

Return True for keys that are forbidden in coarse telemetry.

def _should_redact(key: str, redact_keys: set[str]) -> bool:

Return True if the key should be redacted.

def _truncate(value: str, limit: int = 200) -> str:

Truncate long strings to keep payload size reasonable.

_EMAIL_PATTERN =

Undocumented

Value
re.compile(r'^[^@\s]+@[^@\s]+\.[^@\s]+$')
_PATH_PATTERN =

Undocumented

Value
re.compile(r'^(?:~?/|\.{1,2}/|[a-zA-Z]:[\\/]|/|\\\\)')
_URL_PATTERN =

Undocumented

Value
re.compile(r'^(?:[a-z][a-z0-9\+\.-]*://|www\.)',
           re.IGNORECASE)