Skip to content

Commit

Permalink
Fetch the matomo properties from the config, not from the environment (
Browse files Browse the repository at this point in the history
  • Loading branch information
milanmajchrak authored Dec 3, 2024
1 parent 4c2e997 commit e4dcb89
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
1 change: 0 additions & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ services:
- ./config.prod.yml:/app/config/config.prod.yml
# - ./aai.js:/app/dist/browser/aai.js
# - ./dspace-ui.json:/app/docker/dspace-ui.json:rw
- ./matomo-settings.ts:/src/matomo/matomo-settings.ts
build:
context: ..
dockerfile: Dockerfile
Expand Down
5 changes: 0 additions & 5 deletions src/environments/environment.production.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,4 @@ export const environment: Partial<BuildConfig> = {
time: false,
inlineCriticalCss: false,
},

matomo: {
hostUrl: 'http://localhost:8135/',
siteId: '1',
}
};
5 changes: 0 additions & 5 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export const environment: Partial<BuildConfig> = {
},

signpostingEnabled: false,

matomo: {
hostUrl: 'http://localhost:8135/',
siteId: '1',
}
};

/*
Expand Down
26 changes: 16 additions & 10 deletions src/main.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,23 @@ const main = () => {
function addMatomoStatistics() {
(window as any)._paq = (window as any)._paq || [];

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

const g = document.createElement('script');
g.type = 'text/javascript';
g.async = true;
g.defer = true;
g.src = environment.matomo.hostUrl + 'matomo.js';
document.getElementsByTagName('head')[0].appendChild(g);
// Push all configuration commands first
(window as any)._paq.push(['setTrackerUrl', matomoConfig.hostUrl + 'matomo.php']);
(window as any)._paq.push(['setSiteId', matomoConfig.siteId]);
(window as any)._paq.push(['enableLinkTracking']);

const g = document.createElement('script');
g.type = 'text/javascript';
g.async = true;
g.defer = true;
g.src = matomoConfig.hostUrl + 'matomo.js';
document.getElementsByTagName('head')[0].appendChild(g);
});
}

// support async tag or hmr
Expand Down

0 comments on commit e4dcb89

Please sign in to comment.