insider-python 0.1.0__tar.gz → 0.1.1__tar.gz

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.
Files changed (33) hide show
  1. {insider_python-0.1.0 → insider_python-0.1.1}/PKG-INFO +1 -1
  2. {insider_python-0.1.0 → insider_python-0.1.1}/pyproject.toml +1 -1
  3. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider/_envelope.py +3 -0
  4. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider/_version.py +1 -1
  5. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider/client.py +20 -0
  6. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider/stacktrace.py +11 -1
  7. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider_python.egg-info/PKG-INFO +1 -1
  8. {insider_python-0.1.0 → insider_python-0.1.1}/README.md +0 -0
  9. {insider_python-0.1.0 → insider_python-0.1.1}/setup.cfg +0 -0
  10. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider/__init__.py +0 -0
  11. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider/contrib/__init__.py +0 -0
  12. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider/contrib/django/__init__.py +0 -0
  13. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider/contrib/django/apps.py +0 -0
  14. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider/contrib/django/middleware.py +0 -0
  15. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider/dsn.py +0 -0
  16. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider/py.typed +0 -0
  17. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider/safety.py +0 -0
  18. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider/scope.py +0 -0
  19. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider/scrubbing.py +0 -0
  20. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider/transport.py +0 -0
  21. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider_python.egg-info/SOURCES.txt +0 -0
  22. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider_python.egg-info/dependency_links.txt +0 -0
  23. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider_python.egg-info/requires.txt +0 -0
  24. {insider_python-0.1.0 → insider_python-0.1.1}/src/insider_python.egg-info/top_level.txt +0 -0
  25. {insider_python-0.1.0 → insider_python-0.1.1}/tests/test_capture.py +0 -0
  26. {insider_python-0.1.0 → insider_python-0.1.1}/tests/test_django.py +0 -0
  27. {insider_python-0.1.0 → insider_python-0.1.1}/tests/test_dsn.py +0 -0
  28. {insider_python-0.1.0 → insider_python-0.1.1}/tests/test_envelope.py +0 -0
  29. {insider_python-0.1.0 → insider_python-0.1.1}/tests/test_never_crash.py +0 -0
  30. {insider_python-0.1.0 → insider_python-0.1.1}/tests/test_safety.py +0 -0
  31. {insider_python-0.1.0 → insider_python-0.1.1}/tests/test_scrubbing.py +0 -0
  32. {insider_python-0.1.0 → insider_python-0.1.1}/tests/test_stacktrace.py +0 -0
  33. {insider_python-0.1.0 → insider_python-0.1.1}/tests/test_transport.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: insider-python
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Python SDK for Insider — ship Beacons to your Insider server.
5
5
  Author: Insider
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "insider-python"
7
- version = "0.1.0"
7
+ version = "0.1.1"
8
8
  description = "Python SDK for Insider — ship Beacons to your Insider server."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -56,6 +56,7 @@ def build_envelope(
56
56
  tags: Optional[Dict[str, Any]] = None,
57
57
  extra: Optional[Dict[str, Any]] = None,
58
58
  occurred_at: Optional[str] = None,
59
+ commit_hash: Optional[str] = None,
59
60
  ) -> Dict[str, Any]:
60
61
  """Assemble the Beacon envelope. Pure: no I/O, no globals."""
61
62
  body: Dict[str, Any] = dict(payload or {})
@@ -63,6 +64,8 @@ def build_envelope(
63
64
  body["tags"] = tags
64
65
  if extra:
65
66
  body["extra"] = extra
67
+ if commit_hash:
68
+ body["commit_hash"] = commit_hash
66
69
  return {
67
70
  "kind": kind,
68
71
  "level": level,
@@ -5,4 +5,4 @@ lookup on every beacon. Bump this and `[project].version` together when
5
5
  cutting a release.
6
6
  """
7
7
 
8
- __version__ = "0.1.0"
8
+ __version__ = "0.1.1"
@@ -16,6 +16,7 @@ from __future__ import annotations
16
16
 
17
17
  import atexit
18
18
  import os
19
+ import subprocess
19
20
  import threading
20
21
  from typing import Any, Callable, Dict, Iterable, List, Optional
21
22
 
@@ -95,6 +96,23 @@ class Client:
95
96
  queue_size=transport_queue_size,
96
97
  flush_timeout=transport_flush_timeout,
97
98
  )
99
+ self.commit_hash: Optional[str] = self._get_commit_hash()
100
+
101
+ # Zero-config release tracking: if no release is provided, fallback to the git commit hash
102
+ if not release and self.commit_hash:
103
+ release = self.commit_hash
104
+ self.scope.static.release = release
105
+
106
+ def _get_commit_hash(self) -> Optional[str]:
107
+ try:
108
+ output = subprocess.check_output(
109
+ ["git", "rev-parse", "HEAD"],
110
+ stderr=subprocess.DEVNULL,
111
+ text=True,
112
+ ).strip()
113
+ return output if output else None
114
+ except Exception:
115
+ return None
98
116
 
99
117
  # ------------------------------------------------------------------
100
118
  # Capture
@@ -133,6 +151,7 @@ class Client:
133
151
  environment=self.scope.static.environment,
134
152
  release=self.scope.static.release,
135
153
  trace_id=trace_id,
154
+ commit_hash=self.commit_hash,
136
155
  payload=payload,
137
156
  tags=tags,
138
157
  extra=extra,
@@ -169,6 +188,7 @@ class Client:
169
188
  environment=self.scope.static.environment,
170
189
  release=self.scope.static.release,
171
190
  trace_id=trace_id,
191
+ commit_hash=self.commit_hash,
172
192
  payload=payload,
173
193
  tags=tags,
174
194
  extra=extra,
@@ -62,18 +62,28 @@ def extract_frames(
62
62
  """
63
63
  frames: List[Dict[str, Any]] = []
64
64
  walked = 0
65
+ cwd = os.getcwd()
65
66
  while tb is not None and walked < max_frames:
66
67
  try:
67
68
  frame = tb.tb_frame
68
69
  code = frame.f_code
69
70
  filename = code.co_filename
71
+
72
+ frame_in_app = is_in_app(filename, in_app_include)
73
+
74
+ if filename and filename.startswith(cwd):
75
+ try:
76
+ filename = os.path.relpath(filename, cwd)
77
+ except ValueError:
78
+ pass
79
+
70
80
  frames.append(
71
81
  {
72
82
  "filename": filename,
73
83
  "function": code.co_name,
74
84
  "module": frame.f_globals.get("__name__", ""),
75
85
  "lineno": tb.tb_lineno,
76
- "in_app": is_in_app(filename, in_app_include),
86
+ "in_app": frame_in_app,
77
87
  }
78
88
  )
79
89
  except Exception as exc:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: insider-python
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Python SDK for Insider — ship Beacons to your Insider server.
5
5
  Author: Insider
6
6
  License-Expression: MIT
File without changes
File without changes