This commit is contained in:
Johannes
2024-09-09 18:27:40 +02:00
parent 96292130a8
commit 7eca969496
6 changed files with 50 additions and 37 deletions

View File

@@ -75,30 +75,38 @@ export const OpenTextSummary = ({
{activeTab === "insights" ? (
<Table className="border-t border-slate-200">
<TableBody>
{questionSummary.insights.map((insight) => (
<TableRow
key={insight.id}
className="cursor-pointer hover:bg-slate-50"
onClick={() => {
setCurrentInsight(insight);
setIsInsightSheetOpen(true);
}}>
<TableCell className="flex font-medium">
{insight._count.documentInsights} <UserIcon className="ml-2 h-4 w-4" />
</TableCell>
<TableCell className="font-medium">{insight.title}</TableCell>
<TableCell>{insight.description}</TableCell>
<TableCell>
{insight.category === "complaint" ? (
<Badge text="Complaint" type="error" size="tiny" />
) : insight.category === "featureRequest" ? (
<Badge text="Feature Request" type="warning" size="tiny" />
) : insight.category === "praise" ? (
<Badge text="Praise" type="success" size="tiny" />
) : null}
{questionSummary.insights.length === 0 ? (
<TableRow>
<TableCell colSpan={4} className="py-8 text-center">
<p className="text-slate-500">No insights found for this question.</p>
</TableCell>
</TableRow>
))}
) : (
questionSummary.insights.map((insight) => (
<TableRow
key={insight.id}
className="cursor-pointer hover:bg-slate-50"
onClick={() => {
setCurrentInsight(insight);
setIsInsightSheetOpen(true);
}}>
<TableCell className="flex font-medium">
{insight._count.documentInsights} <UserIcon className="ml-2 h-4 w-4" />
</TableCell>
<TableCell className="font-medium">{insight.title}</TableCell>
<TableCell>{insight.description}</TableCell>
<TableCell>
{insight.category === "complaint" ? (
<Badge text="Complaint" type="error" size="tiny" />
) : insight.category === "featureRequest" ? (
<Badge text="Request" type="warning" size="tiny" />
) : insight.category === "praise" ? (
<Badge text="Praise" type="success" size="tiny" />
) : null}
</TableCell>
</TableRow>
))
)}
</TableBody>
</Table>
) : activeTab === "responses" ? (

View File

@@ -3,7 +3,6 @@ import { SummaryPage } from "@/app/(app)/environments/[environmentId]/surveys/[s
import { SurveyAnalysisCTA } from "@/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/summary/components/SurveyAnalysisCTA";
import { getServerSession } from "next-auth";
import { notFound } from "next/navigation";
import { getEnterpriseLicense } from "@formbricks/ee/lib/service";
import { getAttributeClasses } from "@formbricks/lib/attributeClass/service";
import { authOptions } from "@formbricks/lib/authOptions";
import { IS_AI_ENABLED, IS_FORMBRICKS_CLOUD, WEBAPP_URL } from "@formbricks/lib/constants";
@@ -61,12 +60,15 @@ const Page = async ({ params }) => {
const totalResponseCount = await getResponseCountBySurveyId(params.surveyId);
const { isViewer } = getAccessFlags(currentUserMembership?.role);
const { active: isEnterpriseEdition } = await getEnterpriseLicense();
// I took this out cause it's cloud only right?
// const { active: isEnterpriseEdition } = await getEnterpriseLicense();
const isAiEnabled =
isEnterpriseEdition &&
// isEnterpriseEdition &&
IS_FORMBRICKS_CLOUD &&
(organization.billing.plan === "scale" || organization.billing.plan === "enterprise") &&
(organization.billing.plan === "startup" ||
organization.billing.plan === "scale" ||
organization.billing.plan === "enterprise") &&
IS_AI_ENABLED;
return (

View File

@@ -2,7 +2,6 @@ import { responses } from "@/app/lib/api/response";
import { transformErrorToDetails } from "@/app/lib/api/validator";
import { headers } from "next/headers";
import { prisma } from "@formbricks/database";
import { getEnterpriseLicense } from "@formbricks/ee/lib/service";
import { sendResponseFinishedEmail } from "@formbricks/email";
import { CRON_SECRET, IS_AI_ENABLED, IS_FORMBRICKS_CLOUD } from "@formbricks/lib/constants";
import { createDocument } from "@formbricks/lib/document/service";
@@ -162,18 +161,22 @@ export const POST = async (request: Request) => {
await updateSurveyStatus(surveyId);
// generate embeddings for all open text question responses for enterprise and scale plans
// generate embeddings for all open text question responses for all paid plans
// TODO: check longer surveys if documents get created multiple times
const hasSurveyOpenTextQuestions = survey.questions.some((question) => question.type === "openText");
if (hasSurveyOpenTextQuestions && IS_FORMBRICKS_CLOUD) {
const { active: isEnterpriseEdition } = await getEnterpriseLicense();
const isAiEnabled = isEnterpriseEdition && IS_AI_ENABLED;
// const { active: isEnterpriseEdition } = await getEnterpriseLicense();
const isAiEnabled = IS_AI_ENABLED;
if (hasSurveyOpenTextQuestions && isAiEnabled) {
const organization = await getOrganizationByEnvironmentId(environmentId);
if (!organization) {
throw new Error("Organization not found");
}
if (organization.billing.plan === "enterprise" || organization.billing.plan === "scale") {
if (
organization.billing.plan === "enterprise" ||
organization.billing.plan === "scale" ||
organization.billing.plan === "startup"
) {
for (const question of survey.questions) {
if (question.type === "openText") {
const isQuestionAnswered = response.data[question.id] !== undefined;

View File

@@ -45,7 +45,7 @@ export type TQuestion = {
export const questionTypes: TQuestion[] = [
{
id: QuestionId.OpenText,
label: "Free text",
label: "Free Text",
description: "Ask for a text-based answer",
icon: MessageSquareTextIcon,
preset: {
@@ -204,7 +204,7 @@ export const questionTypes: TQuestion[] = [
},
{
id: QuestionId.Cal,
label: "Schedule a meeting",
label: "Schedule a Meeting",
description: "Allow respondents to schedule a meet",
icon: PhoneIcon,
preset: {

View File

@@ -26,7 +26,7 @@ export const handleInsightAssignments = async (
value: getInsightVectorText(insight.title, insight.description),
});
// find close insight to merge it with
const nearestInsights = await findNearestInsights(environmentId, embedding, 1, 0.2);
const nearestInsights = await findNearestInsights(environmentId, embedding, 1, 0.35);
if (nearestInsights.length > 0) {
// create a documentInsight with this insight

View File

@@ -65,11 +65,11 @@ export const InsightSheet = ({ isOpen, setIsOpen, insight, surveyId, questionId
<p>
Sentiment:{" "}
{document.sentiment === "positive" ? (
<Badge text="positive" size="tiny" type="success" />
<Badge text="Positive" size="tiny" type="success" />
) : document.sentiment === "neutral" ? (
<Badge text="neutral" size="tiny" type="gray" />
<Badge text="Neutral" size="tiny" type="gray" />
) : document.sentiment === "negative" ? (
<Badge text="negative" size="tiny" type="error" />
<Badge text="Negative" size="tiny" type="error" />
) : null}
</p>
<p>{timeSince(new Date(document.createdAt).toISOString())}</p>