chore: remove umami, release 5.3.2

This commit is contained in:
David Ralph
2021-08-23 15:33:09 +01:00
parent 1d99622123
commit 30768053eb
16 changed files with 27 additions and 97 deletions

View File

@@ -26,13 +26,9 @@ export const COPYRIGHT_YEAR = '2018';
export const COPYRIGHT_LICENSE = 'BSD-3 License';
export const DONATE_USERNAME = 'davidjcralph'; // this only works if you use the same username for Patreon, GitHub and Ko-Fi
// umami
export const UMAMI_DOMAIN = 'https://umami.muetab.com';
export const UMAMI_ID = '1b97e723-199c-48d8-8992-17c4e22d4f3c';
// Offline images
export const OFFLINE_IMAGES = 20;
// Version
export const BETA_VERSION = false;
export const VERSION = '5.3.1';
export const VERSION = '5.3.2';

View File

@@ -1,33 +1,7 @@
export default class Stats {
constructor(id) {
this.id = id;
this.url = window.constants.UMAMI_DOMAIN + '/api/collect';
this.online = (localStorage.getItem('offlineMode') === 'false');
}
async postEvent(type, name) {
static async postEvent(type, name) {
const value = name.toLowerCase().replaceAll(' ', '-');
if (this.online) {
// umami
await fetch(this.url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
type: 'event',
payload: {
website: this.id,
url: '/',
event_type: type,
event_value: value
}
})
});
}
// local
const data = JSON.parse(localStorage.getItem('statsData'));
// tl;dr this creates the objects if they don't exist
// this really needs a cleanup at some point
@@ -45,29 +19,9 @@ export default class Stats {
localStorage.setItem('statsData', JSON.stringify(data));
}
async tabLoad() {
if (this.online) {
// umami
await fetch(this.url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
type: 'pageview',
payload: {
website: this.id,
url: '/',
language: window.languagecode.replace('_', '-'),
screen: `${window.screen.width}x${window.screen.height}`
}
})
});
}
// local
static async tabLoad() {
const data = JSON.parse(localStorage.getItem('statsData'));
data['tabs-opened'] = data['tabs-opened'] + 1 || 1;
localStorage.setItem('statsData', JSON.stringify(data));
}
}
}