remove session from formbricks-app feedback button

This commit is contained in:
Matthias Nannt
2023-02-09 12:08:43 +01:00
parent a94a35c89d
commit 187bf3ca49
2 changed files with 14 additions and 22 deletions

View File

@@ -1,6 +1,5 @@
import clsx from "clsx";
import { usePlausible } from "next-plausible";
import Script from "next/script";
import { useEffect, useRef, useState } from "react";
declare global {

View File

@@ -1,5 +1,4 @@
import clsx from "clsx";
import { useSession } from "next-auth/react";
import { useEffect, useRef, useState } from "react";
declare global {
@@ -15,7 +14,6 @@ const feedbackEnabled = !!(
export function FeedbackButton() {
const [isOpen, setIsOpen] = useState(false);
const feedbackRef = useRef<HTMLInputElement>(null);
const { data: session, status } = useSession();
useEffect(() => {
if (feedbackEnabled) {
@@ -36,28 +34,23 @@ export function FeedbackButton() {
}, [feedbackRef, isOpen]);
useEffect(() => {
window.formbricks = {
...window.formbricks,
config: {
hqUrl: process.env.NEXT_PUBLIC_FORMBRICKS_URL,
formId: process.env.NEXT_PUBLIC_FORMBRICKS_FORM_ID,
divId: "formbricks-feedback-wrapper",
contact: {
name: "Matti",
position: "Co-Founder",
imgUrl: "https://avatars.githubusercontent.com/u/675065?s=128&v=4",
},
},
};
// @ts-ignore
import("@formbricks/feedback");
}, []);
useEffect(() => {
if (status !== "loading" && feedbackEnabled) {
window.formbricks = {
...window.formbricks,
config: {
hqUrl: process.env.NEXT_PUBLIC_FORMBRICKS_URL,
formId: process.env.NEXT_PUBLIC_FORMBRICKS_FORM_ID,
divId: "formbricks-feedback-wrapper",
contact: {
name: "Matti",
position: "Co-Founder",
imgUrl: "https://avatars.githubusercontent.com/u/675065?s=128&v=4",
},
customer: session?.user,
},
};
}
}, [status, session]);
if (!feedbackEnabled) return null;
return (