Skip to content

Commit e85e1a4

Browse files
committed
feat: added flask docs
1 parent 0e25e4b commit e85e1a4

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

docs/flask.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Flask integration
2+
3+
This extension adds support for the [Flask](http://flask.pocoo.org/) web framework.
4+
5+
## Installation
6+
7+
```bash
8+
pip install hawkcatcher[flask]
9+
```
10+
11+
import Catcher module to your project.
12+
13+
```python
14+
from hawkcatcher.modules.flask import HawkFlask
15+
```
16+
17+
```python
18+
hawk = HawkFlask(
19+
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwcm9qZWN0SWQiOiI1ZTZmNWM3NzAzOWI0MDAwMjNmZDViODAiLCJpYXQiOjE1ODQzNTY0NzF9.t-5Gelx3MgHVBrxTsoMyPQAdQ6ufVbPsts9zZLW3gM8")
20+
```
21+
22+
Now all global flask errors would be sent to Hawk.
23+
24+
### Try-except
25+
26+
If you want to catch errors in try-except blocks see [this](../README.md#try-except)
27+
28+
## Manual sending
29+
30+
You can send any error to Hawk. See [this](../README.md#manual-sending)
31+
32+
### Event context
33+
34+
See [this](../README.md#event-context)
35+
36+
### Affected user
37+
38+
See [this](../README.md#affected-user)
39+
40+
### Addons
41+
42+
When some event handled by Flask Catcher, it adds some addons to the event data for Hawk.
43+
44+
| name | type | description |
45+
| --------- | ---- | ----------------- |
46+
| `url` | str | Request URL |
47+
| `method` | str | Request method |
48+
| `headers` | dict | Request headers |
49+
| `cookies` | dict | Request cookies |
50+
| `params` | dict | Request params |
51+
| `form` | dict | Request form |
52+
| `json` | dict | Request json data |
53+
54+
## Init params
55+
56+
To init Hawk Catcher just pass a project token.
57+
58+
```python
59+
hawk = HawkFlask('1234567-abcd-8901-efgh-123456789012')
60+
```
61+
62+
### Additional params
63+
64+
If you need to use custom Hawk server then pass a dictionary with params.
65+
66+
```python
67+
hawk = HawkFlask({
68+
'token': '1234567-abcd-8901-efgh-123456789012',
69+
'collector_endpoint': 'https://<id>.k1.hawk.so',
70+
})
71+
```
72+
73+
Parameters:
74+
75+
| name | type | required | description |
76+
| -------------------- | ------------------------- | ------------ | ---------------------------------------------------------------------------- |
77+
| `token` | str | **required** | Your project's Integration Token |
78+
| `release` | str | optional | Release name for Suspected Commits feature |
79+
| `collector_endpoint` | string | optional | Collector endpoint for sending event to |
80+
| `context` | dict | optional | Additional context to be send with every event |
81+
| `before_send` | Callable[[dict], None] | optional | This Method allows you to filter any data you don't want sending to Hawk |
82+
| `set_user` | Callable[[Request], User] | optional | This Method allows you to set user for every request by flask request object |
83+
| `with_addons` | bool | optional | Add framework addons to event data |
84+
85+
## Requirements
86+
87+
See [this](../README.md#requirements)
88+
89+
And for flask you need:
90+
91+
- Flask
92+
- blinker

0 commit comments

Comments
 (0)