reflex 0.5.1a2__py3-none-any.whl → 0.5.1a3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of reflex might be problematic. Click here for more details.

reflex/app.py CHANGED
@@ -1068,13 +1068,12 @@ async def process(
1068
1068
  client_ip: The client_ip.
1069
1069
 
1070
1070
  Raises:
1071
- ReflexError: If a reflex specific error occurs during processing the event.
1071
+ Exception: If a reflex specific error occurs during processing the event.
1072
1072
 
1073
1073
  Yields:
1074
1074
  The state updates after processing the event.
1075
1075
  """
1076
1076
  from reflex.utils import telemetry
1077
- from reflex.utils.exceptions import ReflexError
1078
1077
 
1079
1078
  try:
1080
1079
  # Add request data to the state.
@@ -1118,8 +1117,8 @@ async def process(
1118
1117
 
1119
1118
  # Yield the update.
1120
1119
  yield update
1121
- except ReflexError as ex:
1122
- telemetry.send("error", context="backend", detail=str(ex))
1120
+ except Exception as ex:
1121
+ telemetry.send_error(ex, context="backend")
1123
1122
  raise
1124
1123
 
1125
1124
 
@@ -4,12 +4,14 @@ Only the app attribute is explicitly exposed.
4
4
  from concurrent.futures import ThreadPoolExecutor
5
5
 
6
6
  from reflex import constants
7
+ from reflex.utils import telemetry
7
8
  from reflex.utils.exec import is_prod_mode
8
9
  from reflex.utils.prerequisites import get_app
9
10
 
10
11
  if "app" != constants.CompileVars.APP:
11
12
  raise AssertionError("unexpected variable name for 'app'")
12
13
 
14
+ telemetry.send("compile")
13
15
  app_module = get_app(reload=False)
14
16
  app = getattr(app_module, constants.CompileVars.APP)
15
17
  # For py3.8 and py3.9 compatibility when redis is used, we MUST add any decorator pages
@@ -29,5 +31,6 @@ del app_module
29
31
  del compile_future
30
32
  del get_app
31
33
  del is_prod_mode
34
+ del telemetry
32
35
  del constants
33
36
  del ThreadPoolExecutor
reflex/state.py CHANGED
@@ -1476,7 +1476,6 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
1476
1476
  StateUpdate object
1477
1477
  """
1478
1478
  from reflex.utils import telemetry
1479
- from reflex.utils.exceptions import ReflexError
1480
1479
 
1481
1480
  # Get the function to process the event.
1482
1481
  fn = functools.partial(handler.fn, state)
@@ -1516,8 +1515,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
1516
1515
  except Exception as ex:
1517
1516
  error = traceback.format_exc()
1518
1517
  print(error)
1519
- if isinstance(ex, ReflexError):
1520
- telemetry.send("error", context="backend", detail=str(ex))
1518
+ telemetry.send_error(ex, context="backend")
1521
1519
  yield state._as_state_update(
1522
1520
  handler,
1523
1521
  window_alert("An error occurred. See logs for details."),
@@ -233,9 +233,8 @@ def get_app(reload: bool = False) -> ModuleType:
233
233
 
234
234
  Raises:
235
235
  RuntimeError: If the app name is not set in the config.
236
- exceptions.ReflexError: Reflex specific errors.
237
236
  """
238
- from reflex.utils import exceptions, telemetry
237
+ from reflex.utils import telemetry
239
238
 
240
239
  try:
241
240
  os.environ[constants.RELOAD_CONFIG] = str(reload)
@@ -259,8 +258,8 @@ def get_app(reload: bool = False) -> ModuleType:
259
258
  importlib.reload(app)
260
259
 
261
260
  return app
262
- except exceptions.ReflexError as ex:
263
- telemetry.send("error", context="frontend", detail=str(ex))
261
+ except Exception as ex:
262
+ telemetry.send_error(ex, context="frontend")
264
263
  raise
265
264
 
266
265
 
reflex/utils/telemetry.py CHANGED
@@ -2,8 +2,10 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import asyncio
5
6
  import multiprocessing
6
7
  import platform
8
+ import warnings
7
9
 
8
10
  try:
9
11
  from datetime import UTC, datetime
@@ -157,17 +159,7 @@ def _send_event(event_data: dict) -> bool:
157
159
  return False
158
160
 
159
161
 
160
- def send(event: str, telemetry_enabled: bool | None = None, **kwargs) -> bool:
161
- """Send anonymous telemetry for Reflex.
162
-
163
- Args:
164
- event: The event name.
165
- telemetry_enabled: Whether to send the telemetry (If None, get from config).
166
- kwargs: Additional data to send with the event.
167
-
168
- Returns:
169
- Whether the telemetry was sent successfully.
170
- """
162
+ def _send(event, telemetry_enabled, **kwargs):
171
163
  from reflex.config import get_config
172
164
 
173
165
  # Get the telemetry_enabled from the config if it is not specified.
@@ -182,3 +174,37 @@ def send(event: str, telemetry_enabled: bool | None = None, **kwargs) -> bool:
182
174
  if not event_data:
183
175
  return False
184
176
  return _send_event(event_data)
177
+
178
+
179
+ def send(event: str, telemetry_enabled: bool | None = None, **kwargs):
180
+ """Send anonymous telemetry for Reflex.
181
+
182
+ Args:
183
+ event: The event name.
184
+ telemetry_enabled: Whether to send the telemetry (If None, get from config).
185
+ kwargs: Additional data to send with the event.
186
+ """
187
+
188
+ async def async_send(event, telemetry_enabled, **kwargs):
189
+ return _send(event, telemetry_enabled, **kwargs)
190
+
191
+ try:
192
+ # Within an event loop context, send the event asynchronously.
193
+ asyncio.create_task(async_send(event, telemetry_enabled, **kwargs))
194
+ except RuntimeError:
195
+ # If there is no event loop, send the event synchronously.
196
+ warnings.filterwarnings("ignore", category=RuntimeWarning)
197
+ _send(event, telemetry_enabled, **kwargs)
198
+
199
+
200
+ def send_error(error: Exception, context: str):
201
+ """Send an error event.
202
+
203
+ Args:
204
+ error: The error to send.
205
+ context: The context of the error (e.g. "frontend" or "backend")
206
+
207
+ Returns:
208
+ Whether the telemetry was sent successfully.
209
+ """
210
+ return send("error", detail=type(error).__name__, context=context)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: reflex
3
- Version: 0.5.1a2
3
+ Version: 0.5.1a3
4
4
  Summary: Web apps in pure Python.
5
5
  Home-page: https://reflex.dev
6
6
  License: Apache-2.0
@@ -66,8 +66,8 @@ reflex/__init__.py,sha256=fzBYk8qUFWkUlD3U-97xEAdv9N1tTMRmAzQat_9cZW0,5831
66
66
  reflex/__init__.pyi,sha256=y4jPgnR9f6xOpFAK9-WM7p-T05Y5jGFYkx7Thdok_3I,7791
67
67
  reflex/__main__.py,sha256=6cVrGEyT3j3tEvlEVUatpaYfbB5EF3UVY-6vc_Z7-hw,108
68
68
  reflex/admin.py,sha256=-bTxFUEoHo4X9FzmcSa6KSVVPpF7wh38lBvF67GhSvQ,373
69
- reflex/app.py,sha256=xpYYYPmlXtbj13arDnV9oyw3lgxBictyh60AGEnwzsk,47198
70
- reflex/app_module_for_backend.py,sha256=_QFY5tZYO44C9h_yhGLn0LR27GXsuniBWAJqd80oQBw,1152
69
+ reflex/app.py,sha256=vROxTXBLlPCUjI_9_-8_S7XOaExVls2j-kUE50u6-W0,47127
70
+ reflex/app_module_for_backend.py,sha256=zGsgZWpl11exOuH34JZUimNgBnWpjL7WH4SW6LItxgY,1227
71
71
  reflex/base.py,sha256=nqvgm-f1Fcj1WQrphKFniZWIM13bzr48OgfPBo1KZd8,4274
72
72
  reflex/compiler/__init__.py,sha256=r8jqmDSFf09iV2lHlNhfc9XrTLjNxfDNwPYlxS4cmHE,27
73
73
  reflex/compiler/compiler.py,sha256=_ywbGHWnyM6tqPV-oriyBhFkblm5jQSJ6UuZT0LtkBo,17455
@@ -494,7 +494,7 @@ reflex/model.py,sha256=WMcJiT04HSM4fKTP9SIZJQoDrIO2vaPTsoao-X169V4,13227
494
494
  reflex/page.py,sha256=NPT0xMownZGTiYiRtrUJnvAe_4oEvlzEJEkG-vrGhqI,2077
495
495
  reflex/reflex.py,sha256=VJZAwe9lIqbS3VB3QkP5-OMmNXmM4gi-5TWMCJgZPcc,17826
496
496
  reflex/route.py,sha256=WZS7stKgO94nekFFYHaOqNgN3zZGpJb3YpGF4ViTHmw,4198
497
- reflex/state.py,sha256=lTq7HBWVgB_Nk2vULyjfgqejym3B_zO_iZIPlSJ8AIw,107161
497
+ reflex/state.py,sha256=muy6eMhNKwv0T-mcpSoKIvI_7MAsZPnb2Y4M8RtPVbI,107042
498
498
  reflex/style.py,sha256=iqXJzDZ5pgkpaYHkIn_AZxu7iz1DmVg5mBSFShZhPSE,9389
499
499
  reflex/testing.py,sha256=vY6eRztzOVmrFqKdCVOEOICaFBuhF9K6948G68moNns,31461
500
500
  reflex/utils/__init__.py,sha256=y-AHKiRQAhk2oAkvn7W8cRVTZVK625ff8tTwvZtO7S4,24
@@ -507,17 +507,17 @@ reflex/utils/export.py,sha256=UJd4BYFW9_eexhLCP4C5Ri8Cq2tWAPNVspq70lPLCyo,2270
507
507
  reflex/utils/format.py,sha256=BFadhZX6oFvIZLQ0aUnul8SDN2iURSkFz-7tJcvDlRk,25149
508
508
  reflex/utils/imports.py,sha256=v_xLZiMn7UxxPu5mXln74tXi52wYKqPuZe11Ka31WuM,2309
509
509
  reflex/utils/path_ops.py,sha256=Vy6fU_bXvOcCvbXdTSmeLwy_C4h9seYU-3yIrVdZEZQ,4737
510
- reflex/utils/prerequisites.py,sha256=MfpYv-M9VjfiEeDe_kw7FiO0MDPkHWerNxfOLDznyjE,52920
510
+ reflex/utils/prerequisites.py,sha256=g2iXfhIv0-m_oK0lNr_p1D_54XFKj11Bgp4uaJLdAnU,52824
511
511
  reflex/utils/processes.py,sha256=3viom6wOhrZKgbSC6qvcRiQlYDKnHm1jgdJEcGyReFM,11972
512
512
  reflex/utils/pyi_generator.py,sha256=cOfDESTXjnIvJhi8-anKVDNllgpnsGd4OyRmwdw1z5Y,30637
513
513
  reflex/utils/serializers.py,sha256=bKY4UxwumFfzE-75tpCFQWRfCeXn301fALwCAUgzgDw,9037
514
- reflex/utils/telemetry.py,sha256=EAly34tKjlZuThKAmCrDZBEfFphrPv1BDZlBezFNCW8,4735
514
+ reflex/utils/telemetry.py,sha256=t4cvQmoAxTKAWF53vGH6ZEX5QYrK_KEcarmvMy-4_E4,5568
515
515
  reflex/utils/types.py,sha256=1CJQsNf2wMrMJi-3th7eELZ3MFOFUBgoIs3j5rU-MNE,15152
516
516
  reflex/utils/watch.py,sha256=HzGrHQIZ_62Di0BO46kd2AZktNA3A6nFIBuf8c6ip30,2609
517
517
  reflex/vars.py,sha256=MlooFk2EYY-1FeaJOSDovBWKGiEhVgR9Nrk_feid0FI,69074
518
518
  reflex/vars.pyi,sha256=p7rrP7ZcV0KN26a8LSqjTWP7IzZXXSee0H9Rl4fjEtg,5753
519
- reflex-0.5.1a2.dist-info/LICENSE,sha256=dw3zLrp9f5ObD7kqS32vWfhcImfO52PMmRqvtxq_YEE,11358
520
- reflex-0.5.1a2.dist-info/METADATA,sha256=Aau26V-BiSytdYK0wmFJxHQG9N6EmXtzf2VLuKb-MPg,12089
521
- reflex-0.5.1a2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
522
- reflex-0.5.1a2.dist-info/entry_points.txt,sha256=H1Z5Yat_xJfy0dRT1Frk2PkO_p41Xy7fCKlj4FcdL9o,44
523
- reflex-0.5.1a2.dist-info/RECORD,,
519
+ reflex-0.5.1a3.dist-info/LICENSE,sha256=dw3zLrp9f5ObD7kqS32vWfhcImfO52PMmRqvtxq_YEE,11358
520
+ reflex-0.5.1a3.dist-info/METADATA,sha256=4Fy6e5bOAsm_S9x0rbBUPE84IfcdVW8nW3nuv365a-E,12089
521
+ reflex-0.5.1a3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
522
+ reflex-0.5.1a3.dist-info/entry_points.txt,sha256=H1Z5Yat_xJfy0dRT1Frk2PkO_p41Xy7fCKlj4FcdL9o,44
523
+ reflex-0.5.1a3.dist-info/RECORD,,