Skip to content

Commit

Permalink
cookie削除
Browse files Browse the repository at this point in the history
  • Loading branch information
eatski committed Apr 10, 2024
1 parent 17c70a4 commit 95d2068
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ export default function App({ Component, pageProps }: AppProps) {
}, [router]);

useEffect(() => {
if (!process.env.NEXT_PUBLIC_AB_TEST_RATE) {
return;
}
const rate = Number(process.env.NEXT_PUBLIC_AB_TEST_RATE);
if (rate < 0 || rate > 1 || isNaN(rate)) {
console.error("NEXT_PUBLIC_AB_TEST_RATE must be between 0 and 1.");
return;
}
//ABテストのためのクッキーを付与
import("js-cookie").then((jsCookie) => {
if (!process.env.NEXT_PUBLIC_AB_TEST_RATE) {
jsCookie.default.remove(AB_TESTING_COOKIE_NAME);
}
const rate = Number(process.env.NEXT_PUBLIC_AB_TEST_RATE);
if (rate < 0 || rate > 1 || isNaN(rate)) {
console.error("NEXT_PUBLIC_AB_TEST_RATE must be between 0 and 1.");
return;
}
const cookieValue = jsCookie.default.get(AB_TESTING_COOKIE_NAME);
if (!cookieValue || !validateABTestingVariant(cookieValue)) {
jsCookie.default.set(AB_TESTING_COOKIE_NAME, getAorBRandom(rate));
Expand Down

0 comments on commit 95d2068

Please sign in to comment.