Skip to content

Commit 43bc28a

Browse files
committed
update api
1 parent 519eb52 commit 43bc28a

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

apps/api/fly.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ kill_signal = 'SIGTERM'
99
kill_timeout = 30
1010
swap_size_mb = 512
1111

12-
[build]
13-
dockerfile = "Dockerfile"
14-
1512
[deploy]
1613
strategy = "bluegreen"
1714

apps/api/src/instrument.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import * as Sentry from "@sentry/bun";
22

3+
const isProduction = Bun.env.BUN_ENV === "production";
4+
35
Sentry.init({
46
dsn: Bun.env.SENTRY_DSN,
7+
environment: isProduction ? "production" : "development",
58
release: Bun.env.APP_VERSION
69
? `hyprnote-api@${Bun.env.APP_VERSION}`
7-
: undefined,
10+
: "hyprnote-api@local",
811
sampleRate: 1.0,
9-
enabled: ["true", "1"].includes(Bun.env.LOAD_TEST),
12+
enabled: isProduction || ["true", "1"].includes(Bun.env.LOAD_TEST),
13+
initialScope: {
14+
tags: {
15+
service: "api",
16+
},
17+
},
1018
});

apps/api/src/listen.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as Sentry from "@sentry/bun";
12
import type { Handler } from "hono";
23
import { upgradeWebSocket } from "hono/bun";
34

@@ -21,17 +22,35 @@ export const listenSocketHandler: Handler<AppBindings> = async (c, next) => {
2122
await connection.preconnectUpstream();
2223
emit({ type: "stt.websocket.connected", userId, provider });
2324
} catch (error) {
25+
const errorMessage =
26+
error instanceof Error ? error.message : "upstream_connect_failed";
27+
console.error("[listen] preconnect failed:", {
28+
provider,
29+
error: errorMessage,
30+
stack: error instanceof Error ? error.stack : undefined,
31+
});
32+
Sentry.captureException(error, {
33+
tags: {
34+
operation: "stt_preconnect",
35+
provider,
36+
},
37+
extra: {
38+
errorMessage,
39+
userId,
40+
},
41+
});
2442
emit({
2543
type: "stt.websocket.error",
2644
userId,
2745
provider,
2846
error:
2947
error instanceof Error ? error : new Error("upstream_connect_failed"),
3048
});
31-
const detail =
32-
error instanceof Error ? error.message : "upstream_connect_failed";
33-
const status = detail === "upstream_connect_timeout" ? 504 : 502;
34-
return c.json({ error: "upstream_connect_failed", detail }, status);
49+
const status = errorMessage === "upstream_connect_timeout" ? 504 : 502;
50+
return c.json(
51+
{ error: "upstream_connect_failed", detail: errorMessage },
52+
status,
53+
);
3554
}
3655

3756
const connectionStartTime = performance.now();

0 commit comments

Comments
 (0)