fix: posthog ping to send overview (#1804)

Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
This commit is contained in:
Shubham Palriwala
2023-12-20 18:29:48 +05:30
committed by GitHub
parent 4c85fcb3cd
commit 51cec0184f
2 changed files with 14 additions and 4 deletions

View File

@@ -1,6 +1,8 @@
import { responses } from "@/app/lib/api/response";
import packageJson from "@/package.json";
import { headers } from "next/headers";
import { prisma } from "@formbricks/database";
import { CRON_SECRET } from "@formbricks/lib/constants";
import { captureTelemetry } from "@formbricks/lib/telemetry";
@@ -12,7 +14,18 @@ export async function POST() {
return responses.notAuthenticatedResponse();
}
captureTelemetry("ping");
const [surveyCount, responseCount, userCount] = await Promise.all([
prisma.survey.count(),
prisma.response.count(),
prisma.user.count(),
]);
captureTelemetry("ping", {
version: packageJson.version,
surveyCount,
responseCount,
userCount,
});
return responses.successResponse({}, true);
}

View File

@@ -20,7 +20,6 @@ import { personCache } from "../person/cache";
import { productCache } from "../product/cache";
import { getProductByEnvironmentId } from "../product/service";
import { responseCache } from "../response/cache";
import { captureTelemetry } from "../telemetry";
import { diffInDays, formatDateFields } from "../utils/datetime";
import { validateInputs } from "../utils/validate";
import { surveyCache } from "./cache";
@@ -513,8 +512,6 @@ export const createSurvey = async (environmentId: string, surveyBody: TSurveyInp
triggers: survey.triggers.map((trigger) => trigger.actionClass.name),
};
captureTelemetry("survey created");
surveyCache.revalidate({
id: survey.id,
environmentId: survey.environmentId,