mirror of
https://github.com/baptisteArno/typebot.io.git
synced 2026-06-22 21:06:40 +08:00
🐛 (landing-page) Fix first-time cookie setter for non EU users
This commit is contained in:
parent
9a9a7e684c
commit
8548d36cda
7
apps/landing-page/src/helpers/setCookie.ts
Normal file
7
apps/landing-page/src/helpers/setCookie.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { serializeTypebotCookie } from "@typebot.io/telemetry/cookies/helpers";
|
||||
|
||||
export const setCookie = (consent: "declined" | "accepted") => {
|
||||
document.cookie = serializeTypebotCookie({
|
||||
consent,
|
||||
});
|
||||
};
|
||||
@ -1,4 +1,5 @@
|
||||
import { isEU } from "@/features/telemetry/server/isEU";
|
||||
import { setCookie } from "@/helpers/setCookie";
|
||||
import { getTypebotCookie } from "@typebot.io/telemetry/cookies/helpers";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
@ -17,7 +18,12 @@ export const useCookieConsentStatus = () => {
|
||||
}
|
||||
|
||||
isEU().then((response) => {
|
||||
setCookieConsentStatus(response.isEU ? "need-consent" : "not-needed");
|
||||
if (response.isEU) {
|
||||
setCookieConsentStatus("need-consent");
|
||||
} else {
|
||||
setCookie("accepted");
|
||||
setCookieConsentStatus("not-needed");
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ import { CookieConsentBot } from "@/components/CookieConsentBot";
|
||||
import { Header } from "@/components/Header";
|
||||
import { NotFound } from "@/components/NotFound";
|
||||
import { Footer } from "@/components/footer/Footer";
|
||||
import { setCookie } from "@/helpers/setCookie";
|
||||
import { useCookieConsentStatus } from "@/hooks/useIsCookieConsentNeeded";
|
||||
import { useTrackPageViewQuery } from "@/hooks/useTrackPageViewQuery";
|
||||
import {
|
||||
@ -12,7 +13,6 @@ import {
|
||||
createRootRoute,
|
||||
useNavigate,
|
||||
} from "@tanstack/react-router";
|
||||
import { serializeTypebotCookie } from "@typebot.io/telemetry/cookies/helpers";
|
||||
import { z } from "@typebot.io/zod";
|
||||
|
||||
const HERO_ANIMATION_DELAY = 1800;
|
||||
@ -102,9 +102,3 @@ function RootComponent() {
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
||||
const setCookie = (consent: "declined" | "accepted") => {
|
||||
document.cookie = serializeTypebotCookie({
|
||||
consent,
|
||||
});
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user