Skip to content

Commit 69c0359

Browse files
authored
remove cookie consent (#51)
1 parent 7028a60 commit 69c0359

File tree

4 files changed

+21
-135
lines changed

4 files changed

+21
-135
lines changed

.github/workflows/run-checks.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ name: Lint, Format, Test, Build
33
on:
44
push:
55
branches:
6-
- "*"
7-
- "!main"
8-
- "!develop"
6+
- '*'
7+
- '!main'
8+
- '!develop'
99
workflow_dispatch:
1010

1111
jobs:
@@ -19,7 +19,7 @@ jobs:
1919
uses: actions/setup-node@v4
2020
with:
2121
node-version: 23
22-
cache: "npm"
22+
cache: 'npm'
2323

2424
- name: Install Node.js packages
2525
run: npm ci
@@ -34,7 +34,7 @@ jobs:
3434
uses: actions/setup-node@v4
3535
with:
3636
node-version: 23
37-
cache: "npm"
37+
cache: 'npm'
3838

3939
- name: Install Node.js packages
4040
run: npm ci
@@ -52,7 +52,7 @@ jobs:
5252
uses: actions/setup-node@v4
5353
with:
5454
node-version: 23
55-
cache: "npm"
55+
cache: 'npm'
5656

5757
- name: Install Node.js packages
5858
run: npm ci
@@ -70,7 +70,7 @@ jobs:
7070
uses: actions/setup-node@v4
7171
with:
7272
node-version: 23
73-
cache: "npm"
73+
cache: 'npm'
7474

7575
- name: Install Node.js packages
7676
run: npm ci
@@ -90,7 +90,7 @@ jobs:
9090
uses: actions/setup-node@v4
9191
with:
9292
node-version: 23
93-
cache: "npm"
93+
cache: 'npm'
9494

9595
- name: Install Node.js packages
9696
run: npm ci

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)