Skip to content

Commit

Permalink
Merge pull request #1 from private-attribution/limit-api-calls
Browse files Browse the repository at this point in the history
limit the number of times the api is called per session to 16
  • Loading branch information
eriktaubeneck authored Sep 18, 2024
2 parents f37f914 + 41187a1 commit af9352d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default function Home() {
upsideDownSmily,
];
const [text, setText] = useState<string>(texts[0]);

useEffect(() => {
if (
typeof IPAExperiment !== "undefined" &&
Expand All @@ -41,9 +42,19 @@ export default function Home() {
}
}, []);

const [apiCalls, setApiCalls] = useState<number>(0);
useEffect(() => {
setApiCalls(Number(sessionStorage.getItem("apiCalls")));
}, []);

const handleClick = () => {
const conversionValue = 1;
if (
setApiCalls(apiCalls + 1);
sessionStorage.setItem("apiCalls", apiCalls.toString());
if (apiCalls > 16) {
console.warn("too many api calls");
cycleText(upsideDownSmily);
} else if (
typeof IPAExperiment !== "undefined" &&
typeof IPAExperiment.createAndSubmitConversionReport === "function"
) {
Expand Down

0 comments on commit af9352d

Please sign in to comment.