← Back
Editing: envelope.cpython-312.pyc
� ]*jz% � � � d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZm Z erd dlm Z mZmZm Z mZmZ d dlmZmZ dd�Z G d� d � Z G d � d� Z G d� d � Zy)� N)� TYPE_CHECKING)�Session)�capture_internal_exceptions� json_dumps)�Any�Dict�Iterator�List�Optional�Union)�Event�EventDataCategoryc �p � t | t � r| j dd� } t j | � S )N�utf-8�replace)� isinstance�bytes�decode�json�loads)�datas �B/opt/hc_python/lib/python3.12/site-packages/sentry_sdk/envelope.py� parse_jsonr s+ � ��$����{�{�7�I�.���:�:�d��� c �2 � e Zd ZdZ d dd�Zedefd�� Z dd�Z dd�Z dd�Z dd �Z dd �Z dd�Z dd�Z d d �Zd!d�Zd!d�Zd"d�Z d#d�Zdefd�Ze d$d�� Zededd fd�� Zdefd�Zy)%�Envelopea. Represents a Sentry Envelope. The calling code is responsible for adhering to the constraints documented in the Sentry docs: https://develop.sentry.dev/sdk/envelopes/#data-model. In particular, each envelope may have at most one Item with type "event" or "transaction" (but not both). N�returnc �p � |�t |� }|xs i | _ |� g }|| _ y t |� }|| _ y �N)�dict�headers�list�items)�selfr! r# s r �__init__zEnvelope.__init__ sC � � ���7�m�G��}�"����=��E� �� � ��K�E��� r c �z � dt | j � �ddj d� | j D � � �d�S )Nzenvelope with z items (z, c 3 �4 K � | ] }|j �� � y �wr )� data_category)�.0�xs r � <genexpr>z'Envelope.description.<locals>.<genexpr>/ s � �� �:�z�!�a�o�o�z�s ��))�lenr# �join�r$ s r �descriptionzEnvelope.description+ s/ � � �� � �O��I�I�:�t�z�z�:�:� � r c �P � | j t t |�� d�� � y )N�r �event��payload�type��add_item�Item� PayloadRef)r$ r3 s r � add_eventzEnvelope.add_event2 s � � � � �d�:�5�#9��H�Ir c �P � | j t t |�� d�� � y )Nr2 �transactionr4 r7 )r$ r= s r �add_transactionzEnvelope.add_transaction8 s � � � � �d�:�;�#?�m�T�Ur c �P � | j t t |�� d�� � y )Nr2 �profiler4 r7 )r$ r@ s r �add_profilezEnvelope.add_profile>