Skip to content

Commit c144f6b

Browse files
committed
prevent regression in runtime enablement
1 parent fc18752 commit c144f6b

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/main.browser.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ const main = () => {
2727
enableProdMode();
2828
}
2929

30-
addMatomoStatistics();
3130
if (hasTransferState) {
3231
// Configuration will be taken from transfer state during initialization
32+
addMatomoStatistics();
3333
return bootstrap();
3434
} else {
3535
// Configuration must be fetched explicitly
@@ -38,18 +38,21 @@ const main = () => {
3838
.then((appConfig: AppConfig) => {
3939
// extend environment with app config for browser when not prerendered
4040
extendEnvironmentWithAppConfig(environment, appConfig);
41+
addMatomoStatistics();
4142
return bootstrap();
4243
});
4344
}
4445
};
4546

4647
function addMatomoStatistics() {
4748
// Debug: Log the matomo configuration
48-
console.log('Matomo config check:', {
49-
hasMatomo: !!environment.matomo,
50-
enabled: environment.matomo?.enabled,
51-
full: environment.matomo
52-
});
49+
if (!environment.production) {
50+
console.log('Matomo config check:', {
51+
hasMatomo: !!environment.matomo,
52+
enabled: environment.matomo?.enabled,
53+
full: environment.matomo
54+
});
55+
}
5356

5457
// Check if Matomo is enabled in the environment configuration
5558
if (!environment.matomo || !environment.matomo.enabled) {

src/modules/app/browser-init.service.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,19 @@ export class BrowserInitService extends InitService {
113113
// ideally we'd add the custom dimension to the 'trackPageView' action only, but don't have that information
114114
// in pageTrack context. So we add it to page_view events, and remove it after the page view.
115115
// page_view events are fired via view-track.component, and exposes dc.identifier.uri via properties
116+
const dimensionId = this.appConfig.matomo.dimensionId;
116117
this.angulartics2Matomo.eventTrack = function (action: string, properties?: any) {
117118
if (action === 'page_view') {
118119
if (properties.dc_identifier) {
119-
(window as any)._paq.push(['setCustomDimension', this.appConfig.matomo.dimensionId, properties.dc_identifier]);
120+
(window as any)._paq.push(['setCustomDimension', dimensionId, properties.dc_identifier]);
120121
}
121122
}
122-
}.bind(this);
123+
};
123124
let pageTrack = this.angulartics2Matomo.pageTrack;
124125
this.angulartics2Matomo.pageTrack = function (path: string) {
125126
pageTrack.call(this, path);
126-
(window as any)._paq.push(['deleteCustomDimension', this.appConfig.matomo.dimensionId]);
127-
}.bind(this);
127+
(window as any)._paq.push(['deleteCustomDimension', dimensionId]);
128+
};
128129
this.angulartics2Matomo.startTracking();
129130
}
130131

0 commit comments

Comments
 (0)