mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-25 20:01:53 -05:00
fix: web-app surveys not triggered with modified api endpoint (#1097)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { prisma } from "@formbricks/database";
|
||||
import { selectSurvey } from "@formbricks/lib/survey/service";
|
||||
import { TSurveysWithTriggers } from "@formbricks/types/v1/js";
|
||||
import { TPerson } from "@formbricks/types/v1/people";
|
||||
import { TSurvey } from "@formbricks/types/v1/surveys";
|
||||
import { unstable_cache } from "next/cache";
|
||||
|
||||
const getSurveysCacheTags = (environmentId: string, personId: string): string[] => [
|
||||
@@ -26,7 +26,7 @@ export const getSurveysCached = (environmentId: string, person: TPerson) =>
|
||||
}
|
||||
)();
|
||||
|
||||
export const getSurveys = async (environmentId: string, person: TPerson): Promise<TSurvey[]> => {
|
||||
export const getSurveys = async (environmentId: string, person: TPerson): Promise<TSurveysWithTriggers[]> => {
|
||||
// get recontactDays from product
|
||||
const product = await prisma.product.findFirst({
|
||||
where: {
|
||||
@@ -133,7 +133,7 @@ export const getSurveys = async (environmentId: string, person: TPerson): Promis
|
||||
});
|
||||
|
||||
// filter surveys that meet the recontactDays criteria
|
||||
const surveys: TSurvey[] = potentialSurveysWithAttributes
|
||||
const surveys: TSurveysWithTriggers[] = potentialSurveysWithAttributes
|
||||
.filter((survey) => {
|
||||
if (!lastDisplayPerson) {
|
||||
// no display yet - always display
|
||||
@@ -165,7 +165,7 @@ export const getSurveys = async (environmentId: string, person: TPerson): Promis
|
||||
.map((survey) => ({
|
||||
...survey,
|
||||
singleUse: survey.singleUse ? JSON.parse(JSON.stringify(survey.singleUse)) : null,
|
||||
triggers: survey.triggers.map((trigger) => trigger.eventClass.name),
|
||||
triggers: survey.triggers.map((trigger) => trigger.eventClass),
|
||||
attributeFilters: survey.attributeFilters.map((af) => ({
|
||||
...af,
|
||||
attributeClassId: af.attributeClass.id,
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getSurveysCached } from "@/app/api/v1/js/surveys";
|
||||
import { getSurveysCached } from "@/app/api/v1/js/sync/lib/surveys";
|
||||
import { MAU_LIMIT } from "@formbricks/lib/constants";
|
||||
import { getActionClasses } from "@formbricks/lib/actionClass/service";
|
||||
import { getEnvironment } from "@formbricks/lib/environment/service";
|
||||
|
||||
@@ -5,10 +5,16 @@ import { ZSurvey } from "./surveys";
|
||||
import { ZActionClass } from "./actionClasses";
|
||||
import { ZProduct } from "./product";
|
||||
|
||||
const ZSurveysWithTriggers = ZSurvey.augment({
|
||||
triggers: z.array(ZActionClass),
|
||||
});
|
||||
|
||||
export type TSurveysWithTriggers = z.infer<typeof ZSurveysWithTriggers>;
|
||||
|
||||
export const ZJsState = z.object({
|
||||
person: ZPerson,
|
||||
session: ZSession,
|
||||
surveys: z.array(ZSurvey),
|
||||
surveys: z.array(ZSurveysWithTriggers),
|
||||
noCodeActionClasses: z.array(ZActionClass),
|
||||
product: ZProduct,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user