|
5 | 5 | import warnings |
6 | 6 | from datetime import datetime, timedelta |
7 | 7 | from typing import Any, Dict, Optional, Union |
8 | | -from typing_extensions import Unpack |
9 | 8 | from uuid import uuid4 |
10 | 9 |
|
11 | 10 | from dateutil.tz import tzutc |
12 | 11 | from six import string_types |
| 12 | +from typing_extensions import Unpack |
13 | 13 |
|
14 | | -from posthog.args import OptionalCaptureArgs, OptionalSetArgs, ID_TYPES, ExceptionArg |
| 14 | +from posthog.args import ID_TYPES, ExceptionArg, OptionalCaptureArgs, OptionalSetArgs |
15 | 15 | from posthog.consumer import Consumer |
| 16 | +from posthog.contexts import ( |
| 17 | + _get_current_context, |
| 18 | + get_capture_exception_code_variables_context, |
| 19 | + get_code_variables_ignore_patterns_context, |
| 20 | + get_code_variables_mask_patterns_context, |
| 21 | + get_context_distinct_id, |
| 22 | + get_context_session_id, |
| 23 | + new_context, |
| 24 | +) |
16 | 25 | from posthog.exception_capture import ExceptionCapture |
17 | 26 | from posthog.exception_utils import ( |
| 27 | + DEFAULT_CODE_VARIABLES_IGNORE_PATTERNS, |
| 28 | + DEFAULT_CODE_VARIABLES_MASK_PATTERNS, |
18 | 29 | exc_info_from_error, |
| 30 | + exception_is_already_captured, |
19 | 31 | exceptions_from_error_tuple, |
20 | 32 | handle_in_app, |
21 | | - exception_is_already_captured, |
22 | 33 | mark_exception_as_captured, |
23 | 34 | try_attach_code_variables_to_frames, |
24 | | - DEFAULT_CODE_VARIABLES_MASK_PATTERNS, |
25 | | - DEFAULT_CODE_VARIABLES_IGNORE_PATTERNS, |
26 | 35 | ) |
27 | 36 | from posthog.feature_flags import ( |
28 | 37 | InconclusiveMatchError, |
|
46 | 55 | get, |
47 | 56 | remote_config, |
48 | 57 | ) |
49 | | -from posthog.contexts import ( |
50 | | - _get_current_context, |
51 | | - get_context_distinct_id, |
52 | | - get_context_session_id, |
53 | | - get_capture_exception_code_variables_context, |
54 | | - get_code_variables_mask_patterns_context, |
55 | | - get_code_variables_ignore_patterns_context, |
56 | | - new_context, |
57 | | -) |
58 | 58 | from posthog.types import ( |
59 | 59 | FeatureFlag, |
60 | 60 | FeatureFlagError, |
@@ -197,6 +197,7 @@ def __init__( |
197 | 197 | capture_exception_code_variables=False, |
198 | 198 | code_variables_mask_patterns=None, |
199 | 199 | code_variables_ignore_patterns=None, |
| 200 | + in_app_modules: list[str] | None = None, |
200 | 201 | ): |
201 | 202 | """ |
202 | 203 | Initialize a new PostHog client instance. |
@@ -265,6 +266,7 @@ def __init__( |
265 | 266 | if code_variables_ignore_patterns is not None |
266 | 267 | else DEFAULT_CODE_VARIABLES_IGNORE_PATTERNS |
267 | 268 | ) |
| 269 | + self.in_app_modules = in_app_modules |
268 | 270 |
|
269 | 271 | if project_root is None: |
270 | 272 | try: |
@@ -998,6 +1000,7 @@ def capture_exception( |
998 | 1000 | "values": all_exceptions_with_trace, |
999 | 1001 | }, |
1000 | 1002 | }, |
| 1003 | + in_app_include=self.in_app_modules, |
1001 | 1004 | project_root=self.project_root, |
1002 | 1005 | ) |
1003 | 1006 | all_exceptions_with_trace_and_in_app = event["exception"]["values"] |
@@ -2182,9 +2185,9 @@ def _initialize_flag_cache(self, cache_url): |
2182 | 2185 | return None |
2183 | 2186 |
|
2184 | 2187 | try: |
2185 | | - from urllib.parse import urlparse, parse_qs |
| 2188 | + from urllib.parse import parse_qs, urlparse |
2186 | 2189 | except ImportError: |
2187 | | - from urlparse import urlparse, parse_qs |
| 2190 | + from urlparse import parse_qs, urlparse |
2188 | 2191 |
|
2189 | 2192 | try: |
2190 | 2193 | parsed = urlparse(cache_url) |
|
0 commit comments