Skip to content

Commit eec6072

Browse files
committed
added debug info to console, fix logic about matomo disability
1 parent b2a2b66 commit eec6072

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/app/item-page/clarin-matomo-statistics/clarin-matomo-statistics.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ export class ClarinMatomoStatisticsComponent implements OnInit {
135135

136136
ngOnInit(): void {
137137
// Check if Matomo is enabled in the environment
138-
this.matomoEnabled = environment.matomo?.enabled || false;
139-
138+
this.matomoEnabled = environment.matomo?.enabled === true;
139+
140140
// If Matomo is disabled, don't fetch statistics
141141
if (!this.matomoEnabled) {
142142
return;

src/main.browser.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ function addMatomoStatistics() {
6565
g.src = environment.matomo.hostUrl + 'matomo.js';
6666
document.getElementsByTagName('head')[0].appendChild(g);
6767
} catch (error) {
68-
// Silently fail if Matomo initialization fails to avoid interfering with tests
68+
// Log error unless in a test environment to aid debugging in production
69+
if (!('test' in environment && environment.test)) {
70+
// Log the error to the console for visibility in production and development
71+
console.error('Matomo initialization failed:', error);
72+
}
73+
// Silently fail in test environments to avoid interfering with tests
6974
return;
7075
}
7176
}

0 commit comments

Comments
 (0)