Compare commits

...

16 Commits

Author SHA1 Message Date
ShubhamPalriwala
562f326638 fix: stripe action not running due to invalid env check in github action 2023-12-04 20:44:56 +05:30
Johannes
4b0eef9c2e feat: community page revamp (#1725) 2023-12-03 19:49:35 +00:00
Naitik Kapadia
6e08a94da7 feat: Show the number of Responses to Respondents (#1720)
Co-authored-by: Johannes <johannes@formbricks.com>
2023-12-03 19:27:05 +00:00
Matti Nannt
c8f621cea2 fix: increase rate limit for client endpoints (#1718) 2023-12-01 13:27:37 +00:00
Shubham Palriwala
6436ec6416 fix: add docs + increase size about increasing size of changing button text (#1714) 2023-12-01 10:49:21 +00:00
Matti Nannt
e7c3d9abee chore: use node 20 in dockerfiles (#1716) 2023-12-01 09:10:05 +00:00
Matti Nannt
c8bc942eb4 chore: prepare 1.3.4 release (#1715) 2023-11-30 17:53:31 +00:00
Dhruwang Jariwala
d4fcaa54ba fix: progress bar (#1698)
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
2023-11-30 15:12:40 +00:00
Dhruwang Jariwala
2118f881f6 feat: Time to complete Metadata (#1416)
Co-authored-by: Johannes <johannes@formbricks.com>
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
2023-11-30 14:22:33 +00:00
Shubham Palriwala
05884ead56 fix: validate string before fetching survey (#1701) 2023-11-30 08:45:34 +00:00
Dhruwang Jariwala
e53e04ca05 fix: duplicate title tags and meta descriptions (and other titles) (#1683)
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
2023-11-30 08:30:38 +00:00
Dhruwang Jariwala
32b2cd9ef3 chore: added individual eslints (#1710)
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
2023-11-30 08:24:20 +00:00
Anshuman Pandey
f734a76588 fix: team invites (#1699) 2023-11-30 08:23:05 +00:00
Anshuman Pandey
d71b1ee052 fix: fixes encoding of file name (#1712) 2023-11-30 07:41:03 +00:00
Dhruwang Jariwala
6b1d4a249a refactor: Auth options refactor (#1617)
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
2023-11-29 15:24:07 +00:00
Sidi jeddou
6b69d7c9af feat: Add devhunt open source to the list of oss-friends in api route (#1708)
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
2023-11-29 13:55:18 +00:00
112 changed files with 2903 additions and 2783 deletions

View File

@@ -57,6 +57,8 @@ jobs:
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
with:
platforms: linux/amd64,linux/arm64
# Login against a Docker registry except on PR
# https://github.com/docker/login-action

View File

@@ -1,10 +1,6 @@
import { Fence } from "@/components/shared/Fence";
export const metadata = {
title: "Formbricks People API: Fetch or Create Person Overview",
description:
"Dive into Formbricks' People API within the Public Client API suite, designed to work without authentication requirements. Seamlessly fetch or create a person by their userId and environmentId, optimizing client-side interactions while maintaining data privacy.",
};
import {generateManagementApiMetadata} from "@/lib/utils"
export const metadata = generateManagementApiMetadata("Action Class",["Fetch","Create","Delete"])
#### Management API

View File

@@ -1,10 +1,7 @@
import { Fence } from "@/components/shared/Fence";
import {generateManagementApiMetadata} from "@/lib/utils"
export const metadata = {
title: "Formbricks People API: Fetch or Create Person Overview",
description:
"Dive into Formbricks' People API within the Public Client API suite, designed to work without authentication requirements. Seamlessly fetch or create a person by their userId and environmentId, optimizing client-side interAttributes while maintaining data privacy.",
};
export const metadata = generateManagementApiMetadata("Attribute Class",["Fetch","Create","Delete"])
#### Management API

View File

@@ -1,9 +1,9 @@
import { Fence } from "@/components/shared/Fence";
export const metadata = {
title: "Formbricks People API: Fetch or Create Person Overview",
title: "Formbricks Me API: Fetch your environment details",
description:
"Dive into Formbricks' People API within the Public Client API suite, designed to work without authentication requirements. Seamlessly fetch or create a person by their userId and environmentId, optimizing client-side interactions while maintaining data privacy.",
"Dive into Formbricks' Me API within the Public Client API suite. Seamlessly fetch your own current environment details.",
};
#### Management API

View File

@@ -1,10 +1,8 @@
import { Fence } from "@/components/shared/Fence";
import {generateManagementApiMetadata} from "@/lib/utils"
export const metadata = generateManagementApiMetadata("People",["Fetch","Delete"])
export const metadata = {
title: "Formbricks People API: Fetch or Create Person Overview",
description:
"Dive into Formbricks' People API within the Public Client API suite, designed to work without authentication requirements. Seamlessly fetch or create a person by their userId and environmentId, optimizing client-side interactions while maintaining data privacy.",
};
#### Management API

View File

@@ -1,10 +1,7 @@
import { Fence } from "@/components/shared/Fence";
import {generateManagementApiMetadata} from "@/lib/utils"
export const metadata = {
title: "Formbricks Responses API Documentation - Manage Your Survey Data Seamlessly",
description:
"Unlock the full potential of Formbricks' Responses API. From fetching to updating survey responses, our comprehensive guide helps you integrate and manage survey data efficiently without compromising security. Ideal for client-side interactions.",
};
export const metadata = generateManagementApiMetadata("Responses",["Fetch","Delete"])
#### Management API

View File

@@ -1,10 +1,7 @@
import { Fence } from "@/components/shared/Fence";
import {generateManagementApiMetadata} from "@/lib/utils"
export const metadata = {
title: "Formbricks Surveys API Documentation - How to Retrieve All Surveys",
description:
"Explore the comprehensive guide to the Formbricks Surveys API. Learn how to effectively retrieve all the surveys in your environment with the necessary headers and API key setup. Includes sample request and response formats.",
};
export const metadata = generateManagementApiMetadata("Surveys",["Fetch","Create","Update","Delete"])
#### Management API

View File

@@ -1,8 +1,6 @@
export const metadata = {
title: "Formbricks Webhook API Documentation - List, Retrieve, Create, and Delete Webhooks",
description:
"Explore the comprehensive guide to the Formbricks Webhooks API. This is all you need to interact and play with the Formbricks Webhooks and integrate them into any third party app of your choice",
};
import {generateManagementApiMetadata} from "@/lib/utils"
export const metadata = generateManagementApiMetadata("Webhook",["Fetch","Create","Delete"])
#### Management API

View File

@@ -45,6 +45,15 @@ const FAQ_DATA = [
</>
),
},
{
question: "How can I change Button texts in my survey?",
answer: () => (
<>
For the question that you want to change the button text, click on the <b>Show Advanced Settings</b>{" "}
toggle and change the button label in the <b>Button Text</b> field.
</>
),
},
];
export const faqJsonLdData = FAQ_DATA.map((faq) => ({

View File

@@ -22,9 +22,9 @@ import {
VideoTabletAdjustIcon,
} from "@formbricks/ui/icons";
import { createId } from "@paralleldrive/cuid2";
import { TTemplate } from "@formbricks/types/templates";
import { TSurveyQuestionType } from "@formbricks/types/surveys";
import { TTemplate } from "@formbricks/types/templates";
import { createId } from "@paralleldrive/cuid2";
const thankYouCardDefault = {
enabled: true,
@@ -32,6 +32,12 @@ const thankYouCardDefault = {
subheader: "We appreciate your feedback.",
};
const welcomeCardDefault = {
enabled: true,
timeToFinish: false,
showResponseCount: false,
};
export const customSurvey: TTemplate = {
name: "Start from scratch",
description: "Create a survey without template.",
@@ -51,10 +57,7 @@ export const customSurvey: TTemplate = {
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -150,10 +153,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -260,10 +260,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -340,10 +337,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -389,10 +383,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -447,10 +438,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -513,10 +501,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -582,10 +567,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -640,10 +622,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -685,10 +664,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -723,10 +699,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -752,10 +725,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -803,10 +773,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -848,10 +815,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -905,10 +869,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -961,10 +922,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -1013,10 +971,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -1043,10 +998,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -1071,10 +1023,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -1098,10 +1047,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -1142,10 +1088,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -1179,10 +1122,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -1216,10 +1156,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},
@@ -1281,10 +1218,7 @@ export const templates: TTemplate[] = [
},
],
thankYouCard: thankYouCardDefault,
welcomeCard: {
enabled: false,
timeToFinish: false,
},
welcomeCard: welcomeCardDefault,
hiddenFields: {
enabled: false,
},

View File

@@ -1,5 +1,3 @@
import PHIcon from "@/images/formtribe/ph-logo.png";
import Image from "next/image";
import Link from "next/link";
export const GitHubSponsorship: React.FC = () => {
@@ -38,7 +36,7 @@ export const GitHubSponsorship: React.FC = () => {
</p>
</div>
<div className="flex items-center justify-end">
<Image src={PHIcon} alt="Product Hunt Logo" width={80} className="" />
{/* <Image src={PHIcon} alt="Product Hunt Logo" width={80} className="" /> */}
</div>
</div>
</Link>

View File

@@ -27,11 +27,11 @@ export const Hero: React.FC = ({}) => {
<ChevronRightIcon className="mb-1 ml-1 inline h-4 w-4 text-slate-300" />
</a>
<h1 className="mt-10 text-3xl font-bold tracking-tight text-slate-800 dark:text-slate-200 sm:text-4xl md:text-5xl">
<span className="xl:inline">The Open Source Survey Suite</span>
<span className="xl:inline">Prviacy-first Experience Management</span>
</h1>
<p className="xs:max-w-none mx-auto mt-3 max-w-xs text-base text-slate-500 dark:text-slate-400 sm:text-lg md:mt-5 md:text-xl">
Run link surveys, in-app surveys and email surveys in one app {" "}
Turn customer insights into irresistible experiences {" "}
<span className="decoration-brand-dark underline underline-offset-4">all privacy-first.</span>
</p>
@@ -92,7 +92,7 @@ export const Hero: React.FC = ({}) => {
router.push("https://app.formbricks.com/auth/signup");
plausible("Hero_CTA_CreateSurvey");
}}>
Create survey
Get started
</Button>
<Button
variant="secondary"

View File

@@ -1,6 +1,6 @@
import Link from "next/link";
import { FaDiscord, FaGithub, FaXTwitter } from "react-icons/fa6";
import { FooterLogo } from "./Logo";
import { FaGithub, FaXTwitter, FaDiscord } from "react-icons/fa6";
const navigation = {
other: [
@@ -33,7 +33,7 @@ export default function Footer() {
return (
<footer
className="mt-32 bg-gradient-to-b from-slate-50 to-slate-200 dark:from-slate-900 dark:to-slate-800"
className="bg-gradient-to-b from-slate-50 to-slate-200 pt-32 dark:from-slate-900 dark:to-slate-800"
aria-labelledby="footer-heading">
<h2 id="footer-heading" className="sr-only">
Footer

View File

@@ -278,6 +278,11 @@ export default function Header() {
className="text-sm font-medium text-slate-400 hover:text-slate-700 dark:hover:text-slate-300 lg:text-base">
Pricing
</Link>
<Link
href="/concierge"
className="text-sm font-medium text-slate-400 hover:text-slate-700 dark:hover:text-slate-300 lg:text-base">
Concierge
</Link>
<Link
href="/docs"
className="text-sm font-medium text-slate-400 hover:text-slate-700 dark:hover:text-slate-300 lg:text-base">
@@ -293,12 +298,6 @@ export default function Header() {
className="text-base font-medium text-slate-400 hover:text-slate-700 dark:hover:text-slate-300">
Careers <p className="bg-brand inline rounded-full px-2 text-xs text-white">1</p>
</Link> */}
<Link
href="/concierge"
className="text-sm font-medium text-slate-400 hover:text-slate-700 dark:hover:text-slate-300 lg:text-base">
Concierge
</Link>
</Popover.Group>
<div className="hidden flex-1 items-center justify-end md:flex">
<ThemeSelector className="relative z-10 mr-2 lg:mr-5" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

View File

@@ -6,3 +6,14 @@ export function formatDate(dateString: string) {
timeZone: "UTC",
});
}
export function generateManagementApiMetadata(title, methods) {
// Create a string from the methods array, formatted for title and description
const formattedMethods = methods.join(", ").replace(/, ([^,]*)$/, " or $1");
return {
title: `Formbricks ${title} API: ${
formattedMethods.charAt(0).toUpperCase() + formattedMethods.slice(1)
} ${title}`,
description: `Dive into Formbricks' ${title} API within the Public Client API suite. This API is designed for ${formattedMethods} operations on ${title}, facilitating client-side interactions without the need for authentication, thereby ensuring data privacy and efficiency.`,
};
}

View File

@@ -25,6 +25,11 @@ const nextConfig = {
hostname: "seo-strapi-aws-s3.s3.eu-central-1.amazonaws.com",
port: "",
},
{
protocol: "https",
hostname: "avatars.githubusercontent.com",
port: "",
},
],
},
async redirects() {
@@ -160,6 +165,11 @@ const nextConfig = {
destination: "/docs/contributing/setup#gitpod",
permanent: true,
},
{
source: "/formtribe",
destination: "/community",
permanent: true,
},
];
},
async rewrites() {

View File

@@ -28,6 +28,11 @@ export default async function handle(req: NextApiRequest, res: NextApiResponse)
"Centralize community, product, and customer data to understand which companies are engaging with your open source project.",
href: "https://www.crowd.dev",
},
{
name: "DevHunt",
description: "Find the best Dev Tools upvoted by the community every week.",
href: "https://devhunt.org/",
},
{
name: "Documenso",
description:

View File

@@ -1,101 +0,0 @@
import Layout from "@/components/shared/Layout";
import HeroTitle from "@/components/shared/HeroTitle";
import { Button } from "@formbricks/ui/Button";
import { ArrowTopRightOnSquareIcon } from "@heroicons/react/24/outline";
import { useRouter } from "next/router";
import { ChatBubbleOvalLeftEllipsisIcon, EnvelopeIcon } from "@heroicons/react/24/solid";
const topContributors = [
{
name: "Midka",
href: "https://github.com/kymppi",
},
{
name: "Pandeyman",
href: "https://github.com/pandeymangg",
},
{
name: "Ashu",
href: "https://github.com/Ashutosh-Bhadauriya",
},
{
name: "Timothy",
href: "https://github.com/timothyde",
},
{
name: "Shubhdeep",
href: "https://github.com/Shubhdeep12",
},
];
const CommunityPage = () => {
const router = useRouter();
return (
<Layout
title="Community | Formbricks Open Source Forms & Surveys"
description="You're building open source forms and surveys? So are we! Get support for anything your building - or just say hi!">
<HeroTitle headingPt1="Join the" headingTeal="Formbricks" headingPt2="Community 🤍" />
<div className="mb-32 grid grid-cols-1 px-4 md:grid-cols-2 md:gap-8 md:px-16">
<div className="mb-6 rounded-lg bg-gradient-to-b from-slate-200 to-slate-300 px-10 py-6 dark:from-slate-800 dark:to-slate-700 md:mb-0">
<h2 className="mt-7 text-3xl font-bold text-slate-800 dark:text-slate-200 xl:text-4xl">
Top Contributors
</h2>
<p className="mt-2 text-sm text-slate-500 dark:text-slate-400">
Super thankful to have you guys contribute for Formbricks 🙌
</p>
<ol className="ml-4 mt-10 list-decimal">
{topContributors.map((MVP) => (
<li
key={MVP.name}
className="my-3 text-lg font-bold text-slate-700 hover:text-slate-600 dark:text-slate-300 dark:hover:text-slate-400">
<a href={MVP.href} className="" target="_blank" rel="noreferrer">
{MVP.name}
<ArrowTopRightOnSquareIcon className="text-brand-dark dark:text-brand-light mb-1 ml-1 inline h-5 w-5" />
</a>
</li>
))}
</ol>
</div>
<div>
<div className="rounded-lg bg-gradient-to-b from-slate-200 to-slate-300 px-10 pb-12 pt-6 dark:from-slate-800 dark:to-slate-700">
<h3 className="mt-7 text-3xl font-bold text-slate-800 dark:text-slate-200 xl:text-4xl">
Community Discord
</h3>
<p className="mt-2 text-sm text-slate-500 dark:text-slate-400">
Get support for anything your building - or just say hi 👋
</p>
<Button
className="mt-7 w-full justify-center"
variant="highlight"
onClick={() => router.push("/discord")}>
Join Discord <ChatBubbleOvalLeftEllipsisIcon className="ml-1 inline h-5 w-5" />
</Button>
</div>
<div className="mt-7 flex">
<a
href="https://twitter.com/formbricks"
target="_blank"
rel="noreferrer"
className="delay-50 w-1/2 transition ease-in-out hover:scale-105">
<div className="mr-3 flex justify-center rounded-lg bg-gradient-to-b from-slate-200 to-slate-300 py-6 dark:from-slate-800 dark:to-slate-700">
<svg fill="currentColor" viewBox="0 0 24 24" className="h-20 w-20 text-[#1DA1F2]">
<path d="M8.29 20.251c7.547 0 11.675-6.253 11.675-11.675 0-.178 0-.355-.012-.53A8.348 8.348 0 0022 5.92a8.19 8.19 0 01-2.357.646 4.118 4.118 0 001.804-2.27 8.224 8.224 0 01-2.605.996 4.107 4.107 0 00-6.993 3.743 11.65 11.65 0 01-8.457-4.287 4.106 4.106 0 001.27 5.477A4.072 4.072 0 012.8 9.713v.052a4.105 4.105 0 003.292 4.022 4.095 4.095 0 01-1.853.07 4.108 4.108 0 003.834 2.85A8.233 8.233 0 012 18.407a11.616 11.616 0 006.29 1.84" />
</svg>
</div>
</a>
<a
href="mailto:hola@formbricks.com"
className="delay-50 w-1/2 transition ease-in-out hover:scale-105">
<div className="ml-3 flex justify-center rounded-lg bg-gradient-to-b from-slate-200 to-slate-300 py-6 dark:from-slate-800 dark:to-slate-700">
<EnvelopeIcon className="ml-1 h-20 w-20 text-slate-400 " />
</div>
</a>
</div>
</div>
</div>
</Layout>
);
};
export default CommunityPage;

View File

@@ -0,0 +1,44 @@
import Image from "next/image";
import Link from "next/link";
import { FaGithub } from "react-icons/fa6";
type Contributor = {
githubId: string;
imgUrl: string;
name: string;
};
type GridComponentProps = {
contributors: Contributor[];
};
const ContributorGrid: React.FC<GridComponentProps> = ({ contributors }) => {
return (
<div className="-mb-64 mt-24 grid scale-105 grid-cols-4 gap-6 md:-mb-32 md:grid-cols-8">
{contributors?.map((contributor, index) => (
<div key={index} className={`col-span-1 ${index % 2 !== 0 ? "-mt-8" : ""}`}>
<Link
href={`https://github.com/${contributor.githubId}`}
target="_blank"
className="group transition-transform">
<div className="bg-brand-dark mx-auto -mb-12 flex w-fit max-w-[90%] items-center justify-center rounded-t-xl px-4 pb-3 pt-1 text-sm text-slate-100 transition-all group-hover:-mt-12 group-hover:mb-0">
<FaGithub className="mr-2 h-4 w-4" />
<p className="max-w-[100px] overflow-hidden text-ellipsis whitespace-nowrap">
{contributor.githubId}
</p>
</div>
<Image
src={contributor.imgUrl}
alt={contributor.name}
className="ring-brand-dark rounded-lg ring-offset-4 ring-offset-slate-900 transition-all hover:scale-110 hover:ring-1"
width={500}
height={500}
/>
</Link>
</div>
))}
</div>
);
};
export default ContributorGrid;

View File

@@ -0,0 +1,93 @@
import DeputyBadge from "@/images/formtribe/deputy-batch.png";
import LegendBadge from "@/images/formtribe/legend-batch.png";
import PrimeBadge from "@/images/formtribe/prime-batch.png";
import RookieBadge from "@/images/formtribe/rookie-batch.png";
import Image from "next/image";
import Link from "next/link";
interface Member {
name: string;
githubId: string;
level: string;
imgUrl: string;
}
interface RoadmapProps {
members: Member[];
}
interface BadgeSectionProps {
badgeImage: any;
level: string;
members: Member[];
className: string; // New property for styling
}
const BadgeSection: React.FC<BadgeSectionProps> = ({ badgeImage, level, members, className }) => {
const filteredMembers = members?.filter((member) => member.level === level);
return (
<div className="group flex flex-col items-center space-y-6 pt-12 md:flex-row md:space-x-10 md:px-4">
<Image
src={badgeImage}
alt={`${level} badge`}
className="h-32 w-32 transition-all delay-100 duration-300 group-hover:-rotate-6 group-hover:scale-110"
/>
<div className="grid w-full gap-2 md:grid-cols-3">
{filteredMembers?.length > 0 ? (
filteredMembers?.map((member) => (
<Link
key={member.githubId}
href={`https://github.com/formbricks/formbricks/pulls?q=is:pr+author:${member.githubId}`}
target="_blank"
className={`flex w-full items-center space-x-3 rounded-xl border px-4 py-1 transition-all hover:scale-105 md:px-5 md:py-2 ${className}`}>
<Image
src={member.imgUrl}
alt={member.githubId}
className="mr-3 h-8 w-8 rounded-full md:h-12 md:w-12"
width={100}
height={100}
/>
{member.name}
</Link>
))
) : (
<div className="text-center text-slate-700">No Legends around yet 👀</div>
)}
</div>
</div>
);
};
export const HallOfFame: React.FC<RoadmapProps> = ({ members }) => {
return (
<div className="mx-auto space-y-12 divide-y-2">
<BadgeSection
badgeImage={LegendBadge}
level="legend"
members={members}
className="border-green-300 bg-green-100 text-green-700"
/>
<BadgeSection
badgeImage={PrimeBadge}
level="prime"
members={members}
className="border-indigo-200 bg-indigo-100 text-indigo-700"
/>
<BadgeSection
badgeImage={DeputyBadge}
level="deputy"
members={members}
className="border-orange-200 bg-orange-100 text-orange-700"
/>
<BadgeSection
badgeImage={RookieBadge}
level="rookie"
members={members}
className="border-amber-200 bg-amber-100 text-amber-700"
/>
</div>
);
};
export default HallOfFame;

View File

@@ -1,15 +1,15 @@
import Logo from "@/images/formtribe/formtribe-logo.png";
import { Popover, PopoverContent, PopoverTrigger } from "@formbricks/ui/Popover";
import footerLogoDark from "@/images/logo/footerlogo-dark.svg";
import { Button } from "@formbricks/ui/Button";
import { Popover, PopoverContent, PopoverTrigger } from "@formbricks/ui/Popover";
import { Bars3Icon } from "@heroicons/react/24/solid";
import Image from "next/image";
import Link from "next/link";
import { useState } from "react";
const navigation = [
{ name: "How it works", href: "#how" },
{ name: "Prizes", href: "#prizes" },
{ name: "Leaderboard", href: "#leaderboard" },
{ name: "Roadmap", href: "#roadmap" },
{ name: "Levels", href: "#levels" },
{ name: "Hall of Fame", href: "#hof" },
{ name: "FAQ", href: "#faq" },
];
@@ -17,33 +17,30 @@ export default function HeaderLight() {
const [mobileNavMenuOpen, setMobileNavMenuOpen] = useState(false);
return (
<div className="mx-auto flex w-full items-center justify-between py-6 sm:px-2 ">
<div className="= mx-auto flex w-full max-w-7xl items-center justify-between py-6 sm:px-2 ">
<div className="flex items-center justify-start">
<Link href="/">
<span className="sr-only">FormTribe</span>
<Image alt="Formtribe Logo" src={Logo} className="ml-7 h-8 w-auto sm:h-10" />
<Image alt="Formbricks Logo" src={footerLogoDark} className="h-8 w-auto pl-4 sm:h-10" />
</Link>
<Link
href="https://formbricks.com/github"
target="_blank"
className="ml-6 mt-1 text-sm text-slate-500 hover:scale-105">
className="ml-6 mt-1 text-sm text-slate-300 hover:scale-105">
Star us
</Link>
</div>
{/* Desktop Menu */}
<div className="hidden items-center gap-x-8 text-slate-700 md:flex">
<div className="hidden items-center gap-x-8 text-slate-300 md:flex">
{navigation.map((navItem) => (
<Link key={navItem.name} href={navItem.href} className="hover:scale-105">
{navItem.name}
</Link>
))}
<Button
variant="highlight"
className="font-kablammo ml-2 bg-gradient-to-br from-[#032E1E] via-[#032E1E] to-[#013C27] text-xl"
href="#join">
Join
<Button variant="secondary" size="sm" className="ml-2" href="https://formbricks.com/discord">
Join us!
</Button>
</div>
@@ -52,17 +49,17 @@ export default function HeaderLight() {
<Popover open={mobileNavMenuOpen} onOpenChange={setMobileNavMenuOpen}>
<PopoverTrigger onClick={() => setMobileNavMenuOpen(!mobileNavMenuOpen)}>
<span>
<Bars3Icon className="h-8 w-8 rounded-md bg-slate-200 p-1 text-slate-600" />
<Bars3Icon className="h-8 w-8 rounded-md bg-slate-700 p-1 text-slate-200" />
</span>
</PopoverTrigger>
<PopoverContent className="mr-4 bg-slate-100 shadow">
<PopoverContent className="border-slate-600 bg-slate-700 shadow">
<div className="flex flex-col">
{navigation.map((navItem) => (
<Link key={navItem.name} href={navItem.href}>
<div
onClick={() => setMobileNavMenuOpen(false)}
className="flex items-center space-x-2 rounded-md p-2">
<span className="font-medium text-slate-600">{navItem.name}</span>
<span className="font-medium text-slate-200">{navItem.name}</span>
</div>
</Link>
))}

View File

@@ -10,14 +10,10 @@ interface LayoutProps {
export default function Layout({ title, description, children }: LayoutProps) {
return (
<div className="max-w-8xl mx-auto">
<div className="mx-auto bg-gradient-to-br from-gray-800 via-gray-900 to-gray-900">
<MetaInformation title={title} description={description} />
<HeaderTribe />
{
<main className="relative mx-auto flex w-full max-w-6xl flex-col justify-center px-2 lg:px-8 xl:px-12">
{children}
</main>
}
<main className="">{children}</main>
<Footer />
</div>
);

View File

@@ -0,0 +1,41 @@
import Image from "next/image";
import React from "react";
import { StaticImageData } from "next/image";
type Task = {
title: string;
description: string;
};
type LevelCardProps = {
badgeSrc: StaticImageData; // or string if it's a URL
badgeAlt: string;
title: string;
points: string;
tasks: Task[];
};
const LevelCard: React.FC<LevelCardProps> = ({ badgeSrc, badgeAlt, title, points, tasks }) => (
<div className="group">
<div className="flex w-full flex-col items-center rounded-t-xl bg-slate-700 p-10 transition-colors">
<Image
src={badgeSrc}
alt={badgeAlt}
className="h-32 w-32 transition-all delay-100 duration-300 group-hover:-rotate-6 group-hover:scale-110"
/>
<p className="mt-4 text-lg font-bold text-slate-200">{title}</p>
<p className="text-sm leading-5 text-slate-400">{points}</p>
</div>
<div className="w-full rounded-b-xl bg-slate-600 p-10 text-left">
{tasks?.map((task, index) => (
<React.Fragment key={index}>
<p className="font-bold text-slate-200">{task.title}</p>
<p className="mb-6 leading-5 text-slate-400">{task.description}</p>
</React.Fragment>
))}
</div>
</div>
);
export default LevelCard;

View File

@@ -0,0 +1,45 @@
import Image from "next/image";
import Link from "next/link";
import { FaGithub } from "react-icons/fa6";
type Contributor = {
githubId: string;
imgUrl: string;
name: string;
};
type LevelGridProps = {
contributors: Contributor[];
};
const LevelGrid: React.FC<LevelGridProps> = ({ contributors }) => {
return (
<div className="-mt-64 grid scale-105 grid-cols-4 gap-6 md:-mt-32 md:grid-cols-8">
{contributors?.map((contributor, index) => (
<div key={index} className={`col-span-1 ${index % 2 !== 0 ? "-mt-8" : ""}`}>
<Link
href={`https://github.com/${contributor.githubId}`}
target="_blank"
rel="noopener noreferrer"
className="group transition-transform">
<div className="bg-brand-dark mx-auto -mb-12 flex w-fit max-w-[90%] items-center justify-center rounded-t-xl px-4 pb-3 pt-1 text-sm text-slate-100 transition-all group-hover:-mt-12 group-hover:mb-0">
<FaGithub className="mr-2 h-4 w-4" />
<p className="max-w-[100px] overflow-hidden text-ellipsis whitespace-nowrap">
{contributor.githubId}
</p>
</div>
<Image
src={contributor.imgUrl}
alt={contributor.name}
className="ring-brand-dark rounded-lg ring-offset-4 ring-offset-slate-900 transition-all hover:scale-110 hover:ring-1"
width={500}
height={500}
/>
</Link>
</div>
))}
</div>
);
};
export default LevelGrid;

View File

@@ -0,0 +1,67 @@
import { Button } from "@formbricks/ui/Button";
import { ChevronDownIcon } from "@heroicons/react/24/outline";
import Link from "next/link";
import { FaGithub } from "react-icons/fa6";
interface Event {
name: string;
link?: string;
}
interface EventBlock {
id: string;
description: string;
period: string;
events: Event[];
}
interface RoadmapProps {
data: EventBlock[];
}
export const Roadmap: React.FC<RoadmapProps> = ({ data }) => {
return (
<div className="px-6 text-left">
{data?.map((eventblock) => (
<div key={eventblock.id} className="relative mb-6 border-l-2 border-slate-400 pb-2 pl-12">
<h3 className="my-4 hidden pt-2 font-semibold text-slate-800 md:block">
{eventblock.description} <span className="font-normal">{eventblock.period}</span>
</h3>
<h3 className="my-4 block pt-2 font-semibold text-slate-800 md:hidden">
{eventblock.description} <br></br> <span className="font-normal">{eventblock.period}</span>
</h3>
{eventblock?.events?.map((event) => (
<div key={event.name}>
{event.link ? (
<Link
href={event.link}
target="_blank"
className="group mb-2 flex max-w-fit justify-between rounded-xl border border-slate-200 bg-slate-100 px-6 py-3 text-slate-700 transition-all hover:scale-105 hover:border-slate-300 hover:bg-slate-200">
{event.name}
<FaGithub className="ml-0 inline-block h-6 w-0 text-slate-800 opacity-0 transition-all group-hover:ml-6 group-hover:w-6 group-hover:opacity-100" />
</Link>
) : (
<div className="mb-2 block max-w-fit rounded-xl border border-slate-200 bg-slate-100 px-6 py-3 text-slate-700 transition-all">
{event.name}
</div>
)}
</div>
))}
{eventblock.id === "phlaunch" && (
<Button
href="https://formbricks.com/discord"
target="_blank"
variant="darkCTA"
className="rounded-xl px-5 py-2 text-base transition-all hover:scale-105">
Whats next? Request Features
</Button>
)}
<ChevronDownIcon className="absolute -left-[17px] -mt-3 h-8 w-8 text-slate-400" />
</div>
))}
<h3 className="text-xl font-bold">Internet Domination 😇</h3>
</div>
);
};
export default Roadmap;

View File

@@ -0,0 +1,723 @@
import ArrowGift from "@/images/formtribe/arrow-gift.png";
import HoodieSticker from "@/images/formtribe/arrow-hoodie.png";
import ArrowSticker from "@/images/formtribe/arrow-stickers.png";
import DeputyBadge from "@/images/formtribe/deputy-batch.png";
import LegendBadge from "@/images/formtribe/legend-batch.png";
import PrimeBadge from "@/images/formtribe/prime-batch.png";
import RookieBadge from "@/images/formtribe/rookie-batch.png";
import HallOfFame from "@/pages/community/HallOfFame";
import Roadmap from "@/pages/community/Roadmap";
import LoadingSpinner from "@formbricks/ui/LoadingSpinner";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@formbricks/ui/Tooltip";
import Image from "next/image";
import Link from "next/link";
import { useEffect } from "react";
import ContributorGrid from "./ContributorGrid";
import LayoutTribe from "./LayoutTribe";
import LevelCard from "./LevelCard";
import LevelsGrid from "./LevelGrid";
/* const SideQuests = [
{
points: "Spread the Word Tweet (100 Points)",
quest: "Tweet “🧱🚀” on the day of the ProductHunt launch to spread the word.",
proof: "Share the link to the tweet in the “side-quest” channel.",
},
{
points: "Meme Magic (50 Points + up to 100 Points)",
quest:
"Craft a meme where a brick plays a role. For extra points, tweet it, tag us and score +5 for each like.",
proof: "Share meme or link to the tweet in the “side-quest” channel.",
},
{
points: "GIF Magic (100 Points)",
quest:
"Create a branded gif related to Formbricks. Upload it to Giphy. For extra points, tweet it, tag us and score +5 for each like.",
proof: "Share link to Giphy in the “side-quest” channel.",
},
{
points: "Design a background (250 Points)",
quest: "Illustrate a captivating background for survey enthusiasts (more infos on Notion).",
proof: "Share the design in the “side-quest” channel.",
},
{
points: "Starry-eyed Supporter (250 Points)",
quest: "Get five friends to star our repository.",
proof: "Share 5 screenshots of the chats where you asked them and they confirmed + their GitHub names",
},
{
points: "Bug Hunter (100 Points)",
quest:
"Find and report any bugs in our core product. We will close all bugs on the landing page bc we don't have time for that before the launch :)",
proof: "Open a bug issue in our repository.",
},
{
points: "Brickify someone famous with AI (200 Points + up to 100 Points)",
quest:
"Find someone whose name would be funny as a play on words with “brick”. Then, with the help of AI, create a brick version of this person like Brick Astley, Brickj Minaj, etc. For extra points, tweet it, tag us and score +5 for each like.",
proof: "Share your art or link to the tweet in the “side-quest” channel.",
},
{
points: "Community Connector (50 points each, up to 250 points)",
quest:
"Introduce and onboard new members to the community. Have them join Discord and reply to their automated welcome message with your discord handle (in “say-hi” channel).",
proof: "New member joined and commented with your Discord handle",
},
{
points: "Feedback Fanatic (50 Points)",
quest: "Fill out our feedback survey after the hackathon with suggestions for improvement.",
proof: "Submit the survey.",
},
{
points: "Side Quest Babo (500 Points)",
quest: "Complete all side quests.",
proof: "All quests marked as completed.",
},
]; */
const LevelsData = [
{
badgeSrc: RookieBadge,
badgeAlt: "Rookie Badge",
title: "Repository Rookie",
points: "Level 1",
tasks: [
{ title: "Easy issues", description: "Warm up with the repo, get your first PR merged." },
{ title: "DevRel tasks", description: "Write docs and manuals for better understanding." },
],
},
{
badgeSrc: DeputyBadge,
badgeAlt: "Deputy Badge",
title: "Deploy Deputy",
points: "Level 2",
tasks: [
{ title: "Core Contributions", description: "Work on more complex issues. Get guidance." },
{ title: "Work with core team", description: "Work closely with the core team, learn faster." },
],
},
{
badgeSrc: PrimeBadge,
badgeAlt: "Prime Badge",
title: "Pushmaster Prime",
points: "Level 3",
tasks: [
{ title: "Cash Bounties", description: "Get access to issues with $$$ bounties." },
{ title: "Job Listings", description: "We hire top contributors. Hear about new jobs first!" },
],
},
{
badgeSrc: LegendBadge,
badgeAlt: "Legend Badge",
title: "Formbricks Legend",
points: "Special Honor",
tasks: [{ title: "Unconditional Love", description: "Finally. From the community and core team 🤍" }],
},
];
const TheDeal = [
{
os: "100% free",
free: "Unlimited Surveys",
pro: "Custom URL",
},
{
os: "All community features included",
free: "Unlimited Link Survey Submissions",
pro: "Remove Branding",
},
{
os: "It's your storage, go nuts!",
free: "Upload Limit 10 MB",
pro: "Unlimited Uploads",
},
{
os: "Hook up your own Stripe",
free: "Payments with 2% Mark Up",
pro: "Remove Mark Up from Payments",
},
{
os: "Your server, your rules",
free: "Invite Team Members",
pro: "",
},
{
os: "The 'Do what you want' plan",
free: "Verify Email before Submission",
pro: "",
},
{
os: "at this point I'm just filling rows",
free: "Partial Submissions",
pro: "",
},
{
os: "I should stop",
free: "Custom Thank You Page",
pro: "",
},
{
os: "ok one more",
free: "Close Survey after Submission Limit",
pro: "",
},
{
os: "no flavor like free flavor",
free: "Custom Survey Closed Message",
pro: "",
},
{
os: "...",
free: "Close Survey on Date",
pro: "",
},
{
free: "Redirect on Completion",
pro: "",
},
{
free: "+ all upcoming community-built features",
pro: "",
},
];
const FAQ = [
{
question: "Why do I have to sign a CLA?",
answer:
"To assure this project to be financially viable, we have to be able to relicense the code for enterprise customers and governments. To be able to do so, we are legally obliged to have you sign a CLA.",
},
{
question: "Where will this be hosted?",
answer:
"We offer a Formbricks Cloud hosted in Germany with a generous free plan but you can also easily self-host using Docker.",
},
{
question: "Why is there a Commercial plan?",
answer:
"The commercial plan is for features who break the OSS WIN-WIN Loop or incur additional cost. We charge 29$ if you want a custom domain, remove Formbricks branding, collect large files in surveys or collect payments. We think thats fair :)",
},
{
question: "Are your in app surveys also free forever?",
answer:
"The in app surveys you can run with Formbricks are not part of this Deal. We offer a generous free plan but keep full control over the pricing in the long run. In app surveys are really powerful for products with thousands of users and something has to bring in the dollars.",
},
{
question: "Can anyone join?",
answer:
"Yes! Even when you dont know how to write code you can become part of the community completing side quests. As long as you know how to open a PR you are very welcome to take part irrespective of your age, gender, nationality, food preferences, taste in clothing and favorite Pokemon.",
},
{
question: "How do I level up?",
answer:
"Every PR gives you points - doesnt matter if its for code related tasks or non-code ones. With every point, you move closer to levelling up!",
},
];
const roadmapDates = [
{
id: "earlywork",
description: "Previously at Formbricks",
period: "February until September 2023",
events: [{ name: "Formbricks team building out surveying infrastructure" }],
},
{
id: "hackathon",
description: "Hackathon Kick-Off 🔥",
period: "1st October 2023",
events: [
{ name: "✅ Email Embeds", link: "https://github.com/formbricks/formbricks/pull/873" },
{ name: "✅ Hidden Fields", link: "https://github.com/formbricks/formbricks/pull/1144" },
{
name: "✅ Question Type: Picture Choice",
link: "https://github.com/formbricks/formbricks/pull/1388",
},
{ name: "✅ Question Type: Welcome Card", link: "https://github.com/formbricks/formbricks/pull/1073" },
{ name: "✅ Add Image to Question", link: "https://github.com/formbricks/formbricks/pull/1305" },
{ name: "✅ Dynamic Link Previews", link: "https://github.com/formbricks/formbricks/pull/1093" },
{ name: "✅ Fullscreen Previews", link: "https://github.com/formbricks/formbricks/pull/898" },
{ name: "✅ PIN protected surveys", link: "https://github.com/formbricks/formbricks/pull/1142" },
{ name: "✅ Source Tracking", link: "https://github.com/formbricks/formbricks/pull/1486" },
{ name: "✅ Time To Complete Indicator", link: "https://github.com/formbricks/formbricks/pull/1461" },
],
},
{
id: "phlaunch",
description: "Product Hunt Launch 🚀",
period: "31st October 2023",
events: [
{ name: "✅ Question Type: File Upload", link: "https://github.com/formbricks/formbricks/pull/1277" },
{ name: "✅ Notion Integration", link: "https://github.com/formbricks/formbricks/pull/1197" },
{ name: "✅ Media Backgrounds", link: "https://github.com/formbricks/formbricks/pull/1515" },
{ name: "🚧 Custom Styling", link: "https://github.com/formbricks/formbricks/pull/916" },
{ name: "🚧 Recall Information", link: "https://github.com/formbricks/formbricks/issues/884" },
{ name: "⏳ Unsplash Backgrounds" },
{ name: "⏳ Question Type: Matrix" },
{ name: "⏳ Question Type: Collect payment" },
{ name: "⏳Question Type: Schedule a call (Powered by Cal.com)" },
{ name: "⏳ Question Type: Signature (Powered by Documenso)" },
],
},
];
const members = [
{
name: "Shubham Palriwala",
githubId: "ShubhamPalriwala",
points: "100",
level: "prime",
imgUrl: "https://avatars.githubusercontent.com/u/55556994?v=4",
},
{
name: "Rotimi Best",
githubId: "rotimi-best",
points: "100",
level: "prime",
imgUrl: "https://avatars.githubusercontent.com/u/31730715?v=4",
},
{
name: "Dhruwang Jariwala",
githubId: "Dhruwang",
points: "100",
level: "prime",
imgUrl: "https://avatars.githubusercontent.com/u/67850763?v=4",
},
{
name: "Piyush Gupta",
githubId: "gupta-piyush19",
points: "100",
level: "prime",
imgUrl: "https://avatars.githubusercontent.com/u/56182734?v=4",
},
{
name: "Naitik Kapadia",
githubId: "KapadiaNaitik",
points: "100",
level: "deputy",
imgUrl: "https://avatars.githubusercontent.com/u/88614335?v=4",
},
{
name: "Anshuman Pandey",
githubId: "pandeymangg",
points: "100",
level: "prime",
imgUrl: "https://avatars.githubusercontent.com/u/54475686?v=4",
},
{
name: "Midka",
githubId: "kymppi",
points: "100",
level: "deputy",
imgUrl: "https://avatars.githubusercontent.com/u/48528700?v=4",
},
{
name: "Meet Patel",
githubId: "Meetcpatel",
points: "100",
level: "rookie",
imgUrl: "https://avatars.githubusercontent.com/u/26919832?v=4",
},
{
name: "Ankur Datta",
githubId: "Ankur-Datta-4",
points: "100",
level: "rookie",
imgUrl: "https://avatars.githubusercontent.com/u/75306530?v=4",
},
{
name: "Abhinav Arya",
githubId: "itzabhinavarya",
points: "100",
level: "rookie",
imgUrl: "https://avatars.githubusercontent.com/u/95561280?v=4",
},
{
name: "Anjy Gupta",
githubId: "anjy7",
points: "100",
level: "deputy",
imgUrl: "https://avatars.githubusercontent.com/u/92802904?v=4",
},
{
name: "Aditya Deshlahre",
githubId: "adityadeshlahre",
points: "100",
level: "rookie",
imgUrl: "https://avatars.githubusercontent.com/u/132184385?v=4",
},
{
name: "Ashutosh Bhadauriya",
githubId: "Ashutosh-Bhadauriya",
points: "100",
level: "rookie",
imgUrl: "https://avatars.githubusercontent.com/u/62984427?v=4",
},
{
name: "Bilal Mirza",
githubId: "bilalmirza74",
points: "100",
level: "rookie",
imgUrl: "https://avatars.githubusercontent.com/u/84387676?v=4",
},
{
name: "Timothy",
githubId: "timothyde",
points: "100",
level: "rookie",
imgUrl: "https://avatars.githubusercontent.com/u/13225886?v=4",
},
{
name: "Jonas Höbenreich",
githubId: "jonas-hoebenreich",
points: "100",
level: "rookie",
imgUrl: "https://avatars.githubusercontent.com/u/64426524?v=4",
},
{
name: "Pratik Awaik",
githubId: "PratikAwaik",
points: "100",
level: "deputy",
imgUrl: "https://avatars.githubusercontent.com/u/54103265?v=4",
},
{
name: "Rohan Gupta",
githubId: "rohan9896",
points: "100",
level: "rookie",
imgUrl: "https://avatars.githubusercontent.com/u/56235204?v=4",
},
{
name: "Shubham Khunt",
githubId: "shubhamkhunt04",
points: "100",
level: "rookie",
imgUrl: "https://avatars.githubusercontent.com/u/55044317?v=4",
},
{
name: "Joe",
githubId: "joe-shajan",
points: "100",
level: "rookie",
imgUrl: "https://avatars.githubusercontent.com/u/69904519?v=4",
},
{
name: "Ty Kerr",
githubId: "ty-kerr",
points: "100",
level: "deputy",
imgUrl: "https://avatars.githubusercontent.com/u/17407010?v=4",
},
{
name: "Olasunkanmi Balogun",
githubId: "SiR-PENt",
points: "100",
level: "rookie",
imgUrl: "https://avatars.githubusercontent.com/u/80556643?v=4",
},
{
name: "Ronit Panda",
githubId: "rtpa25",
points: "100",
level: "deputy",
imgUrl: "https://avatars.githubusercontent.com/u/72537293?v=4",
},
{
name: "Nafees Nazik",
githubId: "G3root",
points: "100",
level: "deputy",
imgUrl: "https://avatars.githubusercontent.com/u/84864519?v=4",
},
];
export default function FormTribeHackathon() {
// dark mode fix
useEffect(() => {
document.documentElement.classList.remove("dark");
}, []);
return (
<LayoutTribe
title="Join the FormTribe"
description="We build an Open Source Typeform alternative together and give it to the world. Join us!">
{/* Header */}
<div className="flex h-full w-full flex-col items-center justify-center overflow-clip text-center">
<div className="py-16 md:py-24">
<h1 className="mt-10 px-6 text-3xl font-bold text-slate-100 sm:text-4xl md:text-5xl">
<span className="xl:inline">
Beautiful Open Source Surveys. <br className="hidden md:block"></br>Built as a community, free
forever.
</span>
</h1>
<p className="xs:max-w-none mx-auto mt-3 max-w-xs text-base text-slate-300 sm:text-lg md:mt-6 md:text-xl">
The time is ripe, this is needed. So we ship it as a community - and give it back to the world!
<br></br>Join us and build surveying infrastructure for millions - free and open source.
</p>
</div>
<ContributorGrid contributors={members} />
</div>
{/* Roadmap */}
<div
className="flex flex-col items-center justify-center bg-gradient-to-br from-white to-slate-100 pb-12 text-center md:pb-24"
id="roadmap">
<div className="py-16 md:py-24">
<h2 className="mt-10 text-2xl font-bold text-slate-800 sm:text-3xl md:text-4xl">
<span className="xl:inline">
First Things First: <br></br>An Open Source Typeform Alternative
</span>
</h2>
<p className="xs:max-w-none mx-auto mt-3 max-w-xs text-base text-slate-600 sm:text-lg md:mt-6 md:text-xl">
It&apos;s been requested many times over, so Typeform-like surveys is where we start.
<br></br>In October, we kicked it off in style with a 30-day hackathon.
</p>
</div>
<Roadmap data={roadmapDates} />
</div>
{/* Levels */}
<div
className="mb-12 flex flex-col items-center justify-center overflow-clip text-center lg:mb-40"
id="levels">
<LevelsGrid contributors={members} />
<div className="py-16 md:py-24">
<h2 className="mt-10 px-8 text-2xl font-bold text-slate-100 sm:text-3xl md:text-4xl">
<span className="xl:inline">Write Code, Level Up and Unlock Benefits</span>
</h2>
<p className="xs:max-w-none mx-auto mt-3 max-w-xs text-base text-slate-300 sm:text-lg md:mt-6 md:text-xl">
The more you contribute, the more points you collect.
<br className="hidden md:block"></br> Unlock benefits like cash bounties, limited merch and more!
</p>
</div>
<div className="max-w-8xl grid gap-6 px-8 md:grid-cols-4 lg:px-24">
{LevelsData.map((badge, index) => (
<LevelCard key={index} {...badge} />
))}
</div>
<div className="max-w-8xl mt-8 grid grid-cols-3 gap-4 px-56">
<div className="px-8">
<p className="h-0 text-lg font-bold text-slate-300">+ Sticker Set</p>
<Image src={ArrowSticker} alt="rookie batch" className="" />
</div>
<div className="px-8">
<p className="h-0 text-lg font-bold text-slate-300">+ Hoodie</p>
<Image src={HoodieSticker} alt="rookie batch" className="" />
</div>
<div className="px-8">
<p className="h-0 text-lg font-bold text-slate-300">+ Handmade Gift</p>
<Image src={ArrowGift} alt="rookie batch" className="" />
</div>
</div>
</div>
{/* Become a Legend */}
<div
className="flex flex-col items-center justify-center bg-gradient-to-br from-white to-slate-100 pb-24 text-center"
id="hof">
<div className="py-16 md:py-24">
<h2 className="mt-10 text-2xl font-bold text-slate-800 sm:text-3xl md:text-4xl">
<span className="xl:inline">
Become a<br className="md:hidden"></br> Formbricks Legend
</span>
</h2>
<p className="xs:max-w-none mx-auto mt-3 max-w-xs text-base text-slate-600 sm:text-lg md:mt-6 md:text-xl">
This is your wall of fame. Were honoured to be in this together!
</p>
</div>
<HallOfFame members={members} />
</div>
{/* Our values */}
<div className="mb-24 flex flex-col items-center justify-center text-center md:mb-40">
<div className="py-16 md:py-24">
<h2 className="mt-10 text-2xl font-bold text-slate-100 sm:text-3xl md:text-4xl">
<span className="xl:inline">Our values</span>
</h2>
<p className="xs:max-w-none mx-auto mt-3 max-w-xs text-base text-slate-300 sm:text-lg md:mt-6 md:text-xl">
Apart from being decent human beings, this is what we value:
</p>
</div>
<div className="max-w-8xl grid gap-x-6 gap-y-6 px-8 md:grid-cols-3 md:px-16">
<ValueCard
emoji="🧘‍♂️"
title="Less is more."
description="Like with friends, were about forming deep and meaningful relationships within our community. If you want to merge a PR with improved punctuation to catch a green square, this is likely not the right place for you :)"
/>
<ValueCard
emoji="🤝"
title="Show up & Pull through."
description="When you pick a task up, please make sure to complete it in timely manner. The longer it floats around, the more merge conflicts arise."
/>
<ValueCard
emoji="🍔"
title="Only bite off what you can chew."
description="Open source is all about learning and so is our community. We love help you learn but have to manage our resources well. Please dont take up tasks far outside your area of competence."
/>
</div>
</div>
{/* Side Quests
<div className="mt-16" id="side-quests">
<h3 className="font-kablammo my-4 text-4xl text-slate-800">🏰 Side Quests: Increase your chances</h3>
<p className="w-3/4 text-slate-600">
While code contributions are what gives the most points, everyone gets to bump up their chance of
winning. Here is a list of side quests you can complete:
</p>
<div className="mt-8">
<TooltipProvider delayDuration={50}>
{SideQuests.map((quest) => (
<div key={quest.points}>
<Tooltip>
<TooltipTrigger>
<div className="mb-2 flex items-center gap-x-6">
<div className="text-2xl">✅</div>
<p className="text-left font-bold text-slate-700">
{quest.points}: <span className="font-normal">{quest.quest}</span>
</p>
</div>
</TooltipTrigger>
<TooltipContent side={"top"}>
<p className="py-2 text-center text-slate-500 dark:text-slate-400">
<p className="mt-1 text-sm text-slate-600">Proof: {quest.proof}</p>
</p>
</TooltipContent>
</Tooltip>
</div>
))}
</TooltipProvider>
</div>
<Button
variant="darkCTA"
href="https://formbricks.notion.site/FormTribe-Side-Quests-4ab3b294cfa04e94b77dfddd66378ea2?pvs=4"
target="_blank"
className="mt-6 bg-gradient-to-br from-[#032E1E] via-[#032E1E] to-[#013C27] text-white ">
Keep track with Notion Template
</Button>
</div> */}
{/* The Promise */}
<div className="flex flex-col items-center justify-center bg-gradient-to-br from-white to-slate-100 pb-24 text-center">
<div className="py-16 md:py-24">
<h2 className="mt-10 text-2xl font-bold text-slate-800 sm:text-3xl md:text-4xl">
<span className="xl:inline">The Deal</span>
</h2>
<p className="xs:max-w-none mx-auto mt-3 max-w-xs text-base text-slate-600 sm:text-lg md:mt-6 md:text-xl">
We&apos;re kinda making a handshake agreement here. This is it:
</p>
</div>
<div className="mx-auto max-w-4xl px-4">
<div>
<div className="grid grid-cols-2 items-end rounded-t-lg border border-slate-200 bg-slate-100 px-6 py-3 text-sm font-bold text-slate-800 sm:text-base md:grid-cols-3">
<div>Self-hosted</div>
<div>Formbricks Cloud</div>
<TooltipProvider delayDuration={50}>
<Tooltip>
<TooltipTrigger asChild>
<div className="hidden md:block">
Formbricks Cloud Pro{" "}
<span className="ml-1 hidden rounded-full bg-slate-700 px-2 text-xs font-normal text-white sm:inline">
Why tho?
</span>
</div>
</TooltipTrigger>
<TooltipContent sideOffset={5} className="max-w-lg font-normal">
You can always self-host to get all features free.
</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
{TheDeal.map((feature) => (
<div
key={feature.free}
className="grid grid-cols-2 gap-x-2 border-x border-b border-slate-200 px-6 py-3 text-sm text-slate-900 last:rounded-b-lg md:grid-cols-3">
<div>{feature.os}</div>
<div>{feature.free}</div>
<div className="hidden md:block">{feature.pro}</div>
</div>
))}
</div>
<div className="rounded-lg-12 mt-6 grid-cols-6 rounded-lg bg-slate-100 py-12 sm:grid">
<div className="col-span-1 mr-8 flex items-center justify-center sm:justify-end">
<div className="flex h-12 w-12 items-center justify-center rounded-full bg-white text-3xl">
🤓
</div>
</div>
<div className="col-span-5 px-8 text-left sm:px-0">
<h3 className="mt-4 text-lg font-semibold text-slate-700 sm:mt-0">
Are Formbricks in-app surveys also free?
</h3>
<p className="text-slate-500 sm:pr-16">
Just a heads-up: this deal doesn&apos;t cover Formbricks&apos; in-app surveys. We&apos;ve got
a solid free plan, but we&apos;ve gotta keep some control over pricing to keep things running
long-term.
</p>
</div>
</div>
</div>
</div>
{/* Get started */}
<div className=" mb-40 flex flex-col items-center justify-center text-center">
<div className="py-16 md:py-24">
<h2 className="mt-10 text-2xl font-bold text-slate-100 sm:text-3xl md:text-4xl">
<span className="xl:inline">Get started</span>
</h2>
<p className="xs:max-w-none mx-auto mt-3 max-w-xs text-base italic text-slate-300 sm:text-lg md:mt-6 md:text-xl">
We&apos;re still setting things up,{" "}
<Link
href="https://formbricks.com/discord"
className="decoration-brand-dark underline underline-offset-2">
join our Discord
</Link>{" "}
to stay in the loop :)
</p>
</div>
<LoadingSpinner />
</div>
{/* FAQ */}
<div id="faq" className="bg-gradient-to-br from-white to-slate-100 px-8 pb-24 lg:px-32 ">
<div className="max-w-6xl">
<div className="py-16 md:py-24 ">
<h2 className="mt-10 text-2xl font-bold text-slate-800 sm:text-3xl md:text-4xl">
<span className="xl:inline">FAQ</span>
</h2>
<p className="xs:max-w-none mx-auto mt-3 max-w-xs text-base text-slate-600 sm:text-lg md:mt-6 md:text-xl">
Anything unclear?
</p>
</div>
{FAQ.map((question) => (
<div key={question.question} className="">
<div>
<h3 className="mt-6 text-lg font-bold text-slate-700">{question.question} </h3>
<p className="text-slate-600">{question.answer}</p>
</div>
</div>
))}
</div>
</div>
</LayoutTribe>
);
}
const ValueCard = ({ title, description, emoji }) => {
return (
<div className="rounded-xl bg-slate-800 p-3 text-left">
<div className="mb-4 flex h-24 items-center justify-center rounded-xl border border-slate-600 bg-slate-700 text-6xl">
{emoji}
</div>
<div className="px-2">
<h2 className="text-xl font-bold text-slate-300">
<span className="xl:inline">{title}</span>
</h2>
<p className=" leading-6 text-slate-400">{description}</p>
</div>
</div>
);
};

File diff suppressed because it is too large Load Diff

View File

@@ -97,7 +97,7 @@ const linkSurveys = {
{ name: "Custom Styling", free: true, paid: true, comingSoon: true },
{ name: "Recall Information", free: true, paid: true, comingSoon: true },
{ name: "Collect Payments, Signatures and Appointments", free: true, paid: true, comingSoon: true },
{ name: "Custom URL", free: false, paid: true },
{ name: "Custom URL", free: false, paid: true, comingSoon: true },
{ name: "Remove Formbricks Branding", free: false, paid: true },
],

View File

@@ -1,5 +1,5 @@
# Installer stage: Building the application
FROM node:18-alpine AS installer
FROM node:20-alpine AS installer
RUN corepack enable && corepack prepare pnpm@latest --activate
# Install Supercronic (cron for containers without super user privileges)
@@ -29,7 +29,7 @@ RUN pnpm post-install --filter=web...
RUN pnpm turbo run build --filter=web...
# Runner stage: Setting up the runtime environment
FROM node:18-alpine AS runner
FROM node:20-alpine AS runner
RUN corepack enable && corepack prepare pnpm@latest --activate
RUN apk add --no-cache curl \

View File

@@ -78,7 +78,7 @@ export default function FileUploadSummary({ questionSummary, environmentId }: Fi
{Array.isArray(response.value) &&
(response.value.length > 0 ? (
response.value.map((fileUrl, index) => (
<div className="relative m-2 rounded-lg bg-slate-200">
<div className="relative m-2 rounded-lg bg-slate-200" key={fileUrl}>
<a href={fileUrl as string} key={index} download target="_blank">
<div className="absolute right-0 top-0 m-2">
<div className="flex h-8 w-8 items-center justify-center rounded-lg bg-slate-50 hover:bg-white">

View File

@@ -1,7 +1,9 @@
import { evaluateCondition } from "@/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/summary/components/evaluateLogic";
import { TResponse } from "@formbricks/types/responses";
import { TSurvey } from "@formbricks/types/surveys";
import { useMemo } from "react";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@formbricks/ui/Tooltip";
import { TimerIcon } from "lucide-react";
import { useCallback, useEffect, useMemo, useState } from "react";
interface SummaryDropOffsProps {
survey: TSurvey;
@@ -10,12 +12,45 @@ interface SummaryDropOffsProps {
}
export default function SummaryDropOffs({ responses, survey, displayCount }: SummaryDropOffsProps) {
const getDropoff = () => {
const initialAvgTtc = useMemo(
() =>
survey.questions.reduce((acc, question) => {
acc[question.id] = 0;
return acc;
}, {}),
[survey.questions]
);
const [avgTtc, setAvgTtc] = useState(initialAvgTtc);
interface DropoffMetricsType {
dropoffCount: number[];
viewsCount: number[];
dropoffPercentage: number[];
}
const [dropoffMetrics, setDropoffMetrics] = useState<DropoffMetricsType>({
dropoffCount: [],
viewsCount: [],
dropoffPercentage: [],
});
const calculateMetrics = useCallback(() => {
let totalTtc = { ...initialAvgTtc };
let responseCounts = { ...initialAvgTtc };
let dropoffArr = new Array(survey.questions.length).fill(0);
let viewsArr = new Array(survey.questions.length).fill(0);
let dropoffPercentageArr = new Array(survey.questions.length).fill(0);
responses.forEach((response) => {
// Calculate total time-to-completion
Object.keys(avgTtc).forEach((questionId) => {
if (response.ttc && response.ttc[questionId]) {
totalTtc[questionId] += response.ttc[questionId];
responseCounts[questionId]++;
}
});
let currQuesIdx = 0;
while (currQuesIdx < survey.questions.length) {
@@ -84,6 +119,13 @@ export default function SummaryDropOffs({ responses, survey, displayCount }: Sum
}
});
// Calculate the average time for each question
Object.keys(totalTtc).forEach((questionId) => {
totalTtc[questionId] =
responseCounts[questionId] > 0 ? totalTtc[questionId] / responseCounts[questionId] : 0;
});
// Calculate drop-off percentages
dropoffPercentageArr[0] = (dropoffArr[0] / displayCount) * 100 || 0;
for (let i = 1; i < survey.questions.length; i++) {
if (viewsArr[i - 1] !== 0) {
@@ -91,28 +133,54 @@ export default function SummaryDropOffs({ responses, survey, displayCount }: Sum
}
}
return [dropoffArr, viewsArr, dropoffPercentageArr];
};
return {
newAvgTtc: totalTtc,
dropoffCount: dropoffArr,
viewsCount: viewsArr,
dropoffPercentage: dropoffPercentageArr,
};
}, [responses, survey.questions, displayCount, initialAvgTtc, avgTtc]);
const [dropoffCount, viewsCount, dropoffPercentage] = useMemo(() => getDropoff(), [responses]);
useEffect(() => {
const { newAvgTtc, dropoffCount, viewsCount, dropoffPercentage } = calculateMetrics();
setAvgTtc(newAvgTtc);
setDropoffMetrics({ dropoffCount, viewsCount, dropoffPercentage });
}, [responses]);
return (
<div className="rounded-lg border border-slate-200 bg-slate-50 shadow-sm">
<div className="rounded-b-lg bg-white ">
<div className="grid h-10 grid-cols-5 items-center border-y border-slate-200 bg-slate-100 text-sm font-bold text-slate-600">
<div className="grid h-10 grid-cols-6 items-center border-y border-slate-200 bg-slate-100 text-sm font-semibold text-slate-600">
<div className="col-span-3 pl-4 md:pl-6">Questions</div>
<div className="pl-4 text-center md:pl-6">Views</div>
<div className="px-4 text-center md:px-6">Drop-off</div>
<div className="flex justify-center">
<TooltipProvider delayDuration={50}>
<Tooltip>
<TooltipTrigger>
<TimerIcon className="h-5 w-5" />
</TooltipTrigger>
<TooltipContent side={"top"}>
<p className="text-center font-normal">Average time to complete each question.</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
<div className="px-4 text-center md:px-6">Views</div>
<div className="pr-6 text-center md:pl-6">Drop Offs</div>
</div>
{survey.questions.map((question, i) => (
<div
key={question.id}
className="grid grid-cols-5 items-center border-b border-slate-100 py-2 text-sm text-slate-800 md:text-base">
className="grid grid-cols-6 items-center border-b border-slate-100 py-2 text-sm text-slate-800 md:text-base">
<div className="col-span-3 pl-4 md:pl-6">{question.headline}</div>
<div className="whitespace-pre-wrap pl-6 text-center font-semibold">{viewsCount[i]}</div>
<div className="px-4 text-center md:px-6">
<span className="font-semibold">{dropoffCount[i]} </span>
<span>({Math.round(dropoffPercentage[i])}%)</span>
<div className="whitespace-pre-wrap text-center font-semibold">
{avgTtc[question.id] !== undefined ? (avgTtc[question.id] / 1000).toFixed(2) + "s" : "N/A"}
</div>
<div className="whitespace-pre-wrap text-center font-semibold">
{dropoffMetrics.viewsCount[i]}
</div>
<div className=" pl-6 text-center md:px-6">
<span className="font-semibold">{dropoffMetrics.dropoffCount[i]} </span>
<span>({Math.round(dropoffMetrics.dropoffPercentage[i])}%)</span>
</div>
</div>
))}

View File

@@ -1,9 +1,10 @@
import { timeSinceConditionally } from "@formbricks/lib/time";
import { Button } from "@formbricks/ui/Button";
import { TResponse } from "@formbricks/types/responses";
import { TSurvey } from "@formbricks/types/surveys";
import { Button } from "@formbricks/ui/Button";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@formbricks/ui/Tooltip";
import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/24/solid";
import { useMemo, useState } from "react";
interface SummaryMetadataProps {
responses: TResponse[];
@@ -34,6 +35,21 @@ const StatCard = ({ label, percentage, value, tooltipText }) => (
</TooltipProvider>
);
function formatTime(ttc, totalResponses) {
const seconds = ttc / (1000 * totalResponses);
let formattedValue;
if (seconds >= 60) {
const minutes = Math.floor(seconds / 60);
const remainingSeconds = seconds % 60;
formattedValue = `${minutes}m ${remainingSeconds.toFixed(2)}s`;
} else {
formattedValue = `${seconds.toFixed(2)}s`;
}
return formattedValue;
}
export default function SummaryMetadata({
responses,
survey,
@@ -41,13 +57,28 @@ export default function SummaryMetadata({
setShowDropOffs,
showDropOffs,
}: SummaryMetadataProps) {
const completedResponses = responses.filter((r) => r.finished).length;
const completedResponsesCount = useMemo(() => responses.filter((r) => r.finished).length, [responses]);
const [validTtcResponsesCount, setValidResponsesCount] = useState(0);
const ttc = useMemo(() => {
let validTtcResponsesCountAcc = 0; //stores the count of responses that contains a _total value
const ttc = responses.reduce((acc, response) => {
if (response.ttc._total) {
validTtcResponsesCountAcc++;
return acc + response.ttc._total;
}
return acc;
}, 0);
setValidResponsesCount(validTtcResponsesCountAcc);
return ttc;
}, [responses]);
const totalResponses = responses.length;
return (
<div className="mb-4">
<div className="flex flex-col-reverse gap-y-2 lg:grid lg:grid-cols-2 lg:gap-x-2">
<div className="grid grid-cols-2 gap-4 md:grid md:grid-cols-4 md:gap-x-2">
<div className="flex flex-col-reverse gap-y-2 lg:grid lg:grid-cols-3 lg:gap-x-2">
<div className="grid grid-cols-2 gap-4 md:grid-cols-5 md:gap-x-2 lg:col-span-2">
<div className="flex flex-col justify-between space-y-2 rounded-lg border border-slate-200 bg-white p-4 shadow-sm">
<p className="text-sm text-slate-600">Displays</p>
<p className="text-2xl font-bold text-slate-800">
@@ -62,16 +93,24 @@ export default function SummaryMetadata({
/>
<StatCard
label="Responses"
percentage={`${Math.round((completedResponses / displayCount) * 100)}%`}
value={responses.length === 0 ? <span>-</span> : completedResponses}
percentage={`${Math.round((completedResponsesCount / displayCount) * 100)}%`}
value={responses.length === 0 ? <span>-</span> : completedResponsesCount}
tooltipText="People who completed the survey."
/>
<StatCard
label="Drop Offs"
percentage={`${Math.round(((totalResponses - completedResponses) / totalResponses) * 100)}%`}
value={responses.length === 0 ? <span>-</span> : totalResponses - completedResponses}
percentage={`${Math.round(((totalResponses - completedResponsesCount) / totalResponses) * 100)}%`}
value={responses.length === 0 ? <span>-</span> : totalResponses - completedResponsesCount}
tooltipText="People who started but not completed the survey."
/>
<StatCard
label="Time to Complete"
percentage={null}
value={
validTtcResponsesCount === 0 ? <span>-</span> : `${formatTime(ttc, validTtcResponsesCount)}`
}
tooltipText="Average time to complete the survey."
/>
</div>
<div className="flex flex-col justify-between gap-2 lg:col-span-1">
<div className="text-right text-xs text-slate-400">

View File

@@ -177,6 +177,28 @@ export default function EditWelcomeCard({
</div>
</div>
</div>
{localSurvey?.type === "link" && (
<div className="mt-6 flex items-center">
<div className="mr-2">
<Switch
id="showResponseCount"
name="showResponseCount"
checked={localSurvey?.welcomeCard?.showResponseCount}
onCheckedChange={() =>
updateSurvey({ showResponseCount: !localSurvey.welcomeCard.showResponseCount })
}
/>
</div>
<div className="flex-column">
<Label htmlFor="showResponseCount" className="">
Show Response Count
</Label>
<div className="text-sm text-gray-500 dark:text-gray-400">
Display number of responses for survey
</div>
</div>
</div>
)}
</form>
</Collapsible.CollapsibleContent>
</Collapsible.Root>

View File

@@ -256,7 +256,7 @@ export default function QuestionCard({
) : null}
<div className="mt-4">
<Collapsible.Root open={openAdvanced} onOpenChange={setOpenAdvanced} className="mt-5">
<Collapsible.CollapsibleTrigger className="flex items-center text-xs text-slate-700">
<Collapsible.CollapsibleTrigger className="flex items-center text-sm text-slate-700">
{openAdvanced ? (
<ChevronDownIcon className="mr-1 h-4 w-3" />
) : (

View File

@@ -3,11 +3,12 @@
import Modal from "@/app/(app)/environments/[environmentId]/surveys/components/Modal";
import TabOption from "@/app/(app)/environments/[environmentId]/surveys/components/TabOption";
import { SurveyInline } from "@formbricks/ui/Survey";
import type { TEnvironment } from "@formbricks/types/environment";
import type { TProduct } from "@formbricks/types/product";
import { TUploadFileConfig } from "@formbricks/types/storage";
import { TSurvey } from "@formbricks/types/surveys";
import { Button } from "@formbricks/ui/Button";
import { SurveyInline } from "@formbricks/ui/Survey";
import { ArrowPathRoundedSquareIcon } from "@heroicons/react/24/outline";
import {
ArrowsPointingInIcon,
@@ -17,7 +18,6 @@ import {
} from "@heroicons/react/24/solid";
import { Variants, motion } from "framer-motion";
import { useEffect, useRef, useState } from "react";
import { TUploadFileConfig } from "@formbricks/types/storage";
type TPreviewType = "modal" | "fullwidth" | "email";
@@ -226,6 +226,7 @@ export default function PreviewSurvey({
isBrandingEnabled={product.linkSurveyBranding}
onActiveQuestionChange={setActiveQuestionId}
onFileUpload={onFileUpload}
responseCount={42}
/>
</div>
</div>
@@ -297,6 +298,7 @@ export default function PreviewSurvey({
onActiveQuestionChange={setActiveQuestionId}
isRedirectDisabled={true}
onFileUpload={onFileUpload}
responseCount={42}
/>
</div>
</div>

View File

@@ -23,6 +23,7 @@ const welcomeCardDefault: TSurveyWelcomeCard = {
headline: "Welcome!",
html: "Thanks for providing your feedback - let's go!",
timeToFinish: true,
showResponseCount: false,
};
export const testTemplate: TTemplate = {
@@ -320,6 +321,7 @@ export const testTemplate: TTemplate = {
welcomeCard: {
enabled: false,
timeToFinish: false,
showResponseCount: false,
},
hiddenFields: {
enabled: false,

View File

@@ -2,7 +2,6 @@ import { sendInviteAcceptedEmail } from "@/app/lib/email";
import { verifyInviteToken } from "@formbricks/lib/jwt";
import { authOptions } from "@formbricks/lib/authOptions";
import { getServerSession } from "next-auth";
import { prisma } from "@formbricks/database";
import {
NotLoggedInContent,
WrongAccountContent,
@@ -11,21 +10,20 @@ import {
RightAccountContent,
} from "./components/InviteContentComponents";
import { env } from "@formbricks/lib/env.mjs";
import { deleteInvite, getInvite } from "@formbricks/lib/invite/service";
import { createMembership } from "@formbricks/lib/membership/service";
export default async function JoinTeam({ searchParams }) {
const currentUser = await getServerSession(authOptions);
try {
const { inviteId, email } = await verifyInviteToken(searchParams.token);
const { inviteId, email } = verifyInviteToken(searchParams.token);
const invite = await prisma?.invite.findUnique({
where: { id: inviteId },
include: { creator: true },
});
const invite = await getInvite(inviteId);
const isExpired = (i) => new Date(i.expiresAt) < new Date();
const isInviteExpired = new Date(invite.expiresAt) < new Date();
if (!invite || isExpired(invite)) {
if (!invite || isInviteExpired) {
return <ExpiredContent />;
} else if (invite.accepted) {
return <UsedContent />;
@@ -35,32 +33,10 @@ export default async function JoinTeam({ searchParams }) {
} else if (currentUser.user?.email !== email) {
return <WrongAccountContent />;
} else {
// create membership
await prisma?.membership.create({
data: {
team: {
connect: {
id: invite.teamId,
},
},
user: {
connect: {
id: currentUser.user?.id,
},
},
role: invite.role,
accepted: true,
},
});
await createMembership(invite.teamId, currentUser.user.id, { accepted: true, role: invite.role });
await deleteInvite(inviteId);
// delete invite
await prisma?.invite.delete({
where: {
id: inviteId,
},
});
sendInviteAcceptedEmail(invite.creator.name, currentUser.user?.name, invite.creator.email);
sendInviteAcceptedEmail(invite.creator.name ?? "", currentUser.user?.name, invite.creator.email);
return <RightAccountContent />;
}

View File

@@ -1,7 +1,7 @@
import { responses } from "@/app/lib/api/response";
import { reportUsageToStripe } from "@formbricks/ee/billing/lib/reportUsage";
import { ProductFeatureKeys } from "@formbricks/ee/billing/lib/constants";
import { CRON_SECRET, IS_FORMBRICKS_CLOUD } from "@formbricks/lib/constants";
import { CRON_SECRET } from "@formbricks/lib/constants";
import {
getMonthlyActiveTeamPeopleCount,
getMonthlyTeamResponseCount,
@@ -17,10 +17,6 @@ async function reportTeamUsage(team: TTeam) {
return;
}
if (!IS_FORMBRICKS_CLOUD) {
return;
}
let calculateResponses =
team.billing.features.inAppSurvey.status !== "inactive" && !team.billing.features.inAppSurvey.unlimited;
let calculatePeople =

View File

@@ -16,6 +16,11 @@ export async function POST(request: NextRequest) {
const { json, fields, fileName } = data;
const fallbackFileName = fileName.replace(/[^A-Za-z0-9_.-]/g, "_");
const encodedFileName = encodeURIComponent(fileName)
.replace(/['()]/g, (match) => "%" + match.charCodeAt(0).toString(16))
.replace(/\*/g, "%2A");
const parser = new AsyncParser({
fields,
});
@@ -29,7 +34,10 @@ export async function POST(request: NextRequest) {
const headers = new Headers();
headers.set("Content-Type", "text/csv;charset=utf-8;");
headers.set("Content-Disposition", `attachment; filename=${fileName ?? "converted"}.csv`);
headers.set(
"Content-Disposition",
`attachment; filename="${fallbackFileName}"; filename*=UTF-8''${encodedFileName}`
);
return NextResponse.json(
{

View File

@@ -15,6 +15,11 @@ export async function POST(request: NextRequest) {
const { json, fields, fileName } = data;
const fallbackFileName = fileName.replace(/[^A-Za-z0-9_.-]/g, "_");
const encodedFileName = encodeURIComponent(fileName)
.replace(/['()]/g, (match) => "%" + match.charCodeAt(0).toString(16))
.replace(/\*/g, "%2A");
const wb = xlsx.utils.book_new();
const ws = xlsx.utils.json_to_sheet(json, { header: fields });
xlsx.utils.book_append_sheet(wb, ws, "Sheet1");
@@ -23,8 +28,12 @@ export async function POST(request: NextRequest) {
const base64String = buffer.toString("base64");
const headers = new Headers();
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
headers.set("Content-Disposition", `attachment; filename=${fileName ?? "converted"}.xlsx`);
headers.set(
"Content-Disposition",
`attachment; filename="${fallbackFileName}"; filename*=UTF-8''${encodedFileName}`
);
return NextResponse.json(
{

View File

@@ -46,7 +46,6 @@ export async function GET(
getActionClasses(environmentId),
getProductByEnvironmentId(environmentId),
]);
if (!product) {
throw new Error("Product not found");
}

View File

@@ -3,6 +3,7 @@ import { env } from "@formbricks/lib/env.mjs";
export const formbricksEnabled =
typeof env.NEXT_PUBLIC_FORMBRICKS_API_HOST && env.NEXT_PUBLIC_FORMBRICKS_ENVIRONMENT_ID;
const ttc = { onboarding: 0 };
export const createResponse = async (
surveyId: string,
@@ -11,12 +12,12 @@ export const createResponse = async (
finished: boolean = false
): Promise<any> => {
const api = formbricks.getApi();
return await api.client.response.create({
surveyId,
userId,
finished,
data,
ttc,
});
};
@@ -30,6 +31,7 @@ export const updateResponse = async (
responseId,
finished,
data,
ttc,
});
};

View File

@@ -25,6 +25,7 @@ interface LinkSurveyProps {
singleUseId?: string;
singleUseResponse?: TResponse;
webAppUrl: string;
responseCount?: number;
}
export default function LinkSurvey({
@@ -36,6 +37,7 @@ export default function LinkSurvey({
singleUseId,
singleUseResponse,
webAppUrl,
responseCount,
}: LinkSurveyProps) {
const responseId = singleUseResponse?.id;
const searchParams = useSearchParams();
@@ -161,6 +163,7 @@ export default function LinkSurvey({
...responseUpdate.data,
...hiddenFieldsRecord,
},
ttc: responseUpdate.ttc,
finished: responseUpdate.finished,
meta: {
url: window.location.href,
@@ -186,6 +189,7 @@ export default function LinkSurvey({
activeQuestionId={activeQuestionId}
autoFocus={autoFocus}
prefillResponseData={prefillResponseData}
responseCount={responseCount}
/>
</ContentWrapper>
</>

View File

@@ -14,6 +14,8 @@ import { TResponse } from "@formbricks/types/responses";
import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { getEmailVerificationStatus } from "./lib/helpers";
import { ZId } from "@formbricks/types/environment";
import { getResponseCountBySurveyId } from "@formbricks/lib/response/service";
interface LinkSurveyPageProps {
params: {
@@ -27,6 +29,11 @@ interface LinkSurveyPageProps {
}
export async function generateMetadata({ params }: LinkSurveyPageProps): Promise<Metadata> {
const validId = ZId.safeParse(params.surveyId);
if (!validId.success) {
notFound();
}
const survey = await getSurvey(params.surveyId);
if (!survey || survey.type !== "link" || survey.status === "draft") {
@@ -74,6 +81,10 @@ export async function generateMetadata({ params }: LinkSurveyPageProps): Promise
}
export default async function LinkSurveyPage({ params, searchParams }: LinkSurveyPageProps) {
const validId = ZId.safeParse(params.surveyId);
if (!validId.success) {
notFound();
}
const survey = await getSurvey(params.surveyId);
const suId = searchParams.suId;
@@ -156,7 +167,7 @@ export default async function LinkSurveyPage({ params, searchParams }: LinkSurve
}
const isSurveyPinProtected = Boolean(!!survey && survey.pin);
const responseCount = await getResponseCountBySurveyId(survey.id);
if (isSurveyPinProtected) {
return (
<PinScreen
@@ -182,6 +193,7 @@ export default async function LinkSurveyPage({ params, searchParams }: LinkSurve
singleUseId={isSingleUseSurvey ? singleUseId : undefined}
singleUseResponse={singleUseResponse ? singleUseResponse : undefined}
webAppUrl={WEBAPP_URL}
responseCount={survey.welcomeCard.showResponseCount ? responseCount : undefined}
/>
);
}

View File

@@ -1,6 +1,6 @@
{
"name": "@formbricks/web",
"version": "1.3.3",
"version": "1.3.4",
"private": true,
"scripts": {
"clean": "rimraf .turbo node_modules .next",
@@ -21,27 +21,27 @@
"@formbricks/ui": "workspace:*",
"@headlessui/react": "^1.7.17",
"@heroicons/react": "^2.0.18",
"@json2csv/node": "^7.0.3",
"@json2csv/node": "^7.0.4",
"@paralleldrive/cuid2": "^2.2.2",
"@radix-ui/react-collapsible": "^1.0.3",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@react-email/components": "^0.0.11",
"@sentry/nextjs": "^7.81.1",
"@sentry/nextjs": "^7.84.0",
"@vercel/og": "^0.5.20",
"bcryptjs": "^2.4.3",
"dotenv": "^16.3.1",
"encoding": "^0.1.13",
"framer-motion": "10.16.5",
"googleapis": "^128.0.0",
"framer-motion": "10.16.9",
"googleapis": "^129.0.0",
"jsonwebtoken": "^9.0.2",
"lodash": "^4.17.21",
"lru-cache": "^10.1.0",
"lucide-react": "^0.293.0",
"mime": "^3.0.0",
"lucide-react": "^0.294.0",
"mime": "^4.0.0",
"next": "13.5.6",
"nodemailer": "^6.9.7",
"otplib": "^12.0.1",
"posthog-js": "^1.93.2",
"posthog-js": "^1.93.3",
"prismjs": "^1.29.0",
"qrcode": "^1.5.3",
"react": "18.2.0",

View File

@@ -63,6 +63,7 @@ export default async function handle(req: NextApiRequest, res: NextApiResponse)
surveyId: true,
finished: true,
data: true,
ttc: true,
meta: true,
personAttributes: true,
singleUseId: true,

View File

@@ -107,6 +107,7 @@ export default async function handle(req: NextApiRequest, res: NextApiResponse)
surveyId: true,
finished: true,
data: true,
ttc: true,
meta: true,
personAttributes: true,
singleUseId: true,

View File

@@ -1,4 +1,3 @@
module.exports = {
root: true,
extends: ["formbricks"],
};
extends: [ "turbo", "prettier"],
};

View File

@@ -33,9 +33,10 @@
"devDependencies": {
"@formbricks/types": "workspace:*",
"@formbricks/tsconfig": "workspace:*",
"eslint-config-formbricks": "workspace:*",
"eslint-config-prettier": "^9.0.0",
"eslint-config-turbo": "latest",
"terser": "^5.24.0",
"vite": "^5.0.2",
"vite-plugin-dts": "^3.6.3"
"vite": "^5.0.4",
"vite-plugin-dts": "^3.6.4"
}
}

View File

@@ -24,10 +24,12 @@ export class ResponseAPI {
responseId,
finished,
data,
ttc,
}: TResponseUpdateInputWithResponseId): Promise<Result<{}, NetworkError | Error>> {
return makeRequest(this.apiHost, `/api/v1/client/${this.environmentId}/responses/${responseId}`, "PUT", {
finished,
data,
ttc,
});
}
}

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Response" ADD COLUMN "ttc" JSONB NOT NULL DEFAULT '{}';

View File

@@ -118,6 +118,9 @@ model Response {
/// @zod.custom(imports.ZResponseData)
/// [ResponseData]
data Json @default("{}")
/// @zod.custom(imports.ZResponseTtc)
/// [ResponseTtc]
ttc Json @default("{}")
/// @zod.custom(imports.ZResponseMeta)
/// [ResponseMeta]
meta Json @default("{}")

View File

@@ -4,7 +4,12 @@ export const ZActionProperties = z.record(z.string());
export { ZActionClassNoCodeConfig } from "@formbricks/types/actionClasses";
export { ZIntegrationConfig } from "@formbricks/types/integration";
export { ZResponseData, ZResponsePersonAttributes, ZResponseMeta } from "@formbricks/types/responses";
export {
ZResponseData,
ZResponsePersonAttributes,
ZResponseMeta,
ZResponseTtc,
} from "@formbricks/types/responses";
export {
ZSurveyWelcomeCard,

View File

@@ -18,6 +18,6 @@
},
"dependencies": {
"@formbricks/lib": "workspace:*",
"stripe": "^14.5.0"
"stripe": "^14.6.0"
}
}

View File

@@ -1,4 +1,3 @@
module.exports = {
root: true,
extends: ["formbricks"],
};
extends: [ "turbo", "prettier"],
};

View File

@@ -1,7 +1,7 @@
{
"name": "@formbricks/js",
"license": "MIT",
"version": "1.2.5",
"version": "1.2.6",
"description": "Formbricks-js allows you to connect your app to Formbricks, display surveys and trigger events.",
"keywords": [
"Formbricks",
@@ -34,8 +34,8 @@
},
"author": "Formbricks <hola@formbricks.com>",
"devDependencies": {
"@babel/core": "^7.23.3",
"@babel/preset-env": "^7.23.3",
"@babel/core": "^7.23.5",
"@babel/preset-env": "^7.23.5",
"@babel/preset-typescript": "^7.23.3",
"@formbricks/api": "workspace:*",
"@formbricks/lib": "workspace:*",
@@ -43,18 +43,19 @@
"@formbricks/tsconfig": "workspace:*",
"@formbricks/types": "workspace:*",
"@types/jest": "^29.5.10",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"babel-jest": "^29.7.0",
"cross-env": "^7.0.3",
"eslint-config-formbricks": "workspace:*",
"isomorphic-fetch": "^3.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-fetch-mock": "^3.0.3",
"terser": "^5.24.0",
"vite": "^5.0.2",
"vite-plugin-dts": "^3.6.3"
"vite": "^5.0.4",
"vite-plugin-dts": "^3.6.4",
"eslint-config-prettier": "^9.0.0",
"eslint-config-turbo": "latest"
},
"jest": {
"transformIgnorePatterns": [

View File

@@ -128,6 +128,7 @@ export const renderWidget = (survey: TSurvey) => {
responseQueue.updateSurveyState(surveyState);
responseQueue.add({
data: responseUpdate.data,
ttc: responseUpdate.ttc,
finished: responseUpdate.finished,
});
},

View File

@@ -0,0 +1,23 @@
import { prisma } from "@formbricks/database";
import { Prisma } from "@prisma/client";
import { DatabaseError } from "@formbricks/types/errors";
import { validateInputs } from "../utils/validate";
import { ZAccountInput, TAccountInput, TAccount } from "@formbricks/types/account";
export const createAccount = async (accountData: TAccountInput): Promise<TAccount> => {
validateInputs([accountData, ZAccountInput]);
try {
const account = await prisma.account.create({
data: accountData,
});
return account;
} catch (error) {
if (error instanceof Prisma.PrismaClientKnownRequestError) {
throw new DatabaseError(error.message);
}
throw error;
}
};

View File

@@ -3,13 +3,17 @@ import { verifyPassword } from "@/app/lib/auth";
import { prisma } from "@formbricks/database";
import { EMAIL_VERIFICATION_DISABLED } from "./constants";
import { verifyToken } from "./jwt";
import { getProfileByEmail, updateProfile } from "./profile/service";
import { createProfile, getProfileByEmail, updateProfile } from "./profile/service";
import type { IdentityProvider } from "@prisma/client";
import type { NextAuthOptions } from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials";
import GitHubProvider from "next-auth/providers/github";
import GoogleProvider from "next-auth/providers/google";
import AzureAD from "next-auth/providers/azure-ad";
import { createTeam } from "./team/service";
import { createProduct } from "./product/service";
import { createAccount } from "./account/service";
import { createMembership } from "./membership/service";
export const authOptions: NextAuthOptions = {
providers: [
@@ -205,120 +209,21 @@ export const authOptions: NextAuthOptions = {
return "/auth/login?error=A%20user%20with%20this%20email%20exists%20already.";
}
await prisma.user.create({
data: {
name: user.name,
email: user.email,
emailVerified: new Date(Date.now()),
onboardingCompleted: false,
identityProvider: provider,
identityProviderAccountId: user.id as string,
accounts: {
create: [{ ...account }],
},
memberships: {
create: [
{
accepted: true,
role: "owner",
// @ts-ignore
team: {
create: {
name: `${user.name}'s Team`,
products: {
create: [
{
name: "My Product",
environments: {
create: [
{
type: "production",
actionClasses: {
create: [
{
name: "New Session",
description: "Gets fired when a new session is created",
type: "automatic",
},
{
name: "Exit Intent (Desktop)",
description: "A user on Desktop leaves the website with the cursor.",
type: "automatic",
},
{
name: "50% Scroll",
description: "A user scrolled 50% of the current page",
type: "automatic",
},
],
},
attributeClasses: {
create: [
{
name: "userId",
description: "The internal ID of the person",
type: "automatic",
},
{
name: "email",
description: "The email of the person",
type: "automatic",
},
],
},
},
{
type: "development",
actionClasses: {
create: [
{
name: "New Session",
description: "Gets fired when a new session is created",
type: "automatic",
},
{
name: "Exit Intent (Desktop)",
description: "A user on Desktop leaves the website with the cursor.",
type: "automatic",
},
{
name: "50% Scroll",
description: "A user scrolled 50% of the current page",
type: "automatic",
},
],
},
attributeClasses: {
create: [
{
name: "userId",
description: "The internal ID of the person",
type: "automatic",
},
{
name: "email",
description: "The email of the person",
type: "automatic",
},
],
},
},
],
},
},
],
},
},
},
},
],
},
},
include: {
memberships: true,
},
const userProfile = await createProfile({
name: user.name,
email: user.email,
emailVerified: new Date(Date.now()),
onboardingCompleted: false,
identityProvider: provider,
identityProviderAccountId: account.providerAccountId,
});
const team = await createTeam({ name: userProfile.name + "'s Team" });
await createAccount({
...account,
userId: userProfile.id,
});
await createProduct(team.id, { name: "My Product" });
await createMembership(team.id, userProfile.id, { role: "owner", accepted: true });
return true;
}

View File

@@ -81,8 +81,8 @@ export const LOGIN_RATE_LIMIT = {
allowedPerInterval: 30,
};
export const CLIENT_SIDE_API_RATE_LIMIT = {
interval: 10 * 60 * 1000, // 60 minutes
allowedPerInterval: 50,
interval: 10 * 15 * 1000, // 15 minutes
allowedPerInterval: 60,
};
// Enterprise License constant

View File

@@ -114,7 +114,9 @@ export const deleteInvite = async (inviteId: string): Promise<TInvite> => {
}
};
export const getInvite = async (inviteId: string): Promise<{ inviteId: string; email: string }> =>
export const getInvite = async (
inviteId: string
): Promise<TInvite & { creator: { name: string | null; email: string } }> =>
unstable_cache(
async () => {
validateInputs([inviteId, ZString]);
@@ -123,8 +125,13 @@ export const getInvite = async (inviteId: string): Promise<{ inviteId: string; e
where: {
id: inviteId,
},
select: {
email: true,
include: {
creator: {
select: {
name: true,
email: true,
},
},
},
});
@@ -132,10 +139,7 @@ export const getInvite = async (inviteId: string): Promise<{ inviteId: string; e
throw new ResourceNotFoundError("Invite", inviteId);
}
return {
inviteId,
email: invite.email,
};
return invite;
},
[`getInvite-${inviteId}`],
{ tags: [inviteCache.tag.byId(inviteId)], revalidate: SERVICES_REVALIDATION_INTERVAL }

View File

@@ -48,14 +48,16 @@ export async function verifyToken(token: string, userEmail: string = ""): Promis
return jwt.verify(token, env.NEXTAUTH_SECRET + userEmail) as JwtPayload;
}
export const verifyInviteToken = (token: string): JwtPayload => {
export const verifyInviteToken = (token: string): { inviteId: string; email: string } => {
try {
const decoded = jwt.decode(token);
const payload: JwtPayload = decoded as JwtPayload;
const { inviteId, email } = payload;
return {
inviteId: payload.inviteId,
email: payload.email,
inviteId,
email,
};
} catch (error) {
console.error("Error verifying invite token:", error);

View File

@@ -12,11 +12,11 @@
"lint:report": "eslint . --format json --output-file ../../lint-results/app-store.json"
},
"dependencies": {
"@aws-sdk/s3-presigned-post": "^3.458.0",
"@aws-sdk/s3-presigned-post": "3.458.0",
"@aws-sdk/client-s3": "3.458.0",
"@aws-sdk/s3-request-presigner": "3.458.0",
"@t3-oss/env-nextjs": "^0.7.1",
"mime": "3.0.0",
"mime": "4.0.0",
"@formbricks/api": "*",
"@formbricks/database": "*",
"@formbricks/types": "*",

View File

@@ -20,7 +20,7 @@ import { unstable_cache } from "next/cache";
import { ITEMS_PER_PAGE, SERVICES_REVALIDATION_INTERVAL } from "../constants";
import { deleteDisplayByResponseId } from "../display/service";
import { createPerson, getPerson, getPersonByUserId, transformPrismaPerson } from "../person/service";
import { formatResponseDateFields } from "../response/util";
import { calculateTtcTotal, formatResponseDateFields } from "../response/util";
import { responseNoteCache } from "../responseNote/cache";
import { getResponseNotes } from "../responseNote/service";
import { captureTelemetry } from "../telemetry";
@@ -35,6 +35,7 @@ const responseSelection = {
finished: true,
data: true,
meta: true,
ttc: true,
personAttributes: true,
singleUseId: true,
person: {
@@ -269,7 +270,14 @@ export const createResponseLegacy = async (responseInput: TResponseLegacyInput):
if (responseInput.personId) {
person = await getPerson(responseInput.personId);
}
const ttcTemp = responseInput.ttc;
const questionId = Object.keys(ttcTemp)[0];
const ttc = responseInput.finished
? {
...ttcTemp,
_total: ttcTemp[questionId], // Add _total property with the same value
}
: ttcTemp;
const responsePrisma = await prisma.response.create({
data: {
survey: {
@@ -279,6 +287,7 @@ export const createResponseLegacy = async (responseInput: TResponseLegacyInput):
},
finished: responseInput.finished,
data: responseInput.data,
ttc,
...(responseInput.personId && {
person: {
connect: {
@@ -287,6 +296,7 @@ export const createResponseLegacy = async (responseInput: TResponseLegacyInput):
},
personAttributes: person?.attributes,
}),
...(responseInput.meta && ({ meta: responseInput?.meta } as Prisma.JsonObject)),
singleUseId: responseInput.singleUseId,
},
@@ -502,6 +512,7 @@ export const updateResponse = async (
...currentResponse.data,
...responseInput.data,
};
const ttc = responseInput.finished ? calculateTtcTotal(responseInput.ttc) : responseInput.ttc;
const responsePrisma = await prisma.response.update({
where: {
@@ -510,6 +521,7 @@ export const updateResponse = async (
data: {
finished: responseInput.finished,
data,
ttc,
},
select: responseSelection,
});

View File

@@ -1,6 +1,6 @@
import "server-only";
import { TResponseDates } from "@formbricks/types/responses";
import { TResponseDates, TResponseTtc } from "@formbricks/types/responses";
export const formatResponseDateFields = (response: TResponseDates): TResponseDates => {
if (typeof response.createdAt === "string") {
@@ -24,3 +24,10 @@ export const formatResponseDateFields = (response: TResponseDates): TResponseDat
return response;
};
export function calculateTtcTotal(ttc: TResponseTtc) {
const result = { ...ttc };
result._total = Object.values(result).reduce((acc: number, val: number) => acc + val, 0);
return result;
}

View File

@@ -5,7 +5,7 @@ export class SurveyState {
displayId: string | null = null;
userId: string | null = null;
surveyId: string;
responseAcc: TResponseUpdate = { finished: false, data: {} };
responseAcc: TResponseUpdate = { finished: false, data: {}, ttc: {} };
singleUseId: string | null;
constructor(
@@ -74,6 +74,7 @@ export class SurveyState {
accumulateResponse(responseUpdate: TResponseUpdate) {
this.responseAcc = {
finished: responseUpdate.finished,
ttc: responseUpdate.ttc,
data: { ...this.responseAcc.data, ...responseUpdate.data },
};
}
@@ -90,7 +91,7 @@ export class SurveyState {
*/
clear() {
this.responseId = null;
this.responseAcc = { finished: false, data: {} };
this.responseAcc = { finished: false, data: {}, ttc: {} };
}
}

View File

@@ -1,4 +1,3 @@
module.exports = {
root: true,
extends: ["formbricks"],
};
extends: [ "turbo", "prettier"],
};

View File

@@ -28,13 +28,14 @@
"@formbricks/types": "workspace:*",
"@preact/preset-vite": "^2.7.0",
"autoprefixer": "^10.4.16",
"eslint-config-formbricks": "workspace:*",
"postcss": "^8.4.31",
"preact": "^10.19.2",
"tailwindcss": "^3.3.5",
"terser": "^5.24.0",
"vite": "^5.0.2",
"vite-plugin-dts": "^3.6.3",
"vite-tsconfig-paths": "^4.2.1"
"vite": "^5.0.4",
"vite-plugin-dts": "^3.6.4",
"vite-tsconfig-paths": "^4.2.1",
"eslint-config-prettier": "^9.0.0",
"eslint-config-turbo": "latest"
}
}

View File

@@ -1,51 +1,44 @@
import { TSurvey } from "@formbricks/types/surveys";
import { useEffect, useState } from "preact/hooks";
import Progress from "./Progress";
import { calculateElementIdx } from "@/lib/utils";
import { useCallback, useMemo } from "preact/hooks";
interface ProgressBarProps {
survey: TSurvey;
questionId: string;
}
const PROGRESS_INCREMENT = 0.1;
export default function ProgressBar({ survey, questionId }: ProgressBarProps) {
const [progress, setProgress] = useState(0); // [0, 1]
const [prevQuestionIdx, setPrevQuestionIdx] = useState(0); // [0, survey.questions.length
const [prevQuestionId, setPrevQuestionId] = useState(""); // [0, survey.questions.length
const currentQuestionIdx = useMemo(
() => survey.questions.findIndex((e) => e.id === questionId),
[survey, questionId]
);
useEffect(() => {
// calculate progress
setProgress(calculateProgress(questionId, survey, progress));
function calculateProgress(questionId: string, survey: TSurvey, progress: number) {
if (survey.questions.length === 0) return 0;
if (questionId === "end") return 1;
let currentQustionIdx = survey.questions.findIndex((e) => e.id === questionId);
if (progress > 0 && questionId === prevQuestionId) return progress;
if (currentQustionIdx === -1) currentQustionIdx = 0;
const elementIdx = calculateElementIdx(survey, currentQustionIdx);
const calculateProgress = useCallback((questionId: string, survey: TSurvey, progress: number) => {
if (survey.questions.length === 0) return 0;
let currentQustionIdx = survey.questions.findIndex((e) => e.id === questionId);
if (currentQustionIdx === -1) currentQustionIdx = 0;
const elementIdx = calculateElementIdx(survey, currentQustionIdx);
const newProgress = elementIdx / survey.questions.length;
// Determine if user went backwards in the survey
const didUserGoBackwards = currentQustionIdx < prevQuestionIdx;
// Update the progress array based on user's navigation
let updatedProgress = progress;
if (didUserGoBackwards) {
updatedProgress = progress - (prevQuestionIdx - currentQustionIdx) * PROGRESS_INCREMENT;
} else if (newProgress > progress) {
updatedProgress = newProgress;
} else if (newProgress <= progress && progress + PROGRESS_INCREMENT <= 1) {
updatedProgress = progress + PROGRESS_INCREMENT;
}
setPrevQuestionId(questionId);
setPrevQuestionIdx(currentQustionIdx);
return updatedProgress;
const newProgress = elementIdx / survey.questions.length;
let updatedProgress = progress;
if (newProgress > progress) {
updatedProgress = newProgress;
} else if (newProgress <= progress && progress + 0.1 <= 1) {
updatedProgress = progress + 0.1;
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [questionId, survey, setPrevQuestionIdx]);
return updatedProgress;
}, []);
return <Progress progress={progress} />;
const progressArray = useMemo(() => {
let progress = 0;
let progressArrayTemp: number[] = [];
survey.questions.forEach((question) => {
progress = calculateProgress(question.id, survey, progress);
progressArrayTemp.push(progress);
});
return progressArrayTemp;
}, [calculateProgress, survey]);
return <Progress progress={questionId === "end" ? 1 : progressArray[currentQuestionIdx]} />;
}

View File

@@ -7,7 +7,7 @@ import NPSQuestion from "@/components/questions/NPSQuestion";
import OpenTextQuestion from "@/components/questions/OpenTextQuestion";
import PictureSelectionQuestion from "@/components/questions/PictureSelectionQuestion";
import RatingQuestion from "@/components/questions/RatingQuestion";
import { TResponseData } from "@formbricks/types/responses";
import { TResponseData, TResponseTtc } from "@formbricks/types/responses";
import { TUploadFileConfig } from "@formbricks/types/storage";
import { TSurveyQuestion, TSurveyQuestionType } from "@formbricks/types/surveys";
@@ -15,12 +15,14 @@ interface QuestionConditionalProps {
question: TSurveyQuestion;
value: string | number | string[];
onChange: (responseData: TResponseData) => void;
onSubmit: (data: TResponseData) => void;
onSubmit: (data: TResponseData, ttc: TResponseTtc) => void;
onBack: () => void;
onFileUpload: (file: File, config?: TUploadFileConfig) => Promise<string>;
isFirstQuestion: boolean;
isLastQuestion: boolean;
autoFocus?: boolean;
ttc: TResponseTtc;
setTtc: (ttc: TResponseTtc) => void;
surveyId: string;
}
@@ -33,6 +35,8 @@ export default function QuestionConditional({
isFirstQuestion,
isLastQuestion,
autoFocus = true,
ttc,
setTtc,
surveyId,
onFileUpload,
}: QuestionConditionalProps) {
@@ -46,6 +50,8 @@ export default function QuestionConditional({
isFirstQuestion={isFirstQuestion}
isLastQuestion={isLastQuestion}
autoFocus={autoFocus}
ttc={ttc}
setTtc={setTtc}
/>
) : question.type === TSurveyQuestionType.MultipleChoiceSingle ? (
<MultipleChoiceSingleQuestion
@@ -56,6 +62,8 @@ export default function QuestionConditional({
onBack={onBack}
isFirstQuestion={isFirstQuestion}
isLastQuestion={isLastQuestion}
ttc={ttc}
setTtc={setTtc}
/>
) : question.type === TSurveyQuestionType.MultipleChoiceMulti ? (
<MultipleChoiceMultiQuestion
@@ -66,6 +74,8 @@ export default function QuestionConditional({
onBack={onBack}
isFirstQuestion={isFirstQuestion}
isLastQuestion={isLastQuestion}
ttc={ttc}
setTtc={setTtc}
/>
) : question.type === TSurveyQuestionType.NPS ? (
<NPSQuestion
@@ -76,6 +86,8 @@ export default function QuestionConditional({
onBack={onBack}
isFirstQuestion={isFirstQuestion}
isLastQuestion={isLastQuestion}
ttc={ttc}
setTtc={setTtc}
/>
) : question.type === TSurveyQuestionType.CTA ? (
<CTAQuestion
@@ -86,6 +98,8 @@ export default function QuestionConditional({
onBack={onBack}
isFirstQuestion={isFirstQuestion}
isLastQuestion={isLastQuestion}
ttc={ttc}
setTtc={setTtc}
/>
) : question.type === TSurveyQuestionType.Rating ? (
<RatingQuestion
@@ -96,6 +110,8 @@ export default function QuestionConditional({
onBack={onBack}
isFirstQuestion={isFirstQuestion}
isLastQuestion={isLastQuestion}
ttc={ttc}
setTtc={setTtc}
/>
) : question.type === TSurveyQuestionType.Consent ? (
<ConsentQuestion
@@ -106,6 +122,8 @@ export default function QuestionConditional({
onBack={onBack}
isFirstQuestion={isFirstQuestion}
isLastQuestion={isLastQuestion}
ttc={ttc}
setTtc={setTtc}
/>
) : question.type === TSurveyQuestionType.PictureSelection ? (
<PictureSelectionQuestion
@@ -116,6 +134,8 @@ export default function QuestionConditional({
onBack={onBack}
isFirstQuestion={isFirstQuestion}
isLastQuestion={isLastQuestion}
ttc={ttc}
setTtc={setTtc}
/>
) : question.type === TSurveyQuestionType.FileUpload ? (
<FileUploadQuestion
@@ -128,6 +148,8 @@ export default function QuestionConditional({
isFirstQuestion={isFirstQuestion}
isLastQuestion={isLastQuestion}
onFileUpload={onFileUpload}
ttc={ttc}
setTtc={setTtc}
/>
) : null;
}

View File

@@ -1,11 +1,11 @@
import FormbricksBranding from "@/components/general/FormbricksBranding";
import ProgressBar from "@/components/general/ProgressBar";
import { AutoCloseWrapper } from "@/components/wrappers/AutoCloseWrapper";
import { evaluateCondition } from "@/lib/logicEvaluator";
import { cn } from "@/lib/utils";
import { SurveyBaseProps } from "@/types/props";
import type { TResponseData } from "@formbricks/types/responses";
import type { TResponseData, TResponseTtc } from "@formbricks/types/responses";
import { useEffect, useRef, useState } from "preact/hooks";
import ProgressBar from "./ProgressBar";
import QuestionConditional from "./QuestionConditional";
import ThankYouCard from "./ThankYouCard";
import WelcomeCard from "./WelcomeCard";
@@ -22,6 +22,7 @@ export function Survey({
isRedirectDisabled = false,
prefillResponseData,
onFileUpload,
responseCount,
}: SurveyBaseProps) {
const [questionId, setQuestionId] = useState(
activeQuestionId || (survey.welcomeCard.enabled ? "start" : survey?.questions[0]?.id)
@@ -32,7 +33,7 @@ export function Survey({
const currentQuestionIndex = survey.questions.findIndex((q) => q.id === questionId);
const currentQuestion = survey.questions[currentQuestionIndex];
const contentRef = useRef<HTMLDivElement | null>(null);
const [ttc, setTtc] = useState<TResponseTtc>({});
useEffect(() => {
if (activeQuestionId === "hidden") return;
if (activeQuestionId === "start" && !survey.welcomeCard.enabled) {
@@ -53,7 +54,7 @@ export function Survey({
// call onDisplay when component is mounted
onDisplay();
if (prefillResponseData) {
onSubmit(prefillResponseData, true);
onSubmit(prefillResponseData, {}, true);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
@@ -90,11 +91,12 @@ export function Survey({
setResponseData(updatedResponseData);
};
const onSubmit = (responseData: TResponseData, isFromPrefilling: Boolean = false) => {
const onSubmit = (responseData: TResponseData, ttc: TResponseTtc, isFromPrefilling: Boolean = false) => {
const questionId = Object.keys(responseData)[0];
setLoadingElement(true);
const nextQuestionId = getNextQuestionId(responseData, isFromPrefilling);
const finished = nextQuestionId === "end";
onResponse({ data: responseData, finished });
onResponse({ data: responseData, ttc, finished });
if (finished) {
onFinished();
}
@@ -129,9 +131,9 @@ export function Survey({
html={survey.welcomeCard.html}
fileUrl={survey.welcomeCard.fileUrl}
buttonLabel={survey.welcomeCard.buttonLabel}
timeToFinish={survey.welcomeCard.timeToFinish}
onSubmit={onSubmit}
survey={survey}
responseCount={responseCount}
/>
);
} else if (questionId === "end" && survey.thankYouCard.enabled) {
@@ -154,6 +156,8 @@ export function Survey({
onChange={onChange}
onSubmit={onSubmit}
onBack={onBack}
ttc={ttc}
setTtc={setTtc}
onFileUpload={onFileUpload}
isFirstQuestion={
history && prefillResponseData

View File

@@ -12,6 +12,7 @@ export function SurveyInline({
prefillResponseData,
isRedirectDisabled = false,
onFileUpload,
responseCount,
}: SurveyBaseProps) {
return (
<div id="fbjs" className="formbricks-form h-full w-full">
@@ -26,6 +27,7 @@ export function SurveyInline({
prefillResponseData={prefillResponseData}
isRedirectDisabled={isRedirectDisabled}
onFileUpload={onFileUpload}
responseCount={responseCount}
/>
</div>
);

View File

@@ -18,6 +18,7 @@ export function SurveyModal({
onFinished = () => {},
onFileUpload,
isRedirectDisabled = false,
responseCount,
}: SurveyModalProps) {
const [isOpen, setIsOpen] = useState(true);
@@ -55,6 +56,7 @@ export function SurveyModal({
}}
onFileUpload={onFileUpload}
isRedirectDisabled={isRedirectDisabled}
responseCount={responseCount}
/>
</Modal>
</div>

View File

@@ -1,5 +1,6 @@
import SubmitButton from "@/components/buttons/SubmitButton";
import { calculateElementIdx } from "@/lib/utils";
import { TResponseData, TResponseTtc } from "@formbricks/types/responses";
import { TSurvey } from "@formbricks/types/surveys";
import Headline from "./Headline";
import HtmlBody from "./HtmlBody";
@@ -9,9 +10,9 @@ interface WelcomeCardProps {
html?: string;
fileUrl?: string;
buttonLabel?: string;
timeToFinish?: boolean;
onSubmit: (data: { [x: string]: any }) => void;
onSubmit: (data: TResponseData, ttc: TResponseTtc) => void;
survey: TSurvey;
responseCount?: number;
}
const TimerIcon = () => {
@@ -31,14 +32,34 @@ const TimerIcon = () => {
);
};
const UsersIcon = () => {
return (
<div className="mr-1">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="h-4 w-4">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M15 19.128a9.38 9.38 0 002.625.372 9.337 9.337 0 004.121-.952 4.125 4.125 0 00-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 018.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0111.964-3.07M12 6.375a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zm8.25 2.25a2.625 2.625 0 11-5.25 0 2.625 2.625 0 015.25 0z"
/>
</svg>
</div>
);
};
export default function WelcomeCard({
headline,
html,
fileUrl,
buttonLabel,
timeToFinish,
onSubmit,
survey,
responseCount,
}: WelcomeCardProps) {
const calculateTimeToComplete = () => {
let idx = calculateElementIdx(survey, 0);
@@ -68,6 +89,9 @@ export default function WelcomeCard({
return `${minutes} minutes`;
};
const timeToFinish = survey.welcomeCard.timeToFinish;
const showResponseCount = survey.welcomeCard.showResponseCount;
return (
<div>
{fileUrl && (
@@ -85,19 +109,37 @@ export default function WelcomeCard({
isLastQuestion={false}
focus={true}
onClick={() => {
onSubmit({ ["welcomeCard"]: "clicked" });
onSubmit({ ["welcomeCard"]: "clicked" }, {});
}}
type="button"
/>
<div className="text-subheading flex items-center text-xs">Press Enter </div>
</div>
</div>
{timeToFinish && (
{timeToFinish && !showResponseCount ? (
<div className="item-center mt-4 flex text-slate-500">
<TimerIcon />
<p className="text-xs">Takes {calculateTimeToComplete()}</p>
<p className="pt-1 text-xs">
<span> Takes {calculateTimeToComplete()} </span>
</p>
</div>
)}
) : showResponseCount && !timeToFinish && responseCount && responseCount > 3 ? (
<div className="item-center mt-4 flex text-slate-500">
<UsersIcon />
<p className="pt-1 text-xs">
<span>{`${responseCount} people responded`}</span>
</p>
</div>
) : timeToFinish && showResponseCount ? (
<div className="item-center mt-4 flex text-slate-500">
<TimerIcon />
<p className="pt-1 text-xs">
<span> Takes {calculateTimeToComplete()} </span>
<span>{responseCount && responseCount > 3 ? `${responseCount} people responded` : ""}</span>
</p>
</div>
) : null}
</div>
);
}

View File

@@ -5,15 +5,19 @@ import Headline from "@/components/general/Headline";
import HtmlBody from "@/components/general/HtmlBody";
import { TResponseData } from "@formbricks/types/responses";
import type { TSurveyCTAQuestion } from "@formbricks/types/surveys";
import { useState } from "react";
import { TResponseTtc } from "@formbricks/types/responses";
import { getUpdatedTtc, useTtc } from "@/lib/ttc";
interface CTAQuestionProps {
question: TSurveyCTAQuestion;
value: string | number | string[];
onChange: (responseData: TResponseData) => void;
onSubmit: (data: TResponseData) => void;
onSubmit: (data: TResponseData, ttc: TResponseTtc) => void;
onBack: () => void;
isFirstQuestion: boolean;
isLastQuestion: boolean;
ttc: TResponseTtc;
setTtc: (ttc: TResponseTtc) => void;
}
export default function CTAQuestion({
@@ -22,7 +26,13 @@ export default function CTAQuestion({
onBack,
isFirstQuestion,
isLastQuestion,
ttc,
setTtc,
}: CTAQuestionProps) {
const [startTime, setStartTime] = useState(performance.now());
useTtc(question.id, ttc, setTtc, startTime, setStartTime);
return (
<div>
{question.imageUrl && <QuestionImage imgUrl={question.imageUrl} />}
@@ -31,7 +41,15 @@ export default function CTAQuestion({
<div className="mt-4 flex w-full justify-between">
{!isFirstQuestion && (
<BackButton backButtonLabel={question.backButtonLabel} onClick={() => onBack()} />
<BackButton
backButtonLabel={question.backButtonLabel}
onClick={() => {
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
onSubmit({ [question.id]: "" }, updatedTtcObj);
onBack();
}}
/>
)}
<div className="flex w-full justify-end">
{!question.required && (
@@ -39,7 +57,9 @@ export default function CTAQuestion({
tabIndex={0}
type="button"
onClick={() => {
onSubmit({ [question.id]: "dismissed" });
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
onSubmit({ [question.id]: "dismissed" }, updatedTtcObj);
}}
className="text-heading focus:ring-focus mr-4 flex items-center rounded-md px-3 py-3 text-base font-medium leading-4 hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-offset-2">
{question.dismissButtonLabel || "Skip"}
@@ -53,7 +73,9 @@ export default function CTAQuestion({
if (question.buttonExternal && question.buttonUrl) {
window?.open(question.buttonUrl, "_blank")?.focus();
}
onSubmit({ [question.id]: "clicked" });
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
onSubmit({ [question.id]: "clicked" }, updatedTtcObj);
}}
type="button"
/>

View File

@@ -1,19 +1,23 @@
import { BackButton } from "@/components/buttons/BackButton";
import SubmitButton from "@/components/buttons/SubmitButton";
import QuestionImage from "@/components/general/QuestionImage";
import Headline from "@/components/general/Headline";
import HtmlBody from "@/components/general/HtmlBody";
import { TResponseData } from "@formbricks/types/responses";
import QuestionImage from "@/components/general/QuestionImage";
import { TResponseData, TResponseTtc } from "@formbricks/types/responses";
import type { TSurveyConsentQuestion } from "@formbricks/types/surveys";
import { useState } from "preact/hooks";
import { getUpdatedTtc, useTtc } from "@/lib/ttc";
interface ConsentQuestionProps {
question: TSurveyConsentQuestion;
value: string | number | string[];
onChange: (responseData: TResponseData) => void;
onSubmit: (data: TResponseData) => void;
onSubmit: (data: TResponseData, ttc: TResponseTtc) => void;
onBack: () => void;
isFirstQuestion: boolean;
isLastQuestion: boolean;
ttc: TResponseTtc;
setTtc: (ttc: TResponseTtc) => void;
}
export default function ConsentQuestion({
@@ -24,7 +28,13 @@ export default function ConsentQuestion({
onBack,
isFirstQuestion,
isLastQuestion,
ttc,
setTtc,
}: ConsentQuestionProps) {
const [startTime, setStartTime] = useState(performance.now());
useTtc(question.id, ttc, setTtc, startTime, setStartTime);
return (
<div>
{question.imageUrl && <QuestionImage imgUrl={question.imageUrl} />}
@@ -34,7 +44,9 @@ export default function ConsentQuestion({
<form
onSubmit={(e) => {
e.preventDefault();
onSubmit({ [question.id]: value });
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
onSubmit({ [question.id]: value }, updatedTtcObj);
}}>
<label
tabIndex={1}
@@ -68,7 +80,16 @@ export default function ConsentQuestion({
<div className="mt-4 flex w-full justify-between">
{!isFirstQuestion && (
<BackButton tabIndex={3} backButtonLabel={question.backButtonLabel} onClick={() => onBack()} />
<BackButton
tabIndex={3}
backButtonLabel={question.backButtonLabel}
onClick={() => {
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
onSubmit({ [question.id]: value }, updatedTtcObj);
onBack();
}}
/>
)}
<div />
<SubmitButton

View File

@@ -1,4 +1,4 @@
import { TResponseData } from "@formbricks/types/responses";
import { TResponseData, TResponseTtc } from "@formbricks/types/responses";
import type { TSurveyFileUploadQuestion } from "@formbricks/types/surveys";
import { BackButton } from "../buttons/BackButton";
import SubmitButton from "../buttons/SubmitButton";
@@ -6,17 +6,21 @@ import FileInput from "../general/FileInput";
import Headline from "../general/Headline";
import Subheader from "../general/Subheader";
import { TUploadFileConfig } from "@formbricks/types/storage";
import { useState } from "preact/hooks";
import { getUpdatedTtc, useTtc } from "@/lib/ttc";
interface FileUploadQuestionProps {
question: TSurveyFileUploadQuestion;
value: string | number | string[];
onChange: (responseData: TResponseData) => void;
onSubmit: (data: TResponseData) => void;
onSubmit: (data: TResponseData, ttc: TResponseTtc) => void;
onBack: () => void;
onFileUpload: (file: File, config?: TUploadFileConfig) => Promise<string>;
isFirstQuestion: boolean;
isLastQuestion: boolean;
surveyId: string;
ttc: TResponseTtc;
setTtc: (ttc: TResponseTtc) => void;
}
export default function FileUploadQuestion({
@@ -29,22 +33,30 @@ export default function FileUploadQuestion({
isLastQuestion,
surveyId,
onFileUpload,
ttc,
setTtc,
}: FileUploadQuestionProps) {
const [startTime, setStartTime] = useState(performance.now());
useTtc(question.id, ttc, setTtc, startTime, setStartTime);
return (
<form
onSubmit={(e) => {
e.preventDefault();
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
if (question.required) {
if (value && (typeof value === "string" || Array.isArray(value)) && value.length > 0) {
onSubmit({ [question.id]: typeof value === "string" ? [value] : value });
onSubmit({ [question.id]: typeof value === "string" ? [value] : value }, updatedTtcObj);
} else {
alert("Please upload a file");
}
} else {
if (value) {
onSubmit({ [question.id]: typeof value === "string" ? [value] : value });
onSubmit({ [question.id]: typeof value === "string" ? [value] : value }, updatedTtcObj);
} else {
onSubmit({ [question.id]: "skipped" });
onSubmit({ [question.id]: "skipped" }, updatedTtcObj);
}
}
}}

View File

@@ -7,15 +7,18 @@ import { cn, shuffleQuestions } from "@/lib/utils";
import { TResponseData } from "@formbricks/types/responses";
import type { TSurveyMultipleChoiceMultiQuestion } from "@formbricks/types/surveys";
import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks";
import { TResponseTtc } from "@formbricks/types/responses";
import { getUpdatedTtc, useTtc } from "@/lib/ttc";
interface MultipleChoiceMultiProps {
question: TSurveyMultipleChoiceMultiQuestion;
value: string | number | string[];
onChange: (responseData: TResponseData) => void;
onSubmit: (data: TResponseData) => void;
onSubmit: (data: TResponseData, ttc: TResponseTtc) => void;
onBack: () => void;
isFirstQuestion: boolean;
isLastQuestion: boolean;
ttc: TResponseTtc;
setTtc: (ttc: TResponseTtc) => void;
}
export default function MultipleChoiceMultiQuestion({
@@ -26,7 +29,13 @@ export default function MultipleChoiceMultiQuestion({
onBack,
isFirstQuestion,
isLastQuestion,
ttc,
setTtc,
}: MultipleChoiceMultiProps) {
const [startTime, setStartTime] = useState(performance.now());
useTtc(question.id, ttc, setTtc, startTime, setStartTime);
const getChoicesWithoutOtherLabels = useCallback(
() => question.choices.filter((choice) => choice.id !== "other").map((item) => item.label),
[question]
@@ -89,7 +98,9 @@ export default function MultipleChoiceMultiQuestion({
return getChoicesWithoutOtherLabels().includes(item) || item === otherValue;
}); // filter out all those values which are either in getChoicesWithoutOtherLabels() (i.e. selected by checkbox) or the latest entered otherValue
onChange({ [question.id]: newValue });
onSubmit({ [question.id]: newValue });
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
onSubmit({ [question.id]: value }, updatedTtcObj);
}}
className="w-full">
{question.imageUrl && <QuestionImage imgUrl={question.imageUrl} />}
@@ -196,8 +207,10 @@ export default function MultipleChoiceMultiQuestion({
}}
onKeyDown={(e) => {
if (e.key == "Enter") {
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
setTimeout(() => {
onSubmit({ [question.id]: value });
onSubmit({ [question.id]: value }, updatedTtcObj);
}, 100);
}
}}
@@ -217,7 +230,11 @@ export default function MultipleChoiceMultiQuestion({
<BackButton
tabIndex={questionChoices.length + 3}
backButtonLabel={question.backButtonLabel}
onClick={onBack}
onClick={() => {
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
onBack();
}}
/>
)}
<div></div>

View File

@@ -7,15 +7,18 @@ import { cn, shuffleQuestions } from "@/lib/utils";
import { TResponseData } from "@formbricks/types/responses";
import type { TSurveyMultipleChoiceSingleQuestion } from "@formbricks/types/surveys";
import { useEffect, useMemo, useRef, useState } from "preact/hooks";
import { TResponseTtc } from "@formbricks/types/responses";
import { getUpdatedTtc, useTtc } from "@/lib/ttc";
interface MultipleChoiceSingleProps {
question: TSurveyMultipleChoiceSingleQuestion;
value: string | number | string[];
onChange: (responseData: TResponseData) => void;
onSubmit: (data: TResponseData) => void;
onSubmit: (data: TResponseData, ttc: TResponseTtc) => void;
onBack: () => void;
isFirstQuestion: boolean;
isLastQuestion: boolean;
ttc: TResponseTtc;
setTtc: (ttc: TResponseTtc) => void;
}
export default function MultipleChoiceSingleQuestion({
@@ -26,7 +29,13 @@ export default function MultipleChoiceSingleQuestion({
onBack,
isFirstQuestion,
isLastQuestion,
ttc,
setTtc,
}: MultipleChoiceSingleProps) {
const [startTime, setStartTime] = useState(performance.now());
useTtc(question.id, ttc, setTtc, startTime, setStartTime);
const [otherSelected, setOtherSelected] = useState(
!!value && !question.choices.find((c) => c.label === value)
); // initially set to true if value is not in choices
@@ -58,7 +67,9 @@ export default function MultipleChoiceSingleQuestion({
<form
onSubmit={(e) => {
e.preventDefault();
onSubmit({ [question.id]: value });
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
onSubmit({ [question.id]: value }, updatedTtcObj);
}}
className="w-full">
{question.imageUrl && <QuestionImage imgUrl={question.imageUrl} />}
@@ -78,8 +89,10 @@ export default function MultipleChoiceSingleQuestion({
onKeyDown={(e) => {
if (e.key == "Enter") {
onChange({ [question.id]: choice.label });
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
setTimeout(() => {
onSubmit({ [question.id]: choice.label });
onSubmit({ [question.id]: choice.label }, updatedTtcObj);
}, 350);
}
}}
@@ -157,8 +170,10 @@ export default function MultipleChoiceSingleQuestion({
}}
onKeyDown={(e) => {
if (e.key == "Enter") {
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
setTimeout(() => {
onSubmit({ [question.id]: value });
onSubmit({ [question.id]: value }, updatedTtcObj);
}, 100);
}
}}
@@ -178,7 +193,11 @@ export default function MultipleChoiceSingleQuestion({
<BackButton
backButtonLabel={question.backButtonLabel}
tabIndex={questionChoices.length + 3}
onClick={onBack}
onClick={() => {
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
onBack();
}}
/>
)}
<div></div>

View File

@@ -6,15 +6,19 @@ import Subheader from "@/components/general/Subheader";
import { cn } from "@/lib/utils";
import { TResponseData } from "@formbricks/types/responses";
import type { TSurveyNPSQuestion } from "@formbricks/types/surveys";
import { useState } from "preact/hooks";
import { TResponseTtc } from "@formbricks/types/responses";
import { getUpdatedTtc, useTtc } from "@/lib/ttc";
interface NPSQuestionProps {
question: TSurveyNPSQuestion;
value: string | number | string[];
onChange: (responseData: TResponseData) => void;
onSubmit: (data: TResponseData) => void;
onSubmit: (data: TResponseData, ttc: TResponseTtc) => void;
onBack: () => void;
isFirstQuestion: boolean;
isLastQuestion: boolean;
ttc: TResponseTtc;
setTtc: (ttc: TResponseTtc) => void;
}
export default function NPSQuestion({
@@ -25,12 +29,20 @@ export default function NPSQuestion({
onBack,
isFirstQuestion,
isLastQuestion,
ttc,
setTtc,
}: NPSQuestionProps) {
const [startTime, setStartTime] = useState(performance.now());
useTtc(question.id, ttc, setTtc, startTime, setStartTime);
return (
<form
onSubmit={(e) => {
e.preventDefault();
onSubmit({ [question.id]: value });
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
onSubmit({ [question.id]: value }, updatedTtcObj);
}}>
{question.imageUrl && <QuestionImage imgUrl={question.imageUrl} />}
<Headline headline={question.headline} questionId={question.id} required={question.required} />
@@ -45,7 +57,9 @@ export default function NPSQuestion({
tabIndex={idx + 1}
onKeyDown={(e) => {
if (e.key == "Enter") {
onSubmit({ [question.id]: number });
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
onSubmit({ [question.id]: number }, updatedTtcObj);
}
}}
className={cn(
@@ -60,9 +74,14 @@ export default function NPSQuestion({
className="absolute h-full w-full cursor-pointer opacity-0"
onClick={() => {
if (question.required) {
onSubmit({
[question.id]: number,
});
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
onSubmit(
{
[question.id]: number,
},
updatedTtcObj
);
}
onChange({ [question.id]: number });
}}
@@ -85,6 +104,8 @@ export default function NPSQuestion({
tabIndex={isLastQuestion ? 12 : 13}
backButtonLabel={question.backButtonLabel}
onClick={() => {
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
onBack();
}}
/>

View File

@@ -6,16 +6,21 @@ import Subheader from "@/components/general/Subheader";
import { TResponseData } from "@formbricks/types/responses";
import type { TSurveyOpenTextQuestion } from "@formbricks/types/surveys";
import { useCallback } from "react";
import { useState } from "preact/hooks";
import { TResponseTtc } from "@formbricks/types/responses";
import { getUpdatedTtc, useTtc } from "@/lib/ttc";
interface OpenTextQuestionProps {
question: TSurveyOpenTextQuestion;
value: string | number | string[];
onChange: (responseData: TResponseData) => void;
onSubmit: (data: TResponseData) => void;
onSubmit: (data: TResponseData, ttc: TResponseTtc) => void;
onBack: () => void;
isFirstQuestion: boolean;
isLastQuestion: boolean;
autoFocus?: boolean;
ttc: TResponseTtc;
setTtc: (ttc: TResponseTtc) => void;
}
export default function OpenTextQuestion({
@@ -27,7 +32,13 @@ export default function OpenTextQuestion({
isFirstQuestion,
isLastQuestion,
autoFocus = true,
ttc,
setTtc,
}: OpenTextQuestionProps) {
const [startTime, setStartTime] = useState(performance.now());
useTtc(question.id, ttc, setTtc, startTime, setStartTime);
const handleInputChange = (inputValue: string) => {
// const isValidInput = validateInput(inputValue, question.inputType, question.required);
// setIsValid(isValidInput);
@@ -50,7 +61,9 @@ export default function OpenTextQuestion({
onSubmit={(e) => {
e.preventDefault();
// if ( validateInput(value as string, question.inputType, question.required)) {
onSubmit({ [question.id]: value, inputType: question.inputType });
const updatedttc = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedttc);
onSubmit({ [question.id]: value, inputType: question.inputType }, updatedttc);
// }
}}
className="w-full">
@@ -75,7 +88,9 @@ export default function OpenTextQuestion({
if (e.key === "Enter" && isInputEmpty(value as string)) {
e.preventDefault(); // Prevent form submission
} else if (e.key === "Enter") {
onSubmit({ [question.id]: value });
const updatedttc = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedttc);
onSubmit({ [question.id]: value, inputType: question.inputType }, updatedttc);
}
}}
pattern={question.inputType === "phone" ? "[+][0-9 ]+" : ".*"}
@@ -106,6 +121,8 @@ export default function OpenTextQuestion({
<BackButton
backButtonLabel={question.backButtonLabel}
onClick={() => {
const updatedttc = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedttc);
onBack();
}}
/>

View File

@@ -1,21 +1,23 @@
import { BackButton } from "@/components/buttons/BackButton";
import SubmitButton from "@/components/buttons/SubmitButton";
import QuestionImage from "@/components/general/QuestionImage";
import Headline from "@/components/general/Headline";
import QuestionImage from "@/components/general/QuestionImage";
import Subheader from "@/components/general/Subheader";
import { cn } from "@/lib/utils";
import { TResponseData } from "@formbricks/types/responses";
import { TResponseData, TResponseTtc } from "@formbricks/types/responses";
import type { TSurveyPictureSelectionQuestion } from "@formbricks/types/surveys";
import { useEffect } from "preact/hooks";
import { useEffect, useState } from "preact/hooks";
import { getUpdatedTtc, useTtc } from "@/lib/ttc";
interface PictureSelectionProps {
question: TSurveyPictureSelectionQuestion;
value: string | number | string[];
onChange: (responseData: TResponseData) => void;
onSubmit: (data: TResponseData) => void;
onSubmit: (data: TResponseData, ttc: TResponseTtc) => void;
onBack: () => void;
isFirstQuestion: boolean;
isLastQuestion: boolean;
ttc: TResponseTtc;
setTtc: (ttc: TResponseTtc) => void;
}
export default function PictureSelectionQuestion({
@@ -26,7 +28,13 @@ export default function PictureSelectionQuestion({
onBack,
isFirstQuestion,
isLastQuestion,
ttc,
setTtc,
}: PictureSelectionProps) {
const [startTime, setStartTime] = useState(performance.now());
useTtc(question.id, ttc, setTtc, startTime, setStartTime);
const addItem = (item: string) => {
let values: string[] = [];
@@ -80,7 +88,9 @@ export default function PictureSelectionQuestion({
<form
onSubmit={(e) => {
e.preventDefault();
onSubmit({ [question.id]: value });
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
onSubmit({ [question.id]: value }, updatedTtcObj);
}}
className="w-full">
{question.imageUrl && <QuestionImage imgUrl={question.imageUrl} />}
@@ -155,7 +165,11 @@ export default function PictureSelectionQuestion({
<BackButton
tabIndex={questionChoices.length + 3}
backButtonLabel={question.backButtonLabel}
onClick={onBack}
onClick={() => {
const updatedTtcObj = getUpdatedTtc(ttc, question.id, performance.now() - startTime);
setTtc(updatedTtcObj);
onBack();
}}
/>
)}
<div></div>

Some files were not shown because too many files have changed in this diff Show More