Skip to content

Commit e4dcb89

Browse files
Fetch the matomo properties from the config, not from the environment (#756)
1 parent 4c2e997 commit e4dcb89

File tree

4 files changed

+16
-21
lines changed

4 files changed

+16
-21
lines changed

docker/docker-compose.yml

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ services:
2929
- ./config.prod.yml:/app/config/config.prod.yml
3030
# - ./aai.js:/app/dist/browser/aai.js
3131
# - ./dspace-ui.json:/app/docker/dspace-ui.json:rw
32-
- ./matomo-settings.ts:/src/matomo/matomo-settings.ts
3332
build:
3433
context: ..
3534
dockerfile: Dockerfile

src/environments/environment.production.ts

-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,4 @@ export const environment: Partial<BuildConfig> = {
1010
time: false,
1111
inlineCriticalCss: false,
1212
},
13-
14-
matomo: {
15-
hostUrl: 'http://localhost:8135/',
16-
siteId: '1',
17-
}
1813
};

src/environments/environment.ts

-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ export const environment: Partial<BuildConfig> = {
2626
},
2727

2828
signpostingEnabled: false,
29-
30-
matomo: {
31-
hostUrl: 'http://localhost:8135/',
32-
siteId: '1',
33-
}
3429
};
3530

3631
/*

src/main.browser.ts

+16-10
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,23 @@ const main = () => {
4646
function addMatomoStatistics() {
4747
(window as any)._paq = (window as any)._paq || [];
4848

49-
// Push all configuration commands first
50-
(window as any)._paq.push(['setTrackerUrl', environment.matomo.hostUrl + 'matomo.php']);
51-
(window as any)._paq.push(['setSiteId', environment.matomo.siteId]);
52-
(window as any)._paq.push(['enableLinkTracking']);
49+
void fetch('assets/config.json')
50+
.then((response) => response.json())
51+
.then((config) => {
52+
const matomoConfig = config.matomo;
5353

54-
const g = document.createElement('script');
55-
g.type = 'text/javascript';
56-
g.async = true;
57-
g.defer = true;
58-
g.src = environment.matomo.hostUrl + 'matomo.js';
59-
document.getElementsByTagName('head')[0].appendChild(g);
54+
// Push all configuration commands first
55+
(window as any)._paq.push(['setTrackerUrl', matomoConfig.hostUrl + 'matomo.php']);
56+
(window as any)._paq.push(['setSiteId', matomoConfig.siteId]);
57+
(window as any)._paq.push(['enableLinkTracking']);
58+
59+
const g = document.createElement('script');
60+
g.type = 'text/javascript';
61+
g.async = true;
62+
g.defer = true;
63+
g.src = matomoConfig.hostUrl + 'matomo.js';
64+
document.getElementsByTagName('head')[0].appendChild(g);
65+
});
6066
}
6167

6268
// support async tag or hmr

0 commit comments

Comments
 (0)