Skip to content

Commit e8ea955

Browse files
committed
fix: gracefully exit on o11y errors
1 parent 6a80bc5 commit e8ea955

2 files changed

Lines changed: 27 additions & 16 deletions

File tree

.changeset/rude-houses-shake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"lingo.dev": patch
3+
---
4+
5+
gracefully exist on o11y errors

packages/cli/src/cli/utils/observability.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,29 @@ export default async function trackEvent(distinctId: string, event: string, prop
55
return;
66
}
77

8-
const posthog = new PostHog("phc_eR0iSoQufBxNY36k0f0T15UvHJdTfHlh8rJcxsfhfXk", {
9-
host: "https://eu.i.posthog.com",
10-
flushAt: 1,
11-
flushInterval: 0,
12-
});
8+
try {
9+
const posthog = new PostHog("phc_eR0iSoQufBxNY36k0f0T15UvHJdTfHlh8rJcxsfhfXk", {
10+
host: "https://eu.i.posthog.com",
11+
flushAt: 1,
12+
flushInterval: 0,
13+
});
1314

14-
await posthog.capture({
15-
distinctId,
16-
event,
17-
properties: {
18-
...properties,
19-
meta: {
20-
version: process.env.npm_package_version,
21-
isCi: process.env.CI === "true",
15+
await posthog.capture({
16+
distinctId,
17+
event,
18+
properties: {
19+
...properties,
20+
meta: {
21+
version: process.env.npm_package_version,
22+
isCi: process.env.CI === "true",
23+
},
2224
},
23-
},
24-
});
25+
});
2526

26-
await posthog.shutdown();
27+
await posthog.shutdown();
28+
} catch (error) {
29+
if (process.env.DEBUG) {
30+
console.error(error);
31+
}
32+
}
2733
}

0 commit comments

Comments
 (0)