bell-tag 1.0.7__py3-none-any.whl → 1.0.8__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 bell-tag might be problematic. Click here for more details.

bell_tag/decorators.py CHANGED
@@ -9,11 +9,15 @@ def bell_tag(name: str = None):
9
9
  """
10
10
  Decorator to track a Flask route.
11
11
  If no name is provided, use the function's __name__.
12
+ Supports both:
13
+ @bell_tag
14
+ @bell_tag("custom_name")
12
15
  """
16
+ # This inner function is the real decorator
13
17
  def decorator(f):
14
18
  route_name = name or f.__name__
15
19
 
16
- # Load BELL_KEY from .env
20
+ # Load API_KEY from .env
17
21
  config = load_env_config()
18
22
  api_key = config.get("BELL_KEY")
19
23
  if not api_key:
@@ -34,7 +38,7 @@ def bell_tag(name: str = None):
34
38
  "https://belltagmanager.com/api/v1/track",
35
39
  json={
36
40
  "api_key": api_key,
37
- "route_name": route_name, # <-- now uses function name if empty
41
+ "route_name": route_name,
38
42
  "path": path,
39
43
  "method": method,
40
44
  "ip": ip_address,
@@ -46,5 +50,13 @@ def bell_tag(name: str = None):
46
50
  pass # fail silently
47
51
 
48
52
  return f(*args, **kwargs)
53
+
49
54
  return wrapper
50
- return decorator if name is not None else decorator(f) # auto-wrap if no param
55
+
56
+ # Handle the case when decorator is used without parentheses: @bell_tag
57
+ if callable(name):
58
+ func = name # name is actually the function
59
+ name = None
60
+ return decorator(func)
61
+
62
+ return decorator
bell_tag/utils.py CHANGED
@@ -1,31 +1,28 @@
1
- import os
2
- from dotenv import load_dotenv
3
- import requests
4
- from .exceptions import VerificationFailed
1
+ # bell_tag/utils.py
5
2
 
6
3
  _verified = False # internal flag for verification
7
4
 
8
- def load_env_config():
9
- """Load BELL_KEY from .env"""
10
- load_dotenv() # loads .env from current working directory
11
- return {"BELL_KEY": os.getenv("BELL_KEY")}
12
-
13
5
  def verify_server_once(api_key):
14
- """Verify server with API once per process"""
6
+ """Verify server with API once per process, fail silently if server is down"""
15
7
  global _verified
16
8
  if _verified:
17
9
  return True
18
10
 
19
11
  try:
12
+ import requests
20
13
  resp = requests.post(
21
14
  "https://belltagmanager.com/api/v1/verify",
22
15
  json={"api_key": api_key},
23
16
  timeout=5
24
17
  )
25
- if resp.status_code != 200:
26
- raise VerificationFailed("Server verification failed.")
27
-
28
- _verified = True
29
- return True
18
+ if resp.status_code == 200:
19
+ _verified = True
20
+ return True
21
+ else:
22
+ # server responded but failed verification — log silently
23
+ print("Bell Tag: Verification failed, continuing anyway.")
24
+ return False
30
25
  except Exception as e:
31
- raise VerificationFailed(f"Verification error: {e}")
26
+ # server unreachable — fail silently
27
+ print(f"Bell Tag: Verification could not be completed ({e}), continuing anyway.")
28
+ return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bell-tag
3
- Version: 1.0.7
3
+ Version: 1.0.8
4
4
  Summary: Secure Flask analytics tracking library
5
5
  Author-email: Bell Network <support@bellnetwork.eu>
6
6
  License-Expression: MIT
@@ -0,0 +1,10 @@
1
+ bell_tag/__init__.py,sha256=9gUiTu_ERtU4dzpFDL07Tr7w66vhSL_QPAim2FjXfRE,232
2
+ bell_tag/decorators.py,sha256=DlrGRqHqLE1h7wYQ70jheACNxxGlyn5QWfv62oVtOpk,1916
3
+ bell_tag/exceptions.py,sha256=Z3iiOE_PXyM06cVrS531G_f3EH4DnC5QB5lcuiM-xng,94
4
+ bell_tag/middleware.py,sha256=oh7MvtZ8RxPoZ330jIVoELPnqvOGNzyD4CeqA6LRqMU,1099
5
+ bell_tag/py.typed,sha256=LeuNCoxZozlVi222NDN-i_wW5_jAlti_H1mOypLzovw,50
6
+ bell_tag/utils.py,sha256=j26ydmWfiLO90OikQeGyjwhnMWds1CQ2OinHZB1QX5s,896
7
+ bell_tag-1.0.8.dist-info/METADATA,sha256=M5kCuz8ZPxH7nwJnItwpHtzmDF6HUYKkyDGplcMBTf0,667
8
+ bell_tag-1.0.8.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
9
+ bell_tag-1.0.8.dist-info/top_level.txt,sha256=zNG3fCyKOmwKuKQz5PFEbzWq9T2tH4C1Tx3CvevSIRg,9
10
+ bell_tag-1.0.8.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- bell_tag/__init__.py,sha256=9gUiTu_ERtU4dzpFDL07Tr7w66vhSL_QPAim2FjXfRE,232
2
- bell_tag/decorators.py,sha256=bOYRofMWog9u4YKLfJaj__TAmfrKThNJSPygLdiSrxw,1695
3
- bell_tag/exceptions.py,sha256=Z3iiOE_PXyM06cVrS531G_f3EH4DnC5QB5lcuiM-xng,94
4
- bell_tag/middleware.py,sha256=oh7MvtZ8RxPoZ330jIVoELPnqvOGNzyD4CeqA6LRqMU,1099
5
- bell_tag/py.typed,sha256=LeuNCoxZozlVi222NDN-i_wW5_jAlti_H1mOypLzovw,50
6
- bell_tag/utils.py,sha256=vfXioF-VIu3Y1c_WkX12e0iYQsg_p4XuWlhg2TSmlII,869
7
- bell_tag-1.0.7.dist-info/METADATA,sha256=1ZQrWtXIXdyluT0AvBwz7_ZsmiYU-52ve9rtOZuer7s,667
8
- bell_tag-1.0.7.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
9
- bell_tag-1.0.7.dist-info/top_level.txt,sha256=zNG3fCyKOmwKuKQz5PFEbzWq9T2tH4C1Tx3CvevSIRg,9
10
- bell_tag-1.0.7.dist-info/RECORD,,