Skip to content
This repository was archived by the owner on Jun 28, 2024. It is now read-only.

Commit 20605d5

Browse files
authored
feat: Merge pull request #57 from seamapi/feat-sentry
2 parents 8b64fda + 9215192 commit 20605d5

18 files changed

+344
-310
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ jobs:
1414
python-version: 3.8
1515
- name: Install Poetry
1616
uses: snok/install-poetry@v1
17+
- name: Run pre-build script (embed Sentry DSN)
18+
run: |
19+
poetry run python scripts/prebuild.py
20+
env:
21+
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
1722
- name: Release
1823
uses: bjoluc/semantic-release-config-poetry@v1
1924
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
dist
2+
seamapi/utils/get_sentry_dsn.py
23
.env
34
__pycache__
45
*/__pycache__

poetry.lock

Lines changed: 121 additions & 309 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ python = "^3.7"
1010
requests = "^2.26.0"
1111
python-dotenv = "^0.19.2"
1212
dataclasses-json = "^0.5.6"
13+
sentry-sdk = "^1.9.10"
1314

1415
[tool.poetry.dev-dependencies]
1516
pytest = "^6.2.5"
1617
black = "^21.12b0"
1718
testcontainers = {extras = ["postgresql"], version = "^3.4.2"}
19+
responses = "^0.22.0"
1820

1921
[build-system]
2022
requires = ["poetry-core>=1.0.0"]

scripts/prebuild.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import os
2+
3+
value = os.environ.get("SENTRY_DSN", "None")
4+
if value != "None":
5+
value = f'"{value}"'
6+
7+
f = open("seamapi/utils/get_sentry_dsn.py", "w")
8+
f.write(f"""
9+
def get_sentry_dsn():
10+
return {value}
11+
""")

seamapi/access_codes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from typing import List, Optional, Union, Any
1111
import requests
1212
from seamapi.utils.convert_to_id import to_access_code_id, to_device_id
13+
from seamapi.utils.report_error import report_error
1314

1415

1516
class AccessCodes(AbstractAccessCodes):
@@ -48,6 +49,7 @@ def __init__(self, seam: Seam):
4849

4950
self.seam = seam
5051

52+
@report_error
5153
def list(self, device: Union[DeviceId, Device]) -> List[AccessCode]:
5254
"""Gets a list of access codes for a device.
5355
@@ -76,6 +78,7 @@ def list(self, device: Union[DeviceId, Device]) -> List[AccessCode]:
7678

7779
return [AccessCode.from_dict(ac) for ac in access_codes]
7880

81+
@report_error
7982
def get(
8083
self,
8184
access_code: Optional[Union[AccessCodeId, AccessCode]] = None,
@@ -114,6 +117,7 @@ def get(
114117

115118
return AccessCode.from_dict(res["access_code"])
116119

120+
@report_error
117121
def create(
118122
self,
119123
device: Union[DeviceId, Device],
@@ -171,6 +175,7 @@ def create(
171175

172176
return AccessCode.from_dict(success_res["access_code"])
173177

178+
@report_error
174179
def update(
175180
self,
176181
access_code: Union[AccessCodeId, AccessCode],
@@ -233,6 +238,7 @@ def update(
233238

234239
return AccessCode.from_dict(success_res["access_code"])
235240

241+
@report_error
236242
def delete(
237243
self,
238244
access_code: Union[AccessCodeId, AccessCode],

seamapi/action_attempts.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import requests
1111
from typing import Union
1212
from seamapi.utils.convert_to_id import to_action_attempt_id
13+
from seamapi.utils.report_error import report_error
1314

1415

1516
class ActionAttempts(AbstractActionAttempts):
@@ -44,6 +45,7 @@ def __init__(self, seam: Seam):
4445

4546
self.seam = seam
4647

48+
@report_error
4749
def get(
4850
self, action_attempt: Union[ActionAttemptId, ActionAttempt]
4951
) -> ActionAttempt:
@@ -87,6 +89,7 @@ def get(
8789
error=error,
8890
)
8991

92+
@report_error
9093
def poll_until_ready(
9194
self,
9295
action_attempt: Union[ActionAttemptId, ActionAttempt],

seamapi/connect_webviews.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import requests
99
from typing import List, Optional, Union
1010
from seamapi.utils.convert_to_id import to_connect_webview_id
11+
from seamapi.utils.report_error import report_error
1112

1213

1314
class ConnectWebviews(AbstractConnectWebviews):
@@ -46,6 +47,7 @@ def __init__(self, seam: Seam):
4647

4748
self.seam = seam
4849

50+
@report_error
4951
def list(self) -> List[ConnectWebview]:
5052
"""Gets a list of connect webviews.
5153
@@ -69,6 +71,7 @@ def list(self) -> List[ConnectWebview]:
6971
ConnectWebview(**json_webview) for json_webview in json_webviews
7072
]
7173

74+
@report_error
7275
def get(
7376
self, connect_webview: Union[ConnectWebviewId, ConnectWebview]
7477
) -> ConnectWebview:
@@ -99,6 +102,7 @@ def get(
99102

100103
return ConnectWebview(**json_webview)
101104

105+
@report_error
102106
def create(
103107
self,
104108
accepted_providers: List[AcceptedProvider],

seamapi/connected_accounts.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import requests
1010
from typing import Any, Dict, List, Union
1111
from seamapi.utils.convert_to_id import to_connected_account_id
12+
from seamapi.utils.report_error import report_error
1213

1314

1415
class ConnectedAccounts(AbstractConnectedAccounts):
@@ -43,6 +44,7 @@ def __init__(self, seam: Seam):
4344

4445
self.seam = seam
4546

47+
@report_error
4648
def list(self) -> List[ConnectedAccount]:
4749
"""Gets a list of connected accounts.
4850
@@ -73,6 +75,7 @@ def list(self) -> List[ConnectedAccount]:
7375
for json_account in json_accounts
7476
]
7577

78+
@report_error
7679
def get(
7780
self,
7881
connected_account: Union[
@@ -129,6 +132,7 @@ def get(
129132
errors=json_account.get("errors", []),
130133
)
131134

135+
@report_error
132136
def delete(
133137
self,
134138
connected_account: Union[ConnectedAccountId, ConnectedAccount],

seamapi/devices.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
DeviceType,
1111
)
1212
from typing import List, Union, Optional
13-
import requests
1413
from seamapi.utils.convert_to_id import (
1514
to_connect_webview_id,
1615
to_connected_account_id,
1716
to_device_id,
1817
)
18+
from seamapi.utils.report_error import report_error
1919

2020

2121
class Devices(AbstractDevices):
@@ -52,6 +52,7 @@ def __init__(self, seam: Seam):
5252

5353
self.seam = seam
5454

55+
@report_error
5556
def list(
5657
self,
5758
connected_account: Union[ConnectedAccountId, ConnectedAccount] = None,
@@ -100,6 +101,7 @@ def list(
100101

101102
return [Device.from_dict(d) for d in devices]
102103

104+
@report_error
103105
def get(
104106
self,
105107
device: Optional[Union[DeviceId, Device]] = None,
@@ -133,6 +135,7 @@ def get(
133135
json_device = res["device"]
134136
return Device.from_dict(json_device)
135137

138+
@report_error
136139
def update(
137140
self,
138141
device: Union[DeviceId, Device],
@@ -184,6 +187,7 @@ def update(
184187

185188
return True
186189

190+
@report_error
187191
def delete(self, device: Union[DeviceId, Device]) -> bool:
188192
"""Deletes a device.
189193

0 commit comments

Comments
 (0)