
    jKj                     	   d dl Z d dlmZmZmZmZmZmZ d dlm	Z	 d dl
mZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlm Z! d dlm"Z# d dlm$Z% d dlm&Z' d dlm(Z) d dlm*Z+ d dl,m-Z-m.Z.m/Z/m0Z0 d dl1m2Z2 d dl3m4Z4 d dl3m5Z5 d dl6m7Z7m8Z8 d dl9m:Z:m;Z;m<Z<m=Z= d dl>m?Z?m@Z@mAZAmBZB d dl>mCZC d dlDmEZE eEZF	 	 	 	 dddeGdeeG   dee   fd ZdedeeG   fd!Zd"eHfd#Z&d$eHfd%Z$d&eHfd'Zd(eGfd)Zd*eIeH   fd+Zd,eIeH   fd-Zd(eGfd.Z d(eGfd/Z"d0eHd1efd2Z(d3eeHef   fd4Z*	 dZJdZKdZLdZMd5ZNdZOdZPdZQdZRd6ZSd5ZTd5ZUd7ZVd8ZWdZXdZYdZZdZ[dZ\dZ]d5Z^dZ_da`dZae/Zbe.Zce0Zde-ZedZfdZgej                  Ziej                  Zkej                  Zmd9eHd:e	e   d3eeH   fd;Znd:e	e   d3eeH   fd<Zod:e	e   d3eeH   fd=Zp	 	 	 	 	 dfd>eHd?eHd@eeeHef      dAee j                      dBeeH   dCeeG   d&ee   d3eeH   fdDZq	 	 	 dgdEeHd&eHdAee j                      dBeeH   dCeeG   d3eeH   fdFZr	 dhdGee   d:e	e   d3eeH   fdHZs	 	 	 	 	 	 	 didIeHd&edJeeeHeeHetf   f      dKeeeHef      dLeeeHeeHef   f      dMeGdNeGdCeeG   d$eeH   d3eeG   fdOZu	 	 	 	 	 	 	 didIeHd&edJeeeHeeHetf   f      dKeeeHef      dLeeeHeeHef   f      dMeGdNeGdCeeG   d$eeH   d3eeA   fdPZv	 	 	 	 	 	 	 djd&edJeeeHeeHetf   f      dKeeeHef      dLeeeHeeHef   f      dMeGdCeeG   d$eeH   dQeeIeH      d3eeweHeAf      fdRZx	 	 	 	 	 	 	 didIeHd&edJeeeHeeHetf   f      dKeeeHef      dLeeeHeeHef   f      dMeGdNeGdCeeG   d$eeH   d3eeC   fdSZy	 	 	 	 	 	 	 	 dkdIeHd&edTeeA   dJeeeHeeHetf   f      dKeeeHef      dLeeeHeeHef   f      dMeGdNeGdCeeG   d$eeH   d3eez   fdUZ{dIeHfdVZ|	 	 	 	 	 	 	 djd&edJeeeHeeHetf   f      dKeeeHef      dLeeeHeeHef   f      dMeGdCeeG   d$eeH   dQeeIeH      d3eBfdWZ}	 	 	 	 	 	 	 	 dld&ee   dJeeeHeeHetf   f      dKeeeHef      dLeeeHeeHef   f      dMeGdCeeG   dXeeIeH      d$eeH   d3e2fdYZ~dZ Zd[ Zdmd\ee   d3dfd]Zdnd^Zdnd_Zd3efd`Zda Z G db dce      Zy)o    N)AnyCallableDictMappingOptionalUnion)Unpack)ID_TYPESExceptionArgOptionalCaptureArgsOptionalSetArgs)Client)ExceptionCapture)identify_context)new_context)scoped),set_capture_exception_code_variables_context)*set_code_variables_ignore_patterns_context)(set_code_variables_mask_patterns_context)/set_code_variables_mask_url_credentials_context))set_code_variables_detect_secrets_context)set_context_device_id)set_context_session)tag)get_tags)%DEFAULT_CODE_VARIABLES_DETECT_SECRETS&DEFAULT_CODE_VARIABLES_IGNORE_PATTERNS$DEFAULT_CODE_VARIABLES_MASK_PATTERNS+DEFAULT_CODE_VARIABLES_MASK_URL_CREDENTIALS)FeatureFlagEvaluations)InconclusiveMatchError)RequiresServerEvaluation)FlagDefinitionCacheDataFlagDefinitionCacheProvider)disable_connection_reuseenable_keep_aliveset_socket_optionsSocketOptions)BeforeSendCallbackFeatureFlag	FlagValueFlagsAndPayloads)FeatureFlagResult)VERSIONFfreshcapture_exceptionsclientc                     t        | ||      S )a  
    Create a new context scope that will be active for the duration of the with block.

    Args:
        fresh: Whether to start with a fresh context (default: False)
        capture_exceptions: Whether to capture exceptions raised within the context. If omitted, defaults to the relevant client's exception autocapture setting.
        client: Optional Posthog client instance to use for this context (default: None)

    Examples:
        ```python
        from posthog import new_context, tag, capture
        with new_context():
            tag("request_id", "123")
            capture("event_name", properties={"property": "value"})
        ```

    Category:
        Contexts
    r/   r0   r1   )inner_new_contextr3   s      a/Users/ahmed/devFolder/Ultron/claude-voice/.venv/lib/python3.12/site-packages/posthog/__init__.pyr   r   [   s    0 (:6     c                     t        | |      S )a>  
    Decorator that creates a new context for the function.

    Args:
        fresh: Whether to start with a fresh context (default: False)
        capture_exceptions: Whether to capture and track exceptions with posthog error tracking. If omitted, defaults to the global exception autocapture setting.

    Examples:
        ```python
        from posthog import scoped, tag, capture
        @scoped()
        def process_payment(payment_id):
            tag("payment_id", payment_id)
            capture("payment_started")
        ```

    Category:
        Contexts
    r/   r0   )inner_scopedr8   s     r5   r   r   x   s    ( e8JKKr6   
session_idc                     t        |       S )aB  
    Set the session ID for the current context.

    Args:
        session_id: The session ID to associate with the current context and its children

    Examples:
        ```python
        from posthog import set_context_session
        set_context_session("session_123")
        ```

    Category:
        Contexts
    )inner_set_context_session)r:   s    r5   r   r      s      %Z00r6   	device_idc                     t        |       S )a  
    Set the device ID for the current context, associating all feature flag requests
    in this or child contexts with the given device ID.

    Args:
        device_id: The device ID to associate with the current context and its children

    Examples:
        ```python
        from posthog import set_context_device_id
        set_context_device_id("device_123")
        ```

    Category:
        Contexts
    )inner_set_context_device_id)r=   s    r5   r   r      s    " 'y11r6   distinct_idc                     t        |       S )aF  
    Identify the current context with a distinct ID.

    Args:
        distinct_id: The distinct ID to associate with the current context and its children

    Examples:
        ```python
        from posthog import identify_context
        identify_context("user_123")
        ```

    Category:
        Identification
    )inner_identify_context)r@   s    r5   r   r      s      "+..r6   enabledc                     t        |       S )z
    Override code-variable capture for exceptions in the current context.

    Args:
        enabled: Whether exceptions captured in this context should include local
            variable values from stack frames.

    Category:
        Contexts
    )2inner_set_capture_exception_code_variables_contextrC   s    r5   r   r      s     >gFFr6   mask_patternsc                     t        |       S )a	  
    Override code-variable mask patterns for exceptions in the current context.

    Args:
        mask_patterns: Variable-name patterns whose values should be replaced
            with ``***`` when code variables are captured.

    Category:
        Contexts
    ).inner_set_code_variables_mask_patterns_context)rG   s    r5   r   r      s     :-HHr6   ignore_patternsc                     t        |       S )a   
    Override code-variable ignore patterns for exceptions in the current context.

    Args:
        ignore_patterns: Variable-name patterns that should be omitted entirely
            when code variables are captured.

    Category:
        Contexts
    )0inner_set_code_variables_ignore_patterns_context)rJ   s    r5   r   r      s     <OLLr6   c                     t        |       S )z
    Whether to scrub credentials embedded in URLs/DSNs (e.g. user:pass@host) from
    captured code variables for the current context.
    )5inner_set_code_variables_mask_url_credentials_contextrF   s    r5   r   r      s    
 AIIr6   c                     t        |       S )z
    Whether to apply entropy-based secret detection as a last-resort redaction of
    high-entropy values (API keys, tokens, strong passwords) in captured code
    variables for the current context.

    Category:
        Contexts
    )/inner_set_code_variables_detect_secrets_contextrF   s    r5   r   r      s     ;7CCr6   namevaluec                     t        | |      S )z
    Add a tag to the current context.

    Args:
        name: The tag key
        value: The tag value

    Examples:
        ```python
        from posthog import tag
        tag("user_id", "123")
        ```

    Category:
        Contexts
    )	inner_tag)rQ   rR   s     r5   r   r     s    " T5!!r6   returnc                      t               S )z
    Get all tags from the current context.

    Returns:
        Dict of all tags in the current context

    Category:
        Contexts
    )inner_get_tags r6   r5   r   r     s     r6   T         eventkwargsc                     t        d| fi |S )a  
    Capture anything a user does within your system.

    Args:
        event: The event name to specify the event
        **kwargs: Optional arguments including:
            distinct_id: Unique identifier for the user
            properties: Dict of event properties
            timestamp: When the event occurred
            uuid: Unique identifier for this event. If omitted, one is generated
                and returned. If provided, it must be a valid UUID string or
                uuid.UUID instance; invalid values are ignored and replaced with
                a newly generated UUID.
            groups: Dict of group types and IDs
            flags: A FeatureFlagEvaluations snapshot from evaluate_flags(). The
                exact values from the snapshot are attached with no extra /flags
                request.
            send_feature_flags: Deprecated. Prefer flags=... from
                evaluate_flags(). When truthy, evaluates flags during capture and
                attaches them to the event.
            disable_geoip: Whether to disable GeoIP lookup

    Details:
        Capture allows you to capture anything a user does within your system, which you can later use in PostHog to find patterns in usage, work out which features to improve or where people are giving up. A capture call requires an event name to specify the event. We recommend using [verb] [noun], like `movie played` or `movie updated` to easily identify what your events mean later on. Capture takes a number of optional arguments, which are defined by the `OptionalCaptureArgs` type.

    Examples:
        ```python
        # Context and capture usage
        from posthog import new_context, identify_context, tag_context, capture
        # Enter a new context (e.g. a request/response cycle, an instance of a background job, etc)
        with new_context():
            # Associate this context with some user, by distinct_id
            identify_context('some user')

            # Capture an event, associated with the context-level distinct ID ('some user')
            capture('movie started')

            # Capture an event associated with some other user (overriding the context-level distinct ID)
            capture('movie joined', distinct_id='some-other-user')

            # Capture an event with some properties
            capture('movie played', properties={'movie_id': '123', 'category': 'romcom'})

            # Capture an event with some properties
            capture('purchase', properties={'product_id': '123', 'category': 'romcom'})
            # Capture an event with some associated group
            capture('purchase', groups={'company': 'id:5'})

            # Adding a tag to the current context will cause it to appear on all subsequent events
            tag_context('some-tag', 'some-value')

            capture('another-event') # Will be captured with `'some-tag': 'some-value'` in the properties dict
        ```
        ```python
        # Set event properties
        from posthog import capture
        capture(
            "user_signed_up",
            distinct_id="distinct_id_of_the_user",
            properties={
                "login_type": "email",
                "is_free_trial": "true"
            }
        )
        ```
    Category:
        Events
    capture_proxy)r\   r]   s     r5   r_   r_     s    L )U-f--r6   c                      t        di | S )a  
    Set properties on a user record.

    Args:
        **kwargs: Optional arguments including:
            distinct_id: Unique identifier for the user. Falls back to the
                context distinct ID; if none exists, this call does nothing.
            properties: Dict of person properties to set.
            timestamp: When the properties were set.
            uuid: Unique identifier for this operation. If omitted, one is
                generated and returned. If provided, it must be a valid UUID
                string or uuid.UUID instance; invalid values are ignored and
                replaced with a newly generated UUID.
            disable_geoip: Whether to disable GeoIP lookup.

    Details:
        This will overwrite previous people property values. Generally operates similar to `capture`, with distinct_id being an optional argument, defaulting to the current context's distinct ID. If there is no context-level distinct ID, and no override distinct_id is passed, this function will do nothing. Context tags are folded into $set properties, so tagging the current context and then calling `set` will cause those tags to be set on the user (unlike capture, which causes them to just be set on the event).

    Examples:
        ```python
        # Set person properties
        from posthog import set
        set(distinct_id='distinct_id', properties={'name': 'Max Hedgehog'})
        ```
    Category:
        Identification
    )setr`   r]   s    r5   rc   rc     s    : "6""r6   c                      t        di | S )ac  
    Set properties on a user record, only if they do not yet exist.

    Args:
        **kwargs: Optional arguments including:
            distinct_id: Unique identifier for the user. Falls back to the
                context distinct ID; if none exists, this call does nothing.
            properties: Dict of person properties to set only once.
            timestamp: When the properties were set.
            uuid: Unique identifier for this operation. If omitted, one is
                generated and returned. If provided, it must be a valid UUID
                string or uuid.UUID instance; invalid values are ignored and
                replaced with a newly generated UUID.
            disable_geoip: Whether to disable GeoIP lookup.

    Details:
        This will not overwrite previous people property values, unlike `set`. Otherwise, operates in an identical manner to `set`.

    Examples:
        ```python
        # Set property once
        from posthog import set_once
        set_once(distinct_id='distinct_id', properties={'initial_url': '/blog'})

        ```
    Category:
        Identification
    )set_oncer`   rd   s    r5   rf   rf     s    : '''r6   
group_type	group_key
properties	timestampuuiddisable_geoipc           
      (    t        d| ||||||      S )a  
    Set properties on a group.

    Args:
        group_type: Type of your group
        group_key: Unique identifier of the group
        properties: Properties to set on the group
        timestamp: Optional timestamp for the event
        uuid: Optional UUID for the event
        disable_geoip: Whether to disable GeoIP lookup
        distinct_id: Optional distinct ID of the user performing the action

    Examples:
        ```python
        # Group identify
        from posthog import group_identify
        group_identify('company', 'company_id_in_your_db', {
            'name': 'Awesome Inc.',
            'employees': 11
        })
        ```
    Category:
        Identification
    group_identifyrg   rh   ri   rj   rk   rl   r@   r`   ro   s          r5   rn   rn     s*    D #	 	r6   previous_idc                 $    t        d| ||||      S )a  
    Associate user behaviour before and after they e.g. register, login, or perform some other identifying action.

    Args:
        previous_id: The unique ID of the user before
        distinct_id: The current unique id
        timestamp: Optional timestamp for the event
        uuid: Optional UUID for the event
        disable_geoip: Whether to disable GeoIP lookup

    Details:
        To marry up whatever a user does before they sign up or log in with what they do after you need to make an alias call. This will allow you to answer questions like "Which marketing channels leads to users churning after a month?" or "What do users do on our website before signing up?". Particularly useful for associating user behaviour before and after they e.g. register, login, or perform some other identifying action.

    Examples:
        ```python
        # Alias user
        from posthog import alias
        alias(previous_id='distinct_id', distinct_id='alias_id')
        ```
    Category:
        Identification
    aliasrp   r@   rj   rk   rl   r`   rs   s        r5   rr   rr   L  s#    < # r6   	exceptionc                     t        dd| i|S )aE  
    Capture exceptions that happen in your code.

    Args:
        exception: The exception to capture. If not provided, the current exception is captured via `sys.exc_info()`
        **kwargs: Optional capture arguments including distinct_id, properties,
            timestamp, uuid, groups, flags, send_feature_flags, and disable_geoip.

    Details:
        Capture exception is idempotent - if it is called twice with the same exception instance, only a occurrence will be tracked in posthog. This is because, generally, contexts will cause exceptions to be captured automatically. However, to ensure you track an exception, if you catch and do not re-raise it, capturing it manually is recommended, unless you are certain it will have crossed a context boundary (e.g. by existing a `with posthog.new_context():` block already). If the passed exception was raised and caught, the captured stack trace will consist of every frame between where the exception was raised and the point at which it is captured (the "traceback"). If the passed exception was never raised, e.g. if you call `posthog.capture_exception(ValueError("Some Error"))`, the stack trace captured will be the full stack trace at the moment the exception was captured. Note that heavy use of contexts will lead to truncated stack traces, as the exception will be captured by the context entered most recently, which may not be the point you catch the exception for the final time in your code. It's recommended to use contexts sparingly, for this reason. `capture_exception` takes the same set of optional arguments as `capture`.

    Examples:
        ```python
        # Capture exception
        from posthog import capture_exception
        try:
            risky_operation()
        except Exception as e:
            capture_exception(e)
        ```
    Category:
        Events
    rt   )capture_exceptionr`   )rt   r]   s     r5   rv   rv   t  s    8 EEfEEr6   keygroupsperson_propertiesgroup_propertiesonly_evaluate_locallysend_feature_flag_eventsc	                 D    t        d| ||xs i |xs i |xs i ||||
      S )a*  
    Use feature flags to enable or disable features for users.

    Args:
        key: The feature flag key
        distinct_id: The user's distinct ID
        groups: Groups mapping
        person_properties: Person properties
        group_properties: Group properties
        only_evaluate_locally: Whether to evaluate only locally
        send_feature_flag_events: Whether to send feature flag events
        disable_geoip: Whether to disable GeoIP lookup
        device_id: Optional device ID override for experience-continuity flags

    Details:
        You can call `posthog.load_feature_flags()` before to make sure you're not doing unexpected requests.

    Examples:
        ```python
        # Boolean feature flag
        from posthog import feature_enabled, get_feature_flag_payload
        is_my_flag_enabled = feature_enabled('flag-key', 'distinct_id_of_your_user')
        if is_my_flag_enabled:
            matched_flag_payload = get_feature_flag_payload('flag-key', 'distinct_id_of_your_user')
        ```
    Category:
        Feature flags
    feature_enabled	rw   r@   rx   ry   rz   r{   r|   rl   r=   r`   r   s	            r5   r~   r~     s>    N |+1r)/R3!9# r6   c	                 D    t        d| ||xs i |xs i |xs i ||||
      S )a  
    Get feature flag variant for users. Used with experiments.

    Args:
        key: The feature flag key
        distinct_id: The user's distinct ID
        groups: Groups mapping from group type to group key
        person_properties: Person properties
        group_properties: Group properties in format { group_type_name: { group_properties } }
        only_evaluate_locally: Whether to evaluate only locally
        send_feature_flag_events: Whether to send feature flag events
        disable_geoip: Whether to disable GeoIP lookup
        device_id: Optional device ID override for experience-continuity flags

    Details:
        `groups` are a mapping from group type to group key. So, if you have a group type of "organization" and a group key of "5", you would pass groups={"organization": "5"}. `group_properties` take the format: { group_type_name: { group_properties } }. So, for example, if you have the group type "organization" and the group key "5", with the properties name, and employee count, you'll send these as: group_properties={"organization": {"name": "PostHog", "employees": 11}}.

    Examples:
        ```python
        # Multivariate feature flag
        from posthog import get_feature_flag, get_feature_flag_payload
        enabled_variant = get_feature_flag('flag-key', 'distinct_id_of_your_user')
        if enabled_variant == 'variant-key':
            matched_flag_payload = get_feature_flag_payload('flag-key', 'distinct_id_of_your_user')
        ```
    Category:
        Feature flags
    get_feature_flagr   r`   r   s	            r5   r   r     s>    N |+1r)/R3!9# r6   flag_keys_to_evaluatec                 B    t        d| |xs i |xs i |xs i ||||	      S )aI  
    Get all flags for a given user.

    Args:
        distinct_id: The user's distinct ID
        groups: Groups mapping
        person_properties: Person properties
        group_properties: Group properties
        only_evaluate_locally: Whether to evaluate only locally
        disable_geoip: Whether to disable GeoIP lookup
        device_id: Optional device ID override for experience-continuity flags
        flag_keys_to_evaluate: Optional list of flag keys to evaluate (evaluates all if None)

    Details:
        Flags are key-value pairs where the key is the flag key and the value is the flag variant, or True, or False.

    Examples:
        ```python
        # All flags for user
        from posthog import get_all_flags
        get_all_flags('distinct_id_of_your_user')
        ```
    Category:
        Feature flags
    get_all_flagsr@   rx   ry   rz   r{   rl   r=   r   r`   r   s           r5   r   r     s;    F |+1r)/R3#3
 
r6   c	                 D    t        d| ||xs i |xs i |xs i ||||
      S )a  
    Get a FeatureFlagResult object which contains the flag result and payload.

    This method evaluates a feature flag and returns a FeatureFlagResult object containing:
    - enabled: Whether the flag is enabled
    - variant: The variant value if the flag has variants
    - payload: The payload associated with the flag (automatically deserialized from JSON)
    - key: The flag key
    - reason: Why the flag was enabled/disabled

    Args:
        key: The feature flag key.
        distinct_id: The user's distinct ID.
        groups: Mapping of group type to group key.
        person_properties: Person properties to use for evaluation.
        group_properties: Group properties keyed by group type.
        only_evaluate_locally: Whether to evaluate only locally.
        send_feature_flag_events: Whether to send a $feature_flag_called event.
        disable_geoip: Whether to disable GeoIP lookup.
        device_id: Optional device ID override for experience-continuity flags.

    Example:
    ```python
    result = posthog.get_feature_flag_result('beta-feature', 'distinct_id')
    if result and result.enabled:
        # Use the variant and payload
        print(f"Variant: {result.variant}")
        print(f"Payload: {result.payload}")
    ```
    get_feature_flag_resultr   r`   r   s	            r5   r   r   -  s>    R !|+1r)/R3!9# r6   match_valuec
                 F    t        d| |||xs i |xs i |xs i ||||	      S )a=  
    Get the payload associated with a feature flag value.

    Deprecated for new code. Prefer ``evaluate_flags()`` and
    ``flags.get_flag_payload(key)`` so flag evaluation happens once per request.

    Args:
        key: The feature flag key.
        distinct_id: The user's distinct ID.
        match_value: Optional flag value to use when selecting a payload.
        groups: Mapping of group type to group key.
        person_properties: Person properties to use for evaluation.
        group_properties: Group properties keyed by group type.
        only_evaluate_locally: Whether to evaluate only locally.
        send_feature_flag_events: Whether to send a $feature_flag_called event.
        disable_geoip: Whether to disable GeoIP lookup.
        device_id: Optional device ID override for experience-continuity flags.

    Returns:
        The payload associated with the matched feature flag value, or None.
        This function returns the payload only, not the FeatureFlagResult wrapper
        used internally to compute it.

    Category:
        Feature flags
    get_feature_flag_payload
rw   r@   r   rx   ry   rz   r{   r|   rl   r=   r`   r   s
             r5   r   r   d  sA    L "|+1r)/R3!9# r6   c                     t        d|       S )a4  Get the payload for a remote config feature flag.

    Args:
        key: The key of the feature flag

    Returns:
        The payload associated with the feature flag. If payload is encrypted, the return value will be decrypted

    Note:
        Requires personal_api_key to be set for authentication
    get_remote_config_payloadrw   r`   r   s    r5   r   r     s     # r6   c                 B    t        d| |xs i |xs i |xs i ||||	      S )a  
    Get all feature flag values and payloads for a user.

    Args:
        distinct_id: The user's distinct ID.
        groups: Mapping of group type to group key.
        person_properties: Person properties to use for evaluation.
        group_properties: Group properties keyed by group type.
        only_evaluate_locally: Whether to evaluate only locally.
        disable_geoip: Whether to disable GeoIP lookup.
        device_id: Optional device ID override for experience-continuity flags.
        flag_keys_to_evaluate: Optional list of flag keys to evaluate. Evaluates
            all flags when omitted.

    Returns:
        A dict with ``featureFlags`` and ``featureFlagPayloads`` entries.

    Category:
        Feature flags
    get_all_flags_and_payloadsr   r`   r   s           r5   r   r     s:    < $|+1r)/R3#3
 
r6   	flag_keysc                 *    t        d| |||||||	      S )u  Evaluate all feature flags for a user in a single call and return a
    :class:`FeatureFlagEvaluations` snapshot. Branch on ``.is_enabled()`` /
    ``.get_flag()`` and pass the same snapshot to ``capture()`` via the
    ``flags`` option so events carry the exact flag values the code branched on.

    Prefer this over repeated ``get_feature_flag()`` calls and over
    ``capture(send_feature_flags=True)`` — it consolidates flag evaluation into
    a single ``/flags`` request per incoming request.

    Args:
        distinct_id: The user's distinct ID. If ``None``, falls back to the context
            distinct_id. If still unresolvable, returns an empty snapshot.
        groups: Mapping of group type to group key.
        person_properties: Person properties to use for evaluation.
        group_properties: Group properties keyed by group type.
        only_evaluate_locally: If ``True``, never fall back to remote evaluation.
        disable_geoip: Whether to disable GeoIP lookup.
        flag_keys: Optional list of flag keys. When provided, only these flags are
            evaluated — the underlying ``/flags`` request asks the server for just
            this subset, which makes the response smaller and the request cheaper.
            Use this when you only need a handful of flags out of many.
        device_id: Optional device ID override. If not provided, falls back to the
            context device_id (which may be set via tracing headers). Used by
            experience-continuity flags to match users across distinct_id changes.

    Examples:
        ```python
        from posthog import evaluate_flags, capture
        flags = evaluate_flags("user_123", person_properties={"plan": "enterprise"})
        if flags.is_enabled("new-dashboard"):
            render_new_dashboard()
        capture("page_viewed", distinct_id="user_123", flags=flags)
        ```

    Category:
        Feature flags
    evaluate_flagsr@   rx   ry   rz   r{   rl   r   r=   r`   r   s           r5   r   r     s-    ^ +)3#
 
r6   c                      t        d      S )aX  
    Returns loaded feature flags.

    Details:
        Returns loaded feature flags, if any. Helpful for debugging what flag information you have loaded.

    Examples:
        ```python
        from posthog import feature_flag_definitions
        definitions = feature_flag_definitions()
        ```

    Category:
        Feature flags
    feature_flag_definitionsr`   rX   r6   r5   r   r     s      ,--r6   c                      t        d      S )z
    Load feature flag definitions from PostHog.

    Examples:
        ```python
        from posthog import load_feature_flags
        load_feature_flags()
        ```

    Category:
        Feature flags
    load_feature_flagsr`   rX   r6   r5   r   r   '  s     &''r6   timeout_secondsc                     t        d|        y)aY  
    Tell the client to flush all queued events.

    Args:
        timeout_seconds: Maximum seconds to wait for the queue to flush.
            Defaults to 10 seconds. Pass ``None`` to wait indefinitely.

    Examples:
        ```python
        from posthog import flush
        flush()
        ```

    Category:
        Client management
    flushr   Nr`   r   s    r5   r   r   7  s    " 7O4r6   c                      t        d       y)a  
    Block program until the client clears the queue. Used during program shutdown. You should use `shutdown()` directly in most cases.

    Examples:
        ```python
        from posthog import join
        join()
        ```

    Category:
        Client management
    joinNr`   rX   r6   r5   r   r   K  s     6Nr6   c                  0    t        d       t        d       y)z
    Flush all messages and cleanly shutdown the client.

    Examples:
        ```python
        from posthog import shutdown
        shutdown()
        ```

    Category:
        Client management
    r   r   Nr`   rX   r6   r5   shutdownr   [  s     7O
6Nr6   c                     t         st        rt        j                         nd} t        | fi dt        dt
        dt        dt        dt        dt        dt        d	t        d
t        dt        dt        dt        dt         dt"        dt$        dt&        dt(        dt*        dt,        dt.        dt0        dt2        dt4        dt6        dt8        dt:        dt<        dt>        a t        xs t         j                   t         _        t
        t         _        t         jA                  t&               t         S )a  
    Create or return the global PostHog client configured by module settings.

    Most applications should either instantiate ``Posthog`` directly or set
    ``posthog.api_key``/other module settings before calling top-level helpers.
    ``setup()`` is called automatically by global APIs such as ``capture()``.

    Returns:
        The global ``Client`` instance. If ``api_key`` is missing or blank,
        the client is disabled and module-level calls become no-ops.

    Category:
        Initialization
     hostdebugon_errorsend	sync_modepersonal_api_keypoll_intervaldisabledrl   	is_server%feature_flags_request_timeout_seconds!feature_flags_request_max_retriessuper_propertiesenable_exception_autocapturelog_captured_exceptionsbefore_sendenable_local_evaluationflag_definition_cache_provider capture_exception_code_variablescode_variables_mask_patternscode_variables_ignore_patterns#code_variables_mask_url_credentialscode_variables_detect_secretsin_app_modules*enable_exception_autocapture_rate_limiting!exception_autocapture_bucket_size!exception_autocapture_refill_rate-exception_autocapture_refill_interval_seconds)!default_clientapi_keystripr   r   r   r   r   r   r   r   r   rl   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   _set_before_send)configured_api_keys    r5   setupr   l  s~     07W]]_R!
!
 !
 	!

 !
  !
 .!
 (!
 !
 (!
  !
 3X!
 /P!
 .!
$ *F%!
& %<'!
( $)!
* %<+!
, ,J-!
. .N/!
0 *F1!
2 ,J3!
4 1T5!
6 +H7!
8 *9!
: 8b;!
< /P=!
> /P?!
@ ;hA!
J 'Dn.D.D*DN N##K0r6   c                 F    t                t        t        |       } ||i |S )z?Create an analytics client if one doesn't exist and send to it.)r   getattrr   )methodargsr]   fns       r5   ra   ra     s#    	G		(Btvr6   c                       e Zd ZdZy)Posthogz
    Public PostHog SDK client.

    ``Posthog`` is the customer-facing alias for ``Client`` and accepts the same
    constructor arguments. Use it to create an explicit SDK instance instead of
    relying on module-level global configuration.
    N)__name__
__module____qualname____doc__rX   r6   r5   r   r     s     	r6   r   )FNN)FN)NNNNN)NNN)N)NNNFTNN)NNNFNNN)NNNNFTNN)NNNNFNNN)
   )rU   N)datetimetypingr   r   r   r   r   r   typing_extensionsr	   posthog.argsr
   r   r   r   posthog.clientr   posthog.exception_capturer   posthog.contextsr   rB   r   r4   r   r9   r   rE   r   rL   r   rI   r   rN   r   rP   r   r?   r   r<   r   rT   r   rW   posthog.exception_utilsr   r   r   r    posthog.feature_flag_evaluationsr    posthog.feature_flagsr!   r"   posthog.flag_definition_cacher#   r$   posthog.requestr%   r&   r'   r(   posthog.typesr)   r*   r+   r,   r-   posthog.versionr.   __version__boolstrlistr   r   r   r   r   r   r   r   project_api_keyr   rl   r   r   r   r   r   r   project_rootprivacy_moder   r   r   r   r   r   r   r   r   r   r   DEFAULT_BUCKET_SIZEr   DEFAULT_REFILL_RATEr   DEFAULT_REFILL_INTERVAL_SECONDSr   r_   rc   rf   rn   rr   rv   intr~   r   dictr   r   objectr   r   r   r   r   r   floatr   r   r   r   ra   r   rX   r6   r5   <module>r      s	    @ @ $  " 6    $  )-#  V:LHTN L.1C 1&2S 2(/# /&G$ GIDI IMS	 MJT J	Dt 	D"c "# "(
$sCx. 
=| 	 	() %$% ! $    !% #(  C !G &Q # E -2 *$4$H$H !$4$H$H !44 .F.3 F.&)<"= F.(3- F.R#&) #hsm #@(vo. (8C= (F ,0-1$(&*+++ c3h(+ ))*	+
 3-+ D>+ (#+ c]+b .2$(%%% ))*% 3-	%
 D>% c]%R )-F%F()F c]FD 7;26<@"'%)$(#2	22 WS%S/1232  S#X/	2
 tCc3h$7892  2 #2 D>2 }2 d^2p 7;26<@"'%)$(#2	22 WS%S/1232  S#X/	2
 tCc3h$7892  2 #2 D>2 }2 i2n 7;26<@"'$(#15--WS%S/123-  S#X/- tCc3h$789	-
  - D>- }- $DI.- d3	>"#-f 7;26<@"'%)$(#4	44 WS%S/1234  S#X/	4
 tCc3h$7894  4 #4 D>4 }4  4t (,6:26<@"'%)$(#2	22 )$2 WS%S/123	2
  S#X/2 tCc3h$7892  2 #2 D>2 }2 f2j	, 7;26<@"'$(#15((WS%S/123(  S#X/( tCc3h$789	(
  ( D>( }( $DI.( (X '+6:26<@"'$(%)#9(#9WS%S/1239  S#X/9 tCc3h$789	9
  9 D>9 S	"9 }9 9x.&( 58E? 5D 5( ";v ;|		f 		r6   