Skip to content

Commit 4c2e997

Browse files
UFAL/Load the matomo configuration from the environment (DSpace#755)
* Added volume into docker-compose * Take a matomo configuration from the environment
1 parent fc70fcb commit 4c2e997

9 files changed

+45
-14
lines changed

config/config.example.yml

+4
Original file line numberDiff line numberDiff line change
@@ -393,3 +393,7 @@ vocabularies:
393393
comcolSelectionSort:
394394
sortField: 'dc.title'
395395
sortDirection: 'ASC'
396+
397+
matomo:
398+
hostUrl: http://localhost:8135/
399+
siteId: 1

src/config/app-config.interface.ts

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { HomeConfig } from './homepage-config.interface';
2222
import { MarkdownConfig } from './markdown-config.interface';
2323
import { FilterVocabularyConfig } from './filter-vocabulary-config';
2424
import { DiscoverySortConfig } from './discovery-sort.config';
25+
import { MatomoConfig } from './matomo-config';
2526

2627
interface AppConfig extends Config {
2728
ui: UIServerConfig;
@@ -49,6 +50,7 @@ interface AppConfig extends Config {
4950
vocabularies: FilterVocabularyConfig[];
5051
comcolSelectionSort: DiscoverySortConfig;
5152
signpostingEnabled: boolean;
53+
matomo: MatomoConfig;
5254
}
5355

5456
/**

src/config/default-app-config.ts

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { HomeConfig } from './homepage-config.interface';
2222
import { MarkdownConfig } from './markdown-config.interface';
2323
import { FilterVocabularyConfig } from './filter-vocabulary-config';
2424
import { DiscoverySortConfig } from './discovery-sort.config';
25+
import { MatomoConfig } from './matomo-config';
2526

2627
export class DefaultAppConfig implements AppConfig {
2728
production = false;
@@ -428,4 +429,10 @@ export class DefaultAppConfig implements AppConfig {
428429

429430
// NOTE: you must disable/enable in the backend the signposting feature to make it work `signposting.enabled`
430431
signpostingEnabled = false;
432+
433+
// Matomo configuration
434+
matomo: MatomoConfig = {
435+
hostUrl: 'http://localhost:8135/',
436+
siteId: '1'
437+
};
431438
}

src/config/matomo-config.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Config } from './config.interface';
2+
3+
/**
4+
* Configuration for Matomo statistics.
5+
*/
6+
export class MatomoConfig implements Config {
7+
8+
public hostUrl: string;
9+
10+
public siteId: string;
11+
}

src/environments/environment.production.ts

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

src/environments/environment.test.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -315,5 +315,10 @@ export const environment: BuildConfig = {
315315
}
316316
],
317317

318-
signpostingEnabled: true
318+
signpostingEnabled: true,
319+
320+
matomo: {
321+
hostUrl: 'http://localhost:8135/',
322+
siteId: '1',
323+
}
319324
};

src/environments/environment.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ export const environment: Partial<BuildConfig> = {
2525
nameSpace: '/server',
2626
},
2727

28-
signpostingEnabled: false
28+
signpostingEnabled: false,
29+
30+
matomo: {
31+
hostUrl: 'http://localhost:8135/',
32+
siteId: '1',
33+
}
2934
};
3035

3136
/*

src/main.browser.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { environment } from './environments/environment';
1010
import { AppConfig } from './config/app-config.interface';
1111
import { extendEnvironmentWithAppConfig } from './config/config.util';
1212
import { enableProdMode } from '@angular/core';
13-
import { matomoSettings } from './matomo/matomo-settings';
1413

1514
const bootstrap = () => platformBrowserDynamic()
1615
.bootstrapModule(BrowserAppModule, {});
@@ -27,8 +26,8 @@ const main = () => {
2726
if (environment.production) {
2827
enableProdMode();
2928
}
30-
addMatomoStatistics();
3129

30+
addMatomoStatistics();
3231
if (hasTransferState) {
3332
// Configuration will be taken from transfer state during initialization
3433
return bootstrap();
@@ -48,15 +47,15 @@ function addMatomoStatistics() {
4847
(window as any)._paq = (window as any)._paq || [];
4948

5049
// Push all configuration commands first
51-
(window as any)._paq.push(['setTrackerUrl', matomoSettings.hostUrl + 'matomo.php']);
52-
(window as any)._paq.push(['setSiteId', matomoSettings.siteId]);
50+
(window as any)._paq.push(['setTrackerUrl', environment.matomo.hostUrl + 'matomo.php']);
51+
(window as any)._paq.push(['setSiteId', environment.matomo.siteId]);
5352
(window as any)._paq.push(['enableLinkTracking']);
5453

5554
const g = document.createElement('script');
5655
g.type = 'text/javascript';
5756
g.async = true;
5857
g.defer = true;
59-
g.src = matomoSettings.hostUrl + 'matomo.js';
58+
g.src = environment.matomo.hostUrl + 'matomo.js';
6059
document.getElementsByTagName('head')[0].appendChild(g);
6160
}
6261

src/matomo/matomo-settings.ts

-7
This file was deleted.

0 commit comments

Comments
 (0)