Revert "check matomo and disable if necessary" #4655
1 changed files with 2 additions and 19 deletions
|
@ -56,24 +56,7 @@ type LogPublishParams = {
|
||||||
channel_claim_id?: string,
|
channel_claim_id?: string,
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkmatomo = (url, timeout = 2000) => {
|
|
||||||
return Promise.race([
|
|
||||||
fetch(url),
|
|
||||||
new Promise((resolve, reject) => setTimeout(() => reject(new Error('timeout')), timeout)),
|
|
||||||
]);
|
|
||||||
};
|
|
||||||
|
|
||||||
let internalAnalyticsEnabled: boolean = IS_WEB || false;
|
let internalAnalyticsEnabled: boolean = IS_WEB || false;
|
||||||
let matomoOnline = true;
|
|
||||||
if (internalAnalyticsEnabled) {
|
|
||||||
checkmatomo(MATOMO_URL)
|
|
||||||
.then()
|
|
||||||
.catch(() => {
|
|
||||||
matomoOnline = false;
|
|
||||||
console.log('matomo offline');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// let thirdPartyAnalyticsEnabled: boolean = IS_WEB || false;
|
// let thirdPartyAnalyticsEnabled: boolean = IS_WEB || false;
|
||||||
// @if TARGET='app'
|
// @if TARGET='app'
|
||||||
if (window.localStorage.getItem(SHARE_INTERNAL) === 'true') internalAnalyticsEnabled = true;
|
if (window.localStorage.getItem(SHARE_INTERNAL) === 'true') internalAnalyticsEnabled = true;
|
||||||
|
@ -106,7 +89,7 @@ const analytics: Analytics = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
pageView: path => {
|
pageView: path => {
|
||||||
if (internalAnalyticsEnabled && matomoOnline) {
|
if (internalAnalyticsEnabled) {
|
||||||
MatomoInstance.trackPageView({
|
MatomoInstance.trackPageView({
|
||||||
href: `${path}`,
|
href: `${path}`,
|
||||||
});
|
});
|
||||||
|
@ -262,7 +245,7 @@ const analytics: Analytics = {
|
||||||
};
|
};
|
||||||
|
|
||||||
function sendMatomoEvent(category, action, name, value) {
|
function sendMatomoEvent(category, action, name, value) {
|
||||||
if (internalAnalyticsEnabled && matomoOnline) {
|
if (internalAnalyticsEnabled) {
|
||||||
const event = { category, action, name, value };
|
const event = { category, action, name, value };
|
||||||
MatomoInstance.trackEvent(event);
|
MatomoInstance.trackEvent(event);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue