mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-30 01:32:44 +00:00
Track generator ID in custom dimension
Preparing to add back search parameters to share links
This commit is contained in:
@@ -6,6 +6,7 @@ export namespace Analytics {
|
|||||||
const DIM_VERSION = 3
|
const DIM_VERSION = 3
|
||||||
const DIM_LANGUAGE = 4
|
const DIM_LANGUAGE = 4
|
||||||
const DIM_PREVIEW = 5
|
const DIM_PREVIEW = 5
|
||||||
|
const DIM_GENERATOR = 6
|
||||||
|
|
||||||
function event(category: string, action: string, label?: string) {
|
function event(category: string, action: string, label?: string) {
|
||||||
ga('send', 'event', category, action, label)
|
ga('send', 'event', category, action, label)
|
||||||
@@ -40,6 +41,11 @@ export namespace Analytics {
|
|||||||
event(ID_GENERATOR, 'set-preview', preview)
|
event(ID_GENERATOR, 'set-preview', preview)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setGenerator(generator: string) {
|
||||||
|
dimension(DIM_GENERATOR, generator)
|
||||||
|
console.log(generator)
|
||||||
|
}
|
||||||
|
|
||||||
export function generatorEvent(action: string, label?: string) {
|
export function generatorEvent(action: string, label?: string) {
|
||||||
event(ID_GENERATOR, action, label)
|
event(ID_GENERATOR, action, label)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export function cleanUrl(url: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getGenerator(url: string) {
|
export function getGenerator(url: string) {
|
||||||
const trimmedUrl = url.replace(/^\//, '').replace(/\/$/, '')
|
const trimmedUrl = url.replace(/^\//, '').replace(/\/$/, '').replace(/\?.*/, '')
|
||||||
return config.generators.find(g => g.url === trimmedUrl)
|
return config.generators.find(g => g.url === trimmedUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,10 +31,6 @@ export function Generator({ lang, changeTitle, version, changeVersion }: Generat
|
|||||||
return <main><ErrorPanel error={`Cannot find generator "${getCurrentUrl()}"`} /></main>
|
return <main><ErrorPanel error={`Cannot find generator "${getCurrentUrl()}"`} /></main>
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setError(null)
|
|
||||||
}, [gen.id, version])
|
|
||||||
|
|
||||||
const allowedVersions = config.versions
|
const allowedVersions = config.versions
|
||||||
.filter(v => checkVersion(v.id, gen.minVersion, gen.maxVersion))
|
.filter(v => checkVersion(v.id, gen.minVersion, gen.maxVersion))
|
||||||
.map(v => v.id as VersionId)
|
.map(v => v.id as VersionId)
|
||||||
@@ -48,11 +44,15 @@ export function Generator({ lang, changeTitle, version, changeVersion }: Generat
|
|||||||
const [model, setModel] = useState<DataModel | null>(null)
|
const [model, setModel] = useState<DataModel | null>(null)
|
||||||
const [blockStates, setBlockStates] = useState<BlockStateRegistry | null>(null)
|
const [blockStates, setBlockStates] = useState<BlockStateRegistry | null>(null)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
setError(null)
|
||||||
setModel(null)
|
setModel(null)
|
||||||
getBlockStates(version)
|
getBlockStates(version)
|
||||||
.then(b => setBlockStates(b))
|
.then(b => setBlockStates(b))
|
||||||
getModel(version, gen.id)
|
getModel(version, gen.id)
|
||||||
.then(m => setModel(m))
|
.then(m => {
|
||||||
|
Analytics.setGenerator(gen.id)
|
||||||
|
setModel(m)
|
||||||
|
})
|
||||||
.catch(e => { console.error(e); setError(message(e)) })
|
.catch(e => { console.error(e); setError(message(e)) })
|
||||||
}, [version, gen.id])
|
}, [version, gen.id])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user