Skip to content

Commit d451dce

Browse files
committed
changes based on milan review
1 parent cc8b0c9 commit d451dce

6 files changed

Lines changed: 46 additions & 0 deletions

File tree

MATOMO_CONFIGURATION.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Matomo Statistics Configuration
2+
3+
## Enable/Disable Matomo
4+
5+
### To Disable Matomo (Default)
6+
```typescript
7+
matomo: {
8+
enabled: false,
9+
hostUrl: 'https://your-matomo-server.com/',
10+
siteId: '1',
11+
dimensionId: 1
12+
}
13+
```
14+
15+
### To Enable Matomo
16+
```typescript
17+
matomo: {
18+
enabled: true,
19+
hostUrl: 'https://your-matomo-server.com/',
20+
siteId: '1',
21+
dimensionId: 1
22+
}
23+
```
24+
25+
## Files to Modify
26+
27+
- environment.test.ts
28+
- default-app-config.ts
29+
- config.example.ts
30+
31+
## After Changes
32+
33+
1. Restart the application
34+
2. Clear browser cache
35+
36+
When disabled: No Matomo scripts load, statistics page shows "disabled" message.
37+
When enabled: Matomo tracking works normally.

config/config.example.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,5 +465,6 @@ accessibility:
465465
cookieExpirationDuration: 7
466466

467467
matomo:
468+
enabled: false
468469
hostUrl: http://localhost:8135/
469470
siteId: 1

src/config/default-app-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ export class DefaultAppConfig implements AppConfig {
452452

453453
// Matomo configuration
454454
matomo: MatomoConfig = {
455+
enabled: false,
455456
hostUrl: 'http://localhost:8135/',
456457
siteId: '1',
457458
dimensionId: 1

src/config/matomo-config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { Config } from './config.interface';
55
*/
66
export class MatomoConfig implements Config {
77

8+
public enabled: boolean;
9+
810
public hostUrl: string;
911

1012
public siteId: string;

src/environments/environment.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ export const environment: BuildConfig = {
356356
signpostingEnabled: true,
357357

358358
matomo: {
359+
enabled: false,
359360
hostUrl: 'http://localhost:8135/',
360361
siteId: '1',
361362
dimensionId: 1

src/main.browser.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ function addMatomoStatistics() {
5151
.then((config) => {
5252
const matomoConfig = config.matomo;
5353

54+
if (!matomoConfig?.enabled) {
55+
return;
56+
}
57+
5458
// Push all configuration commands first
5559
(window as any)._paq.push(['setTrackerUrl', matomoConfig.hostUrl + 'matomo.php']);
5660
(window as any)._paq.push(['setSiteId', matomoConfig.siteId]);

0 commit comments

Comments
 (0)