Switch to vite and preact

This commit is contained in:
Misode
2021-06-23 20:44:28 +02:00
parent e551b7ef75
commit 09c851914f
89 changed files with 6398 additions and 15531 deletions

46
src/app/Analytics.ts Normal file
View File

@@ -0,0 +1,46 @@
export namespace Analytics {
const ID_SITE = 'Site'
const ID_GENERATOR = 'Generator'
const DIM_THEME = 1
const DIM_VERSION = 3
const DIM_LANGUAGE = 4
const DIM_PREVIEW = 5
function event(category: string, action: string, label?: string) {
ga('send', 'event', category, action, label)
}
function dimension(index: number, value: string) {
ga('set', `dimension${index}`, value)
}
export function pageview(page: string) {
ga('set', 'page', page)
ga('send', 'pageview')
}
export function setLanguage(language: string) {
dimension(DIM_LANGUAGE, language)
event(ID_SITE, 'set-language', language)
}
export function setTheme(theme: string) {
dimension(DIM_THEME, theme)
event(ID_SITE, 'set-theme', theme)
}
export function setVersion(version: string) {
dimension(DIM_VERSION, version)
event(ID_GENERATOR, 'set-version', version)
}
export function setPreview(preview: string) {
dimension(DIM_PREVIEW, preview)
event(ID_GENERATOR, 'set-preview', preview)
}
export function generatorEvent(action: string, label?: string) {
event(ID_GENERATOR, action, label)
}
}