Skip to content

Commit 5c66793

Browse files
committed
⬆️ Upgrade posthog-node
1 parent 6ad0ad2 commit 5c66793

File tree

9 files changed

+35
-19
lines changed

9 files changed

+35
-19
lines changed

apps/builder/next.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ const nextConfig = {
7272
config.resolve.alias["@googleapis/gmail"] = false;
7373
config.resolve.alias["nodemailer"] = false;
7474
config.resolve.alias["google-auth-library"] = false;
75+
config.resolve.alias["posthog-node"] = false;
7576
return config;
7677
},
7778
headers: async () => {

apps/builder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"papaparse": "5.4.1",
9696
"partysocket": "1.0.2",
9797
"pexels": "^1.4.0",
98-
"posthog-node": "4.3.2",
98+
"posthog-node": "5.8.2",
9999
"prettier": "2.8.8",
100100
"qs": "6.11.2",
101101
"react": "18.3.1",

apps/viewer/next.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const nextConfig = {
7474
config.resolve.alias["@googleapis/gmail"] = false;
7575
config.resolve.alias["nodemailer"] = false;
7676
config.resolve.alias["google-auth-library"] = false;
77+
config.resolve.alias["posthog-node"] = false;
7778
return config;
7879
},
7980
async redirects() {

bun.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"papaparse": "5.4.1",
101101
"partysocket": "1.0.2",
102102
"pexels": "^1.4.0",
103-
"posthog-node": "4.3.2",
103+
"posthog-node": "5.8.2",
104104
"prettier": "2.8.8",
105105
"qs": "6.11.2",
106106
"react": "18.3.1",
@@ -600,7 +600,7 @@
600600
},
601601
"packages/embeds/js": {
602602
"name": "@typebot.io/js",
603-
"version": "0.8.20",
603+
"version": "0.8.21",
604604
"devDependencies": {
605605
"@ai-sdk/ui-utils": "1.2.11",
606606
"@ark-ui/solid": "5.19.0",
@@ -638,7 +638,7 @@
638638
},
639639
"packages/embeds/react": {
640640
"name": "@typebot.io/react",
641-
"version": "0.8.20",
641+
"version": "0.8.21",
642642
"dependencies": {
643643
"@typebot.io/js": "workspace:*",
644644
"react": "18.3.1",
@@ -885,7 +885,7 @@
885885
"version": "1.0.0",
886886
"dependencies": {
887887
"@typebot.io/lib": "workspace:*",
888-
"posthog-node": "4.3.2",
888+
"posthog-node": "5.8.2",
889889
},
890890
"devDependencies": {
891891
"@typebot.io/forge": "workspace:*",
@@ -1163,7 +1163,7 @@
11631163
"cli-progress": "3.12.0",
11641164
"ky": "1.2.4",
11651165
"papaparse": "5.4.1",
1166-
"posthog-node": "4.3.2",
1166+
"posthog-node": "5.8.2",
11671167
"prompts": "2.4.2",
11681168
"stripe": "17.1.0",
11691169
},
@@ -1199,7 +1199,7 @@
11991199
"@typebot.io/zod": "workspace:*",
12001200
"cookie": "1.0.2",
12011201
"ky": "1.2.4",
1202-
"posthog-node": "4.3.2",
1202+
"posthog-node": "5.8.2",
12031203
},
12041204
"devDependencies": {
12051205
"@typebot.io/tsconfig": "workspace:*",
@@ -2358,6 +2358,8 @@
23582358

23592359
"@poppinss/exception": ["@poppinss/[email protected]", "", {}, "sha512-m7bpKCD4QMlFCjA/nKTs23fuvoVFoA83brRKmObCUNmi/9tVu8Ve3w4YQAnJu4q3Tjf5fr685HYIC/IA2zHRSg=="],
23602360

2361+
"@posthog/core": ["@posthog/[email protected]", "", {}, "sha512-hWk3rUtJl2crQK0WNmwg13n82hnTwB99BT99/XI5gZSvIlYZ1TPmMZE8H2dhJJ98J/rm9vYJ/UXNzw3RV5HTpQ=="],
2362+
23612363
"@prisma/client": ["@prisma/[email protected]", "", { "peerDependencies": { "prisma": "*", "typescript": ">=5.1.0" }, "optionalPeers": ["prisma", "typescript"] }, "sha512-Gg7j1hwy3SgF1KHrh0PZsYvAaykeR0PaxusnLXydehS96voYCGt1U5zVR31NIouYc63hWzidcrir1a7AIyCsNQ=="],
23622364

23632365
"@prisma/config": ["@prisma/[email protected]", "", { "dependencies": { "jiti": "2.4.2" } }, "sha512-Wcfk8/lN3WRJd5w4jmNQkUwhUw0eksaU/+BlAJwPQKW10k0h0LC9PD/6TQFmqKVbHQL0vG2z266r0S1MPzzhbA=="],
@@ -5164,7 +5166,7 @@
51645166

51655167
"postgres-interval": ["[email protected]", "", { "dependencies": { "xtend": "^4.0.0" } }, "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ=="],
51665168

5167-
"posthog-node": ["posthog-node@4.3.2", "", { "dependencies": { "axios": "^1.7.4", "rusha": "^0.8.14" } }, "sha512-vy8Mt9IEfniUgqQ1rOCQ31CBO1VNqDGd3ZtHlWR9/YfU6RiuK+9pUXPb4h6HTGzQmjL8NFnjd8K8NMXSX8S6MQ=="],
5169+
"posthog-node": ["posthog-node@5.8.2", "", { "dependencies": { "@posthog/core": "1.0.2" } }, "sha512-z3XRvYwnc3T/1999FKzv16YTpxERQqLunULl2vkOPfgbCXUGNyJWLgcbTcED2ZIDE11jjZhrSph4De6OSMLphw=="],
51685170

51695171
"preact": ["[email protected]", "", {}, "sha512-Z2dPnBnMUfyQfSQ+GBdsGa16hz35YmLmtTLhM169uW944hYL6xzTYkJjC07j+Wosz733pMWx0fgON3JNw1jJQA=="],
51705172

@@ -5416,8 +5418,6 @@
54165418

54175419
"run-parallel": ["[email protected]", "", { "dependencies": { "queue-microtask": "^1.2.2" } }, "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA=="],
54185420

5419-
"rusha": ["[email protected]", "", {}, "sha512-cLgakCUf6PedEu15t8kbsjnwIFFR2D4RfL+W3iWFJ4iac7z4B0ZI8fxy4R3J956kAI68HclCFGL8MPoUVC3qVA=="],
5420-
54215421
"sade": ["[email protected]", "", { "dependencies": { "mri": "^1.1.0" } }, "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A=="],
54225422

54235423
"safe-buffer": ["[email protected]", "", {}, "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="],

packages/forge/blocks/posthog/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"@typebot.io/tsconfig": "workspace:*"
1313
},
1414
"dependencies": {
15-
"posthog-node": "4.3.2",
15+
"posthog-node": "5.8.2",
1616
"@typebot.io/lib": "workspace:*"
1717
}
1818
}

packages/scripts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"papaparse": "5.4.1",
5050
"@typebot.io/lib": "workspace:*",
5151
"@typebot.io/prisma": "workspace:*",
52-
"posthog-node": "4.3.2",
52+
"posthog-node": "5.8.2",
5353
"prompts": "2.4.2",
5454
"stripe": "17.1.0",
5555
"@typebot.io/workspaces": "workspace:*",

packages/scripts/src/helpers/trackAndReportYesterdaysResults.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ export const trackAndReportYesterdaysResults = async () => {
3535
},
3636
});
3737

38+
console.log("🔍 Found", recentWorkspaces.length, "workspaces");
39+
3840
let resultsSum = 0;
3941
const newResultsCollectedEvents: TelemetryEvent[] = [];
4042
for (const workspace of recentWorkspaces) {
43+
console.log("Getting total results for workspace", workspace.id);
4144
const results = await prisma.result.groupBy({
4245
by: ["typebotId"],
4346
_count: {
@@ -55,6 +58,14 @@ export const trackAndReportYesterdaysResults = async () => {
5558
const olderAdmin = workspace.members
5659
.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime())
5760
.at(0);
61+
console.log(
62+
"Found",
63+
results.reduce((acc, result) => acc + result._count._all, 0),
64+
"results in",
65+
results.length,
66+
"typebots. Saving for admin",
67+
olderAdmin?.user.id,
68+
);
5869
if (!olderAdmin) continue;
5970
for (const result of results) {
6071
if (result._count._all === 0) continue;

packages/telemetry/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"@typebot.io/env": "workspace:*",
1111
"@typebot.io/prisma": "workspace:*",
1212
"@typebot.io/zod": "workspace:*",
13-
"posthog-node": "4.3.2",
13+
"posthog-node": "5.8.2",
1414
"ky": "1.2.4",
1515
"cookie": "1.0.2"
1616
},

packages/telemetry/src/trackEvents.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,27 @@ export const trackEvents = async (events: TelemetryEvent[]) => {
66
if (!env.NEXT_PUBLIC_POSTHOG_KEY) return;
77
const client = new PostHog(env.NEXT_PUBLIC_POSTHOG_KEY, {
88
host: env.POSTHOG_API_HOST,
9+
// Large thresholds since we explicitly shutdown right after.
10+
flushAt: 100_000,
11+
flushInterval: 120_000,
912
});
1013

11-
events.forEach(async (event) => {
14+
for (const event of events) {
1215
if (event.name === "Workspace created") {
1316
client.groupIdentify({
1417
distinctId: event.userId,
1518
groupType: "workspace",
1619
groupKey: event.workspaceId,
1720
});
18-
return;
21+
continue;
1922
}
2023
if (event.name === "Typebot created") {
2124
client.groupIdentify({
2225
distinctId: event.userId,
2326
groupType: "typebot",
2427
groupKey: event.typebotId,
2528
});
26-
return;
29+
continue;
2730
}
2831
const groups: { workspace?: string; typebot?: string } = {};
2932
if ("workspaceId" in event) groups["workspace"] = event.workspaceId;
@@ -32,13 +35,13 @@ export const trackEvents = async (events: TelemetryEvent[]) => {
3235
distinctId: "userId" in event ? event.userId : event.visitorId,
3336
event: event.name,
3437
properties: "data" in event ? event.data : undefined,
35-
groups,
38+
...(Object.keys(groups).length ? { groups } : {}),
3639
});
37-
});
40+
}
3841

3942
try {
4043
await client.shutdown();
4144
} catch (err) {
42-
console.error("ERROR while tracking events", err);
45+
console.error("ERROR while shutting down PostHog client", err);
4346
}
4447
};

0 commit comments

Comments
 (0)