🔧 (scripts) Send daily report notification on Discord

This commit is contained in:
Baptiste Arnaud 2025-11-19 10:25:43 +01:00
parent a33d8cd1b4
commit d17b232a86
No known key found for this signature in database

View File

@ -1,4 +1,3 @@
import { sendMessage } from "@typebot.io/telemetry/sendMessage";
import { formatChurnAgentDiscordMessages } from "../churnAgent/formatChurnAgentDiscordMessages";
import { getYesterdayChurnSummary } from "../churnAgent/getYesterdayChurnSummary";
import { cleanExpiredData } from "../helpers/cleanExpiredData";
@ -18,7 +17,8 @@ export const main = async () => {
// const { totalDeletedWorkspaces } = await deleteOrWarnInactiveWorkspaces();
// reportMessage += `🔥 ${totalDeletedWorkspaces} workspaces were deleted.\n`;
await sendMessage(`Daily report:
await sendDiscordMessage(
`Daily report:
📥 ${totalResults} collected results
🏭 ${totalWorkspaces} active workspaces
@ -27,7 +27,11 @@ export const main = async () => {
${formatSubscriptionMessage(subscriptionTransitions)}
[Go to daily dashboard](https://eu.posthog.com/project/${process.env.POSTHOG_PROJECT_ID}/dashboard/${process.env.POSTHOG_DAILY_DASHBOARD_ID})
[Go to web analytics](https://eu.posthog.com/project/${process.env.POSTHOG_PROJECT_ID}/web)`);
[Go to web analytics](https://eu.posthog.com/project/${process.env.POSTHOG_PROJECT_ID}/web)`,
{
channelId: process.env.DISCORD_CHANNEL_ID!,
},
);
if (!process.env.DISCORD_CHANNEL_ID) {
console.log("DISCORD_CHANNEL_ID is not set, skipping churn agent");