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

Commit 85c8c1c

Browse files
authored
Revert "feat: Log exceptions to Sentry" (#82)
1 parent 3b1f53e commit 85c8c1c

File tree

9 files changed

+28
-684
lines changed

9 files changed

+28
-684
lines changed

.github/workflows/npm-semantic-release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,4 @@ jobs:
2424
env:
2525
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2626
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27-
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
2827
run: npx semantic-release

docs/classes/Seam.md

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@
2424
- [devices](Seam.md#devices)
2525
- [events](Seam.md#events)
2626
- [locks](Seam.md#locks)
27-
- [shouldReportExceptions](Seam.md#shouldreportexceptions)
2827
- [webhooks](Seam.md#webhooks)
2928
- [workspaces](Seam.md#workspaces)
3029

3130
### Methods
3231

3332
- [makeRequest](Seam.md#makerequest)
34-
- [wrapThrowable](Seam.md#wrapthrowable)
3533

3634
## Constructors
3735

@@ -51,7 +49,7 @@ Routes.constructor
5149

5250
#### Defined in
5351

54-
[src/client.ts:52](https://github.com/seamapi/javascript/blob/main/src/client.ts#L52)
52+
[src/client.ts:44](https://github.com/seamapi/javascript/blob/main/src/client.ts#L44)
5553

5654
## Properties
5755

@@ -105,7 +103,7 @@ ___
105103

106104
#### Defined in
107105

108-
[src/client.ts:49](https://github.com/seamapi/javascript/blob/main/src/client.ts#L49)
106+
[src/client.ts:42](https://github.com/seamapi/javascript/blob/main/src/client.ts#L42)
109107

110108
___
111109

@@ -220,16 +218,6 @@ Routes.locks
220218

221219
___
222220

223-
### shouldReportExceptions
224-
225-
`Private` **shouldReportExceptions**: `boolean`
226-
227-
#### Defined in
228-
229-
[src/client.ts:50](https://github.com/seamapi/javascript/blob/main/src/client.ts#L50)
230-
231-
___
232-
233221
### webhooks
234222

235223
`Readonly` **webhooks**: `Object`
@@ -301,32 +289,4 @@ Routes.makeRequest
301289

302290
#### Defined in
303291

304-
[src/client.ts:110](https://github.com/seamapi/javascript/blob/main/src/client.ts#L110)
305-
306-
___
307-
308-
### wrapThrowable
309-
310-
`Private` **wrapThrowable**<`T`\>(`fn`): `Promise`<`T`\>
311-
312-
Reports thrown exceptions to Sentry, if enabled.
313-
314-
#### Type parameters
315-
316-
| Name |
317-
| :------ |
318-
| `T` |
319-
320-
#### Parameters
321-
322-
| Name | Type |
323-
| :------ | :------ |
324-
| `fn` | () => `T` |
325-
326-
#### Returns
327-
328-
`Promise`<`T`\>
329-
330-
#### Defined in
331-
332-
[src/client.ts:140](https://github.com/seamapi/javascript/blob/main/src/client.ts#L140)
292+
[src/client.ts:82](https://github.com/seamapi/javascript/blob/main/src/client.ts#L82)

docs/interfaces/SeamClientOptions.md

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
- [apiKey](SeamClientOptions.md#apikey)
1010
- [axiosOptions](SeamClientOptions.md#axiosoptions)
1111
- [endpoint](SeamClientOptions.md#endpoint)
12-
- [shouldReportExceptions](SeamClientOptions.md#shouldreportexceptions)
1312
- [workspaceId](SeamClientOptions.md#workspaceid)
1413

1514
## Properties
@@ -20,7 +19,7 @@
2019

2120
#### Defined in
2221

23-
[src/client.ts:11](https://github.com/seamapi/javascript/blob/main/src/client.ts#L11)
22+
[src/client.ts:10](https://github.com/seamapi/javascript/blob/main/src/client.ts#L10)
2423

2524
___
2625

@@ -32,7 +31,7 @@ Extended options to pass to Axios
3231

3332
#### Defined in
3433

35-
[src/client.ts:29](https://github.com/seamapi/javascript/blob/main/src/client.ts#L29)
34+
[src/client.ts:23](https://github.com/seamapi/javascript/blob/main/src/client.ts#L23)
3635

3736
___
3837

@@ -44,21 +43,7 @@ Seam Endpoint to use, defaults to https://connect.getseam.com
4443

4544
#### Defined in
4645

47-
[src/client.ts:15](https://github.com/seamapi/javascript/blob/main/src/client.ts#L15)
48-
49-
___
50-
51-
### shouldReportExceptions
52-
53-
`Optional` **shouldReportExceptions**: `boolean`
54-
55-
If true, SDK exceptions will be automatically reported to Seam. This defaults to `false` and is opt-in.
56-
57-
**`default`** false
58-
59-
#### Defined in
60-
61-
[src/client.ts:25](https://github.com/seamapi/javascript/blob/main/src/client.ts#L25)
46+
[src/client.ts:14](https://github.com/seamapi/javascript/blob/main/src/client.ts#L14)
6247

6348
___
6449

@@ -71,4 +56,4 @@ or undefined
7156

7257
#### Defined in
7358

74-
[src/client.ts:20](https://github.com/seamapi/javascript/blob/main/src/client.ts#L20)
59+
[src/client.ts:19](https://github.com/seamapi/javascript/blob/main/src/client.ts#L19)

docs/modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,4 +432,4 @@ ___
432432

433433
#### Defined in
434434

435-
[src/client.ts:32](https://github.com/seamapi/javascript/blob/main/src/client.ts#L32)
435+
[src/client.ts:26](https://github.com/seamapi/javascript/blob/main/src/client.ts#L26)

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"cjs-wrapper.js"
3636
],
3737
"dependencies": {
38-
"@sentry/node": "7.15.0",
3938
"axios": "0.25.0",
4039
"axios-retry": "3.2.5",
4140
"change-case": "4.1.2",
@@ -86,7 +85,6 @@
8685
"prettier": "2.5.1",
8786
"seamapi-types": "1.3.10",
8887
"semantic-release": "19.0.2",
89-
"sentry-testkit": "4.1.0",
9088
"testcontainers": "8.4.0",
9189
"ts-json-schema-generator": "0.98.0",
9290
"tsup": "5.11.11",

src/client.ts

Lines changed: 16 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import axios, { AxiosInstance, AxiosRequestConfig } from "axios"
22
import axiosRetry from "axios-retry"
3-
import * as Sentry from "@sentry/node"
43
import { SeamAPIError, SeamMalformedInputError } from "./lib/api-error"
54
import { Routes } from "./routes"
65
import { ErroredAPIResponse, SuccessfulAPIResponse } from "./types/globals"
7-
import { version, repository } from "../package.json"
6+
import { version } from "../package.json"
87

98
export interface SeamClientOptions {
109
/* Seam API Key */
@@ -18,11 +17,6 @@ export interface SeamClientOptions {
1817
* or undefined
1918
**/
2019
workspaceId?: string
21-
/**
22-
* If true, SDK exceptions will be automatically reported to Seam. This defaults to `false` and is opt-in.
23-
* @default false
24-
*/
25-
shouldReportExceptions?: boolean
2620
/**
2721
* Extended options to pass to Axios
2822
*/
@@ -36,7 +30,6 @@ export const getSeamClientOptionsWithDefaults = (
3630
apiKey: process?.env?.SEAM_API_KEY,
3731
endpoint: process?.env?.SEAM_API_URL || "https://connect.getseam.com",
3832
workspaceId: process?.env?.SEAM_WORKSPACE_ID,
39-
shouldReportExceptions: false,
4033
}
4134
if (typeof apiKeyOrOptions === "string") {
4235
return { ...seamClientDefaults, apiKey: apiKeyOrOptions }
@@ -47,18 +40,12 @@ export const getSeamClientOptionsWithDefaults = (
4740

4841
export class Seam extends Routes {
4942
public client: AxiosInstance
50-
private shouldReportExceptions: boolean
5143

5244
constructor(apiKeyOrOptions?: string | SeamClientOptions) {
5345
super()
5446

55-
const {
56-
apiKey,
57-
endpoint,
58-
workspaceId,
59-
axiosOptions,
60-
shouldReportExceptions,
61-
} = getSeamClientOptionsWithDefaults(apiKeyOrOptions)
47+
const { apiKey, endpoint, workspaceId, axiosOptions } =
48+
getSeamClientOptionsWithDefaults(apiKeyOrOptions)
6249

6350
const isRegularAPIKey = apiKey?.startsWith("seam_")
6451

@@ -79,7 +66,7 @@ export class Seam extends Routes {
7966
headers: {
8067
...axiosOptions?.headers,
8168
Authorization: `Bearer ${apiKey}`,
82-
["User-Agent"]: `Javascript SDK v${version} (${repository})`,
69+
["User-Agent"]: `Javascript SDK v${version} (https://github.com/seamapi/javascript)`,
8370

8471
// only needed for session key authentication
8572
...(!workspaceId ? {} : { "Seam-Workspace": workspaceId }),
@@ -90,66 +77,27 @@ export class Seam extends Routes {
9077
retries: 2,
9178
retryDelay: axiosRetry.exponentialDelay,
9279
})
93-
94-
this.shouldReportExceptions = shouldReportExceptions ?? false
95-
if (this.shouldReportExceptions) {
96-
Sentry.init({
97-
// Replaced during build
98-
dsn: process.env.SENTRY_DSN,
99-
defaultIntegrations: false,
100-
})
101-
102-
Sentry.setContext("sdk_info", {
103-
repository,
104-
version,
105-
endpoint,
106-
})
107-
}
10880
}
10981

11082
public async makeRequest<T>(
11183
request: AxiosRequestConfig
11284
): Promise<SuccessfulAPIResponse<T>> {
113-
return await this.wrapThrowable(async () => {
114-
try {
115-
const response = await this.client.request(request)
116-
return response.data
117-
} catch (error) {
118-
if (axios.isAxiosError(error) && error.response) {
119-
if (error.response.data.error?.type === "invalid_input") {
120-
throw new SeamMalformedInputError(
121-
error.response.data.error.validation_errors
122-
)
123-
}
124-
125-
throw new SeamAPIError(
126-
error.response.status,
127-
error.response.headers["seam-request-id"],
128-
(error.response.data as ErroredAPIResponse).error
85+
try {
86+
const response = await this.client.request(request)
87+
return response.data
88+
} catch (error) {
89+
if (axios.isAxiosError(error) && error.response) {
90+
if (error.response.data.error?.type === "invalid_input") {
91+
throw new SeamMalformedInputError(
92+
error.response.data.error.validation_errors
12993
)
13094
}
13195

132-
throw error
133-
}
134-
})
135-
}
136-
137-
/**
138-
* Reports thrown exceptions to Sentry, if enabled.
139-
*/
140-
private async wrapThrowable<T>(fn: () => T): Promise<T> {
141-
try {
142-
return await fn()
143-
} catch (error) {
144-
if (
145-
this.shouldReportExceptions &&
146-
// Only capture unknown errors
147-
!(
148-
error instanceof SeamMalformedInputError ||
149-
error instanceof SeamAPIError
96+
throw new SeamAPIError(
97+
error.response.status,
98+
error.response.headers["seam-request-id"],
99+
(error.response.data as ErroredAPIResponse).error
150100
)
151-
) {
152-
Sentry.captureException(error)
153101
}
154102

155103
throw error

0 commit comments

Comments
 (0)