Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #149 from poap-xyz/fix/matomo-event-title-store-tr…
Browse files Browse the repository at this point in the history
…ack-state

Fix Matomo track event: Store tracked event to not many times the same
  • Loading branch information
jm42 authored May 1, 2023
2 parents 8103210 + 353bcfe commit 5b76115
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/pages/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export function Event() {
const [ensNames, setEnsNames] = useState([]);
const [canDownloadCsv, setCanDownloadCsv] = useState(CSV_STATUS.NoTokens);
const [tableIsLoading, setTableIsLoading] = useState(true);
const [trackedEvent, setTrackedEvent] = useState(null);
const pageCount = useMemo(
() =>
event.tokenCount % 50 !== 0
Expand Down Expand Up @@ -120,13 +121,20 @@ export function Event() {
}, []);

useEffect(() => {
if (succeededLoadingEvent() && !tableIsLoading && event && event?.name) {
if (
succeededLoadingEvent() &&
event &&
event?.name &&
event?.id &&
(!trackedEvent || trackedEvent !== event.id)
) {
trackPageView({
href: window.location.href,
documentTitle: `POAP Gallery - Event - ${event.name}`,
});
setTrackedEvent(event.id);
}
}, [event, succeededLoadingEvent, tableIsLoading]);
}, [event, succeededLoadingEvent, trackedEvent, setTrackedEvent]);

useEffect(() => {
// Get new batch of tokens
Expand Down

0 comments on commit 5b76115

Please sign in to comment.