Skip to content

Commit 14edaed

Browse files
committed
fix: o11y
1 parent e574f69 commit 14edaed

2 files changed

Lines changed: 33 additions & 21 deletions

File tree

.changeset/ten-guests-ring.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+
fix o11y

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

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
1-
import pkg from "posthog-node";
2-
const { PostHog } = pkg;
1+
import { PostHog } from "posthog-node";
32

4-
export default async function trackEvent(distinctId: string, event: string, properties?: Record<string, any>) {
3+
export default async function trackEvent(
4+
distinctId: string,
5+
event: string,
6+
properties?: Record<string, any>,
7+
) {
58
if (process.env.DO_NOT_TRACK) {
69
return;
710
}
811

912
try {
10-
const safeProperties = properties ? JSON.parse(JSON.stringify(
11-
properties,
12-
(key, value) => {
13-
if (value instanceof Error) {
14-
return {
15-
name: value.name,
16-
message: value.message,
17-
stack: value.stack,
18-
};
19-
}
20-
return value;
21-
}
22-
)) : {};
13+
const safeProperties = properties
14+
? JSON.parse(
15+
JSON.stringify(properties, (key, value) => {
16+
if (value instanceof Error) {
17+
return {
18+
name: value.name,
19+
message: value.message,
20+
stack: value.stack,
21+
};
22+
}
23+
return value;
24+
}),
25+
)
26+
: {};
2327

24-
const posthog = new PostHog("phc_eR0iSoQufBxNY36k0f0T15UvHJdTfHlh8rJcxsfhfXk", {
25-
host: "https://eu.i.posthog.com",
26-
flushAt: 1,
27-
flushInterval: 0,
28-
});
28+
const posthog = new PostHog(
29+
"phc_eR0iSoQufBxNY36k0f0T15UvHJdTfHlh8rJcxsfhfXk",
30+
{
31+
host: "https://eu.i.posthog.com",
32+
flushAt: 1,
33+
flushInterval: 0,
34+
},
35+
);
2936

3037
await posthog.capture({
3138
distinctId,

0 commit comments

Comments
 (0)