Skip to content

Commit dbfbf59

Browse files
committed
Merge branch 'develop' into notebook-error-handling
2 parents 44cb309 + 69c0359 commit dbfbf59

File tree

3 files changed

+13
-127
lines changed

3 files changed

+13
-127
lines changed

src/app/_coming-soon/page.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ export default function Page() {
3131
</div>
3232
</main>
3333
</div>
34+
<div className="absolute bottom-3 left-3 z-50 px-2 py-2 text-base text-white shadow-md md:px-[19px]">
35+
Copyright &copy; {new Date().getFullYear()} – Open Brain Institute
36+
</div>
3437
</div>
3538
);
3639
}

src/components/Matomo/consent.tsx

-70
This file was deleted.

src/components/Matomo/index.tsx

+10-57
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,36 @@
11
'use client';
22

3-
import { Suspense, useCallback, useEffect, useState } from 'react';
3+
import { Suspense, useEffect, useState } from 'react';
44
import { usePathname, useSearchParams } from 'next/navigation';
55

6-
import { CookieNotice } from '@/components/Matomo/consent';
76
import { init, push } from '@/util/matomo';
87
import { env } from '@/env.mjs';
98

109
const MATOMO_URL = env.NEXT_PUBLIC_MATOMO_URL;
1110
const MATOMO_CDN_URL = env.NEXT_PUBLIC_MATOMO_CDN_URL;
1211
const MATOMO_SITE_ID = env.NEXT_PUBLIC_MATOMO_SITE_ID;
13-
const CONSENT_SID = 'c_sid';
1412

1513
function Matomo() {
1614
const searchParams = useSearchParams();
1715
const pathname = usePathname();
18-
const [isOpen, setIsOpen] = useState(false);
16+
const [initialized, setInitialized] = useState(false);
1917

2018
const searchParamsString = searchParams.toString();
21-
const openConsent = useCallback(() => setIsOpen(true), []);
2219

23-
const onAccept = () => {
24-
if (MATOMO_URL && MATOMO_SITE_ID && MATOMO_CDN_URL) {
20+
useEffect(() => {
21+
if (MATOMO_URL && MATOMO_SITE_ID && MATOMO_CDN_URL && !initialized) {
2522
init({
2623
url: MATOMO_URL,
2724
cdnUrl: MATOMO_CDN_URL,
2825
siteId: MATOMO_SITE_ID,
29-
disableCookies: false,
26+
disableCookies: true,
3027
});
31-
localStorage.setItem(
32-
CONSENT_SID,
33-
JSON.stringify({
34-
id: crypto.randomUUID(),
35-
lastUpdated: Math.floor(Date.now() / 1000),
36-
r: true,
37-
})
38-
);
39-
setIsOpen(false);
4028
}
41-
};
42-
43-
const onDecline = () => {
44-
localStorage.setItem(
45-
CONSENT_SID,
46-
JSON.stringify({
47-
id: crypto.randomUUID(),
48-
lastUpdated: Math.floor(Date.now() / 1000),
49-
r: false,
50-
})
51-
);
52-
setIsOpen(false);
53-
};
5429

55-
useEffect(() => {
56-
const savedConsent = localStorage.getItem(CONSENT_SID);
57-
if (!savedConsent) openConsent();
58-
}, [openConsent]);
30+
return () => {
31+
setInitialized(true);
32+
};
33+
}, [initialized, setInitialized]);
5934

6035
useEffect(() => {
6136
if (!pathname) return;
@@ -64,29 +39,7 @@ function Matomo() {
6439
push(['trackPageView']);
6540
}, [pathname, searchParamsString]);
6641

67-
useEffect(() => {
68-
try {
69-
const savedConsent = localStorage.getItem(CONSENT_SID);
70-
if (savedConsent) {
71-
const consentParsed = JSON.parse(savedConsent);
72-
if (consentParsed.r) {
73-
if (MATOMO_URL && MATOMO_SITE_ID && MATOMO_CDN_URL) {
74-
init({
75-
url: MATOMO_URL,
76-
cdnUrl: MATOMO_CDN_URL,
77-
siteId: MATOMO_SITE_ID,
78-
disableCookies: false,
79-
});
80-
}
81-
}
82-
}
83-
} catch (error) {
84-
// eslint-disable-next-line no-console
85-
console.error('failed to parse the consent');
86-
}
87-
}, []);
88-
89-
return <CookieNotice isOpen={isOpen} onAccept={onAccept} onDecline={onDecline} />;
42+
return null;
9043
}
9144

9245
export default function MatomoAnalyticsConsent() {

0 commit comments

Comments
 (0)