diff --git a/src/components/LocaleChanger.vue b/src/components/LocaleChanger.vue index c43dea3..1d1e00d 100644 --- a/src/components/LocaleChanger.vue +++ b/src/components/LocaleChanger.vue @@ -1,5 +1,6 @@ diff --git a/src/components/MenuButtons.vue b/src/components/MenuButtons.vue index cecbd2c..8aabc5c 100644 --- a/src/components/MenuButtons.vue +++ b/src/components/MenuButtons.vue @@ -7,6 +7,7 @@ import { vOnClickOutside }from '@vueuse/components'; import { useSearchStore } from '../stores/useBiomeSearchStore'; import StructureDropdown from './dropdown/StructureDropdown.vue'; import { useSettingsStore } from '../stores/useSettingsStore'; +import { EventTracker } from '../util/EventTracker'; const datapackStore = useDatapackStore() const searchStore = useSearchStore() @@ -17,6 +18,7 @@ const searchBiomeDropdownOpen = ref(false) const structureDropdownOpen = ref(false) function reload(event: MouseEvent){ + EventTracker.track("reload") datapackStore.$patch({}) } diff --git a/src/components/dropdown/OpenDropdown.vue b/src/components/dropdown/OpenDropdown.vue index 0710f78..4507858 100644 --- a/src/components/dropdown/OpenDropdown.vue +++ b/src/components/dropdown/OpenDropdown.vue @@ -8,6 +8,7 @@ import { useRecentStore } from '../../stores/useRecentStore'; import { useI18n } from 'vue-i18n'; import { useSettingsStore } from '../../stores/useSettingsStore'; import { versionMetadata } from '../../util'; +import { EventTracker } from '../../util/EventTracker'; const i18n = useI18n() @@ -27,9 +28,11 @@ async function loadHandle(handle: FileSystemHandle) { const file = await (handle as FileSystemFileHandle).getFile() datapack = Datapack.fromZipFile(file, versionMetadata[settingsStore.mc_version].datapackFormat) recentStore.addRecent(handle, datapack) + EventTracker.track(`add_datapack/recent/zip`) } else { datapack = Datapack.fromFileSystemDirectoryHandle(handle as FileSystemDirectoryHandle, versionMetadata[settingsStore.mc_version].datapackFormat) recentStore.addRecent(handle, datapack) + EventTracker.track(`add_datapack/recent/folder`) } datapackStore.addDatapack(datapack) } catch (e){ @@ -53,6 +56,7 @@ async function loadUrl(url: string) { async function loadZip(event: MouseEvent) { async function addZipDatapack(file: File) { + EventTracker.track(`add_datapack/zip`) const datapack = Datapack.fromZipFile(file, versionMetadata[settingsStore.mc_version].datapackFormat) datapackStore.addDatapack(datapack) return datapack @@ -131,6 +135,7 @@ async function loadFolder(event: MouseEvent) { } if (datapack !== undefined) { + EventTracker.track(`add_datapack/folder`) datapackStore.addDatapack(datapack) } emit('close') diff --git a/src/stores/useSettingsStore.ts b/src/stores/useSettingsStore.ts index 926e5f8..facfbe7 100644 --- a/src/stores/useSettingsStore.ts +++ b/src/stores/useSettingsStore.ts @@ -3,6 +3,7 @@ import { defineStore } from "pinia"; import { computed, ref, watch } from "vue"; import { useI18n } from "vue-i18n"; import { useDatapackStore } from "./useDatapackStore"; +import { EventTracker } from "../util/EventTracker"; export const useSettingsStore = defineStore('settings', () => { const i18n = useI18n() @@ -17,6 +18,26 @@ export const useSettingsStore = defineStore('settings', () => { const datapackStore = useDatapackStore() + watch(mc_version, (new_version) => { + EventTracker.track(`change_version/${new_version}`) + }) + + watch(world_preset, () => { + EventTracker.track(`change_world_preset`) + }) + + watch(dimension, () => { + EventTracker.track(`change_dimension`) + }) + + watch(seed, () => { + EventTracker.track(`change_seed`) + }) + + watch(dev_mode, (new_dev_mode) => { + EventTracker.track(`change_dev_mode/${new_dev_mode}`) + }) + datapackStore.$subscribe(async () => { if ((await datapackStore.dimensions)?.findIndex((id) => id.equals(dimension.value)) === -1) { dimension.value = (await datapackStore.dimensions)[0] diff --git a/src/util/EventTracker.ts b/src/util/EventTracker.ts new file mode 100644 index 0000000..bad7aa5 --- /dev/null +++ b/src/util/EventTracker.ts @@ -0,0 +1,7 @@ +export namespace EventTracker { + export function track(event: string ){ + if ((window as any).beam !== undefined) { + (window as any).beam("/event/" + event) + } + } +} \ No newline at end of file