chore: improve posthog tracking with survey created event (#2964)

This commit is contained in:
Matti Nannt
2024-08-05 17:08:36 +02:00
committed by GitHub
parent a6ac78294b
commit f10bd9c0d8
2 changed files with 9 additions and 1 deletions

View File

@@ -64,7 +64,9 @@ test.describe("JS Package Test", async () => {
await page.goto(htmlFile);
// Formbricks In App Sync has happened
const syncApi = await page.waitForResponse((response) => response.url().includes("/app/sync"));
const syncApi = await page.waitForResponse((response) => response.url().includes("/app/sync"), {
timeout: 20000,
});
expect(syncApi.status()).toBe(200);
// Formbricks Modal exists in the DOM

View File

@@ -29,6 +29,7 @@ import { subscribeOrganizationMembersToSurveyResponses } from "../organization/s
import { personCache } from "../person/cache";
import { getPerson } from "../person/service";
import { structuredClone } from "../pollyfills/structuredClone";
import { capturePosthogEnvironmentEvent } from "../posthogServer";
import { productCache } from "../product/cache";
import { getProductByEnvironmentId } from "../product/service";
import { responseCache } from "../response/cache";
@@ -696,6 +697,11 @@ export const createSurvey = async (
await subscribeOrganizationMembersToSurveyResponses(survey.id, createdBy);
}
await capturePosthogEnvironmentEvent(survey.environmentId, "survey created", {
surveyId: survey.id,
surveyType: survey.type,
});
return transformedSurvey;
} catch (error) {
if (error instanceof Prisma.PrismaClientKnownRequestError) {