From 43eb53eda5dc74d68e5368b48f42f5b39a63af91 Mon Sep 17 00:00:00 2001 From: "Calum H." Date: Sun, 8 Mar 2026 21:30:30 +0000 Subject: [PATCH] fix: posthog discrepancies linked server instances + other (#5504) --- apps/app-frontend/src/components/ui/Instance.vue | 2 +- .../src/components/ui/world/InstanceItem.vue | 2 +- .../src/components/ui/world/RecentWorldsList.vue | 13 ++++++++++--- apps/app-frontend/src/helpers/analytics.ts | 2 +- apps/app-frontend/src/pages/instance/Index.vue | 2 +- apps/app-frontend/src/pages/instance/Worlds.vue | 11 +++++++++++ apps/app-frontend/src/store/install.js | 15 +++++++++++++++ 7 files changed, 40 insertions(+), 7 deletions(-) diff --git a/apps/app-frontend/src/components/ui/Instance.vue b/apps/app-frontend/src/components/ui/Instance.vue index 73940147e..a73162731 100644 --- a/apps/app-frontend/src/components/ui/Instance.vue +++ b/apps/app-frontend/src/components/ui/Instance.vue @@ -69,7 +69,7 @@ const play = async (e, context) => { await run(props.instance.path) .catch((err) => handleSevereError(err, { profilePath: props.instance.path })) .finally(() => { - trackEvent('InstancePlay', { + trackEvent('InstanceStart', { loader: props.instance.loader, game_version: props.instance.game_version, source: context, diff --git a/apps/app-frontend/src/components/ui/world/InstanceItem.vue b/apps/app-frontend/src/components/ui/world/InstanceItem.vue index a4e181659..8057c0b85 100644 --- a/apps/app-frontend/src/components/ui/world/InstanceItem.vue +++ b/apps/app-frontend/src/components/ui/world/InstanceItem.vue @@ -80,7 +80,7 @@ const play = async (event: MouseEvent) => { await run(props.instance.path) .catch((err) => handleSevereError(err, { profilePath: props.instance.path })) .finally(() => { - trackEvent('InstancePlay', { + trackEvent('InstanceStart', { loader: props.instance.loader, game_version: props.instance.game_version, source: 'InstanceItem', diff --git a/apps/app-frontend/src/components/ui/world/RecentWorldsList.vue b/apps/app-frontend/src/components/ui/world/RecentWorldsList.vue index 4f715f2d0..3dbf238fd 100644 --- a/apps/app-frontend/src/components/ui/world/RecentWorldsList.vue +++ b/apps/app-frontend/src/components/ui/world/RecentWorldsList.vue @@ -175,10 +175,17 @@ function refreshServer(address: string, instancePath: string) { refreshServerData(serverData.value[address], protocolVersions.value[instancePath], address) } -async function joinWorld(world: WorldWithProfile) { +async function joinWorld(world: WorldWithProfile, instance?: GameInstance) { console.log(`Joining world ${getWorldIdentifier(world)}`) if (world.type === 'server') { await start_join_server(world.profile, world.address).catch(handleError) + if (instance) { + trackEvent('InstanceStart', { + loader: instance.loader, + game_version: instance.game_version, + source: 'WorldItem', + }) + } } else if (world.type === 'singleplayer') { await start_join_singleplayer_world(world.profile, world.path).catch(handleError) } @@ -188,7 +195,7 @@ async function playInstance(instance: GameInstance) { await run(instance.path) .catch((err) => handleSevereError(err, { profilePath: instance.path })) .finally(() => { - trackEvent('InstancePlay', { + trackEvent('InstanceStart', { loader: instance.loader, game_version: instance.game_version, source: 'WorldItem', @@ -317,7 +324,7 @@ onUnmounted(() => { () => { currentProfile = item.instance.path currentWorld = getWorldIdentifier(item.world) - joinWorld(item.world) + joinWorld(item.world, item.instance) } " @play-instance=" diff --git a/apps/app-frontend/src/helpers/analytics.ts b/apps/app-frontend/src/helpers/analytics.ts index 770001be2..2744d61f5 100644 --- a/apps/app-frontend/src/helpers/analytics.ts +++ b/apps/app-frontend/src/helpers/analytics.ts @@ -15,7 +15,7 @@ type AnalyticsEventMap = { PageView: { path: string; fromPath: string; failed: unknown } InstanceCreate: { source: string } InstanceCreateStart: { source: string } - InstancePlay: InstanceProperties & { source: string } + InstanceStart: InstanceProperties & { source: string } InstanceStop: Partial & { source?: string } InstanceDuplicate: InstanceProperties InstanceRepair: InstanceProperties diff --git a/apps/app-frontend/src/pages/instance/Index.vue b/apps/app-frontend/src/pages/instance/Index.vue index fa2c554ad..2b40f0708 100644 --- a/apps/app-frontend/src/pages/instance/Index.vue +++ b/apps/app-frontend/src/pages/instance/Index.vue @@ -501,7 +501,7 @@ const startInstance = async (context: string) => { } loading.value = false - trackEvent('InstancePlay', { + trackEvent('InstanceStart', { loader: instance.value.loader, game_version: instance.value.game_version, source: context, diff --git a/apps/app-frontend/src/pages/instance/Worlds.vue b/apps/app-frontend/src/pages/instance/Worlds.vue index 6623d140b..67f9035a8 100644 --- a/apps/app-frontend/src/pages/instance/Worlds.vue +++ b/apps/app-frontend/src/pages/instance/Worlds.vue @@ -145,6 +145,7 @@ import AddServerModal from '@/components/ui/world/modal/AddServerModal.vue' import EditServerModal from '@/components/ui/world/modal/EditServerModal.vue' import EditWorldModal from '@/components/ui/world/modal/EditSingleplayerWorldModal.vue' import WorldItem from '@/components/ui/world/WorldItem.vue' +import { trackEvent } from '@/helpers/analytics' import { get_project, get_project_v3 } from '@/helpers/cache.js' import { profile_listener } from '@/helpers/events' import { get_game_versions } from '@/helpers/tags' @@ -409,10 +410,20 @@ async function joinWorld(world: World) { const managedProjectId = instance.value.linked_data?.project_id if (managedProjectId && isManagedServerWorld(world)) { await playServerProject(managedProjectId).catch(handleJoinError) + trackEvent('InstanceStart', { + loader: instance.value.loader, + game_version: instance.value.game_version, + source: 'WorldsPage', + }) startingInstance.value = false return } await start_join_server(instance.value.path, world.address).catch(handleJoinError) + trackEvent('InstanceStart', { + loader: instance.value.loader, + game_version: instance.value.game_version, + source: 'WorldsPage', + }) } else if (world.type === 'singleplayer') { await start_join_singleplayer_world(instance.value.path, world.path).catch(handleJoinError) } diff --git a/apps/app-frontend/src/store/install.js b/apps/app-frontend/src/store/install.js index 702c2712c..18cb00185 100644 --- a/apps/app-frontend/src/store/install.js +++ b/apps/app-frontend/src/store/install.js @@ -404,6 +404,11 @@ const showModpackInstallSuccess = (installStore, project, serverAddress) => { serverAddress, project.linked_data?.project_id ?? null, ) + trackEvent('InstanceStart', { + loader: project.loader, + game_version: project.game_version, + source: 'ServerProject', + }) } catch (err) { handleSevereError(err, { profilePath: project.path }) } @@ -434,6 +439,11 @@ const showUpdateSuccess = (installStore, instance, serverAddress) => { action: async () => { try { if (serverAddress) await start_join_server(instance.path, serverAddress) + trackEvent('InstanceStart', { + loader: instance.loader, + game_version: instance.game_version, + source: 'ServerProject', + }) } catch (err) { handleSevereError(err, { profilePath: instance.path }) } @@ -530,6 +540,11 @@ export const playServerProject = async (projectId) => { // join server try { await joinServer(instance.path, serverAddress, project.id) + trackEvent('InstanceStart', { + loader: instance.loader, + game_version: instance.game_version, + source: 'ServerProject', + }) } catch (err) { handleSevereError(err, { profilePath: instance.path }) }