mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-22 00:52:50 -06:00
26 lines
725 B
TypeScript
26 lines
725 B
TypeScript
import { logger } from "@formbricks/logger";
|
|
import { TPipelineInput } from "@/app/lib/types/pipelines";
|
|
import { CRON_SECRET, WEBAPP_URL } from "@/lib/constants";
|
|
|
|
export const sendToPipeline = async ({ event, surveyId, environmentId, response }: TPipelineInput) => {
|
|
if (!CRON_SECRET) {
|
|
throw new Error("CRON_SECRET is not set");
|
|
}
|
|
|
|
return fetch(`${WEBAPP_URL}/api/pipeline`, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
"x-api-key": CRON_SECRET,
|
|
},
|
|
body: JSON.stringify({
|
|
environmentId: environmentId,
|
|
surveyId: surveyId,
|
|
event,
|
|
response,
|
|
}),
|
|
}).catch((error) => {
|
|
logger.error(error, "Error sending event to pipeline");
|
|
});
|
|
};
|