Skip to content

Commit 8989246

Browse files
committed
Merge branch 'master' into package-rename
2 parents c2e0d67 + 09a3f19 commit 8989246

File tree

7 files changed

+50
-15
lines changed

7 files changed

+50
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Parameters:
106106

107107
## Requirements
108108

109-
- Python \>= 3.9
109+
- Python \>= 3.10
110110
- requests
111111

112112
## Links

docs/fastapi.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Flask integration
1+
# FastAPI integration
22

33
This extension adds support for the [FastAPI](https://fastapi.tiangolo.com/) web framework.
44

@@ -12,15 +12,16 @@ import Catcher module to your project.
1212

1313
```python
1414
from hawk_python_sdk.modules.fastapi import HawkFastapi
15+
from hawk_python_sdk.modules.fastapi import HawkFastapi
1516
```
1617

1718
```python
1819
app = FastAPI()
1920

20-
hawk = HawkFastapi(
21+
hawk = HawkFastapi({
2122
'app_instance': app,
2223
'token': '1234567-abcd-8901-efgh-123456789012'
23-
)
24+
})
2425
```
2526

2627
Now all global fastapi errors would be sent to Hawk.
@@ -60,10 +61,10 @@ To init Hawk Catcher just pass a project token and FastAPI app instance.
6061
```python
6162
app = FastAPI()
6263

63-
hawk = HawkFastapi(
64+
hawk = HawkFastapi({
6465
'app_instance': app,
6566
'token': '1234567-abcd-8901-efgh-123456789012'
66-
)
67+
})
6768
```
6869

6970
### Additional params

docs/flask.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Catcher module to your project.
1212

1313
```python
1414
from hawk_python_sdk.modules.flask import HawkFlask
15+
from hawk_python_sdk.modules.flask import HawkFlask
1516
```
1617

1718
```python

example/example3.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import hawk_python_sdk
2+
3+
4+
hawk_python_sdk.init({
5+
'token':'eyJpbnRlZ3JhdGlvbklkIjoiY2YxYzVhZGEtNzllOC00YWQ1LWFmYTQtNGMzZjI3Y2UzNWRiIiwic2VjcmV0IjoiZjk4NTc5ZTMtNGZmMy00YmVlLThjYzEtOWVlMDY0ZjU4YTRjIn0=',
6+
'release': '3.12.4'
7+
})
8+
hawk_python_sdk.send(
9+
event=Exception("Something went wrong"),
10+
context={
11+
'ip': '192.168.1.1'
12+
},
13+
user={'id': 2, 'name': 'Bob'}
14+
)
15+
print('Event sent successfully')

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ name = "hawk-python-sdk"
88
authors = [{ name = "CodeX Team", email = "[email protected]" }]
99
description = "Python errors Catcher module for Hawk."
1010
readme = "README.md"
11-
requires-python = ">=3.9"
11+
requires-python = ">=3.10"
1212
classifiers = [
1313
"Intended Audience :: Developers",
1414
"Topic :: Software Development :: Bug Tracking",
1515
"License :: OSI Approved :: MIT License",
16-
"Programming Language :: Python :: 3.5",
16+
"Programming Language :: Python :: 3.10",
1717
"Environment :: Console",
1818
"Environment :: Web Environment",
1919
]
2020
[project.optional-dependencies]
2121
flask = ["flask"]
22-
fastapi = ["starlette"]
22+
fastapi = ["fastapi"]
2323
[tool.hatch.version]
2424
path = "src/hawk_python_sdk/__init__.py"
2525
[project.urls]

src/hawk_python_sdk/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "3.5.1"
1+
__version__ = "3.5.2"
22

33
from .core import Hawk
44
from .types import HawkCatcherSettings

src/hawk_python_sdk/types.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,34 @@ class User(TypedDict):
1212
image: str # User's public picture
1313
url: str # URL for user's details page
1414

15-
class HawkCatcherSettings(TypedDict, Generic[T]):
16-
"""Settings for Hawk catcher for errors tracking"""
17-
15+
class HawkCatcherSettings(Generic[T]):
16+
"""Base settings for Hawk catcher for errors tracking"""
1817
token: str # Hawk integration token
1918
collector_endpoint: str # Collector endpoint for sending event to
2019
release: str # Release name for Suspected Commits feature
2120
before_send: Callable[[dict], None] # This hook allows you to filter any data you don't want sending to Hawk
2221
context: dict # Additional context to be send with event
23-
with_addons: bool = True # This parameter points if you want to send framework data with error (cookies, headers, params, form, json)
24-
set_user: Callable[[T], User] # This hook allows you to set user information, this hook is useful for frameworks
22+
with_addons: bool # This parameter points if you want to send framework data with error (cookies, headers, params, form, json)
23+
24+
def __init__(
25+
self,
26+
*,
27+
token: str,
28+
collector_endpoint: str,
29+
release: str,
30+
before_send: Callable[[dict], None],
31+
context: dict,
32+
with_addons: bool,
33+
set_user: Callable[[T], User]
34+
):
35+
self.token = token
36+
self.collector_endpoint = collector_endpoint
37+
self.release = release
38+
self.before_send = before_send
39+
self.context = context
40+
self.with_addons = with_addons
41+
self.set_user = set_user
42+
2543

2644
class Addons(TypedDict):
2745
"""Additional data to be send with event due to frameworks"""

0 commit comments

Comments
 (0)