o
    0 i                     @   s   d dl mZ d dlmZ d dlmZmZ z(d dlZd dlm	Z	m
Z
 er;d dlmZ d dlmZ d dlmZ d d	l mZ W n eyG   ed
w G dd deZG dd de	ZdS )    )TYPE_CHECKING)add_feature_flag)DidNotEnableIntegrationN)HookMetadata)LDClient)EvaluationSeriesContext)EvaluationDetail)AnyzLaunchDarkly is not installedc                   @   s&   e Zd ZdZdddZedd ZdS )LaunchDarklyIntegrationZlaunchdarklyNc              
   C   sZ   z|pt  }W n ty } ztdt| d}~ww | s%td|t  dS )z
        :param client: An initialized LDClient instance. If a client is not provided, this
            integration will attempt to use the shared global instance.
        z#Error getting LaunchDarkly client. Nz'LaunchDarkly client is not initialized.)ldclientget	Exceptionr   reprZis_initializedZadd_hookLaunchDarklyHook)selfZ	ld_clientclientexc r   p/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/sentry_sdk/integrations/launchdarkly.py__init__   s   z LaunchDarklyIntegration.__init__c                   C   s   d S Nr   r   r   r   r   
setup_once(   s   z"LaunchDarklyIntegration.setup_oncer   )__name__
__module____qualname__
identifierr   staticmethodr   r   r   r   r   r      s
    
r   c                   @   s(   e Zd Zedd Zdd Zdd ZdS )r   c                 C   s
   t ddS )Nzsentry-flag-auditor)name)r   )r   r   r   r   metadata/   s   
zLaunchDarklyHook.metadatac                 C   s   t |jtrt|j|j |S r   )
isinstancevalueboolr   key)r   series_contextdatadetailr   r   r   after_evaluation4   s   z!LaunchDarklyHook.after_evaluationc                 C   s   |S r   r   )r   r%   r&   r   r   r   before_evaluation;   s   z"LaunchDarklyHook.before_evaluationN)r   r   r   propertyr    r(   r)   r   r   r   r   r   .   s
    
r   )typingr   Zsentry_sdk.feature_flagsr   Zsentry_sdk.integrationsr   r   r   Zldclient.hookr   r   r   r	   Zldclient.evaluationr
   r   ImportErrorr   r   r   r   r   r   <module>   s"    