Have app send download analytics meta (#5954)

* wip: add download reasons to app

* update how download meta is gathered

* cargo fmt

* prepr frontend
This commit is contained in:
aecsocket
2026-04-30 20:55:47 +01:00
committed by GitHub
parent 38a39feef1
commit 1875b89556
20 changed files with 195 additions and 32 deletions

View File

@@ -107,7 +107,7 @@ defineExpose({
const install = async () => {
installing.value = true
await installMod(instance.value.path, selectedVersion.value.id).catch(handleError)
await installMod(instance.value.path, selectedVersion.value.id, 'standalone').catch(handleError)
installing.value = false
onInstall.value(selectedVersion.value.id)
incompatibleModal.value.hide()

View File

@@ -116,7 +116,7 @@ async function install(instance) {
return
}
await installMod(instance.path, version.id).catch(handleError)
await installMod(instance.path, version.id, 'standalone').catch(handleError)
await installVersionDependencies(instance, version).catch(handleError)
instance.installedMod = true
@@ -188,7 +188,7 @@ const createInstance = async () => {
const id = await create(name.value, gameVersion, loader, 'latest', icon.value).catch(handleError)
await installMod(id, versions.value[0].id).catch(handleError)
await installMod(id, versions.value[0].id, 'standalone').catch(handleError)
await router.push(`/instance/${encodeURIComponent(id)}/`)

View File

@@ -184,8 +184,18 @@ export async function update_project(path: string, projectPath: string): Promise
// Add a project to a profile from a version
// Returns a path to the new project file
export async function add_project_from_version(path: string, versionId: string): Promise<string> {
return await invoke('plugin:profile|profile_add_project_from_version', { path, versionId })
export type DownloadReason = 'standalone' | 'dependency' | 'modpack'
export async function add_project_from_version(
path: string,
versionId: string,
reason: DownloadReason,
): Promise<string> {
return await invoke('plugin:profile|profile_add_project_from_version', {
path,
versionId,
reason,
})
}
// Add a project to a profile from a path + project_type

View File

@@ -343,7 +343,7 @@ async function switchProjectVersion(mod: ContentItem, version: Labrinth.Versions
}
try {
await remove_project(props.instance.path, mod.file_path!)
const newPath = await add_project_from_version(props.instance.path, version.id)
const newPath = await add_project_from_version(props.instance.path, version.id, 'standalone')
const profile = await get(props.instance.path).catch(handleError)
if (profile) {

View File

@@ -426,7 +426,7 @@ export function createContentInstall(opts: {
}
try {
await add_project_from_version(instance.id, version.id)
await add_project_from_version(instance.id, version.id, 'standalone')
await installVersionDependencies(
profile,
version,
@@ -484,7 +484,7 @@ export function createContentInstall(opts: {
)
if (!id) return
await add_project_from_version(id, version.id)
await add_project_from_version(id, version.id, 'standalone')
await opts.router.push(`/instance/${encodeURIComponent(id)}/`)
const instance = await get(id)
@@ -585,7 +585,7 @@ export function createContentInstall(opts: {
const installedProjectIds: string[] = [project.id]
addInstallingItem(instancePath, project, version)
try {
await add_project_from_version(instance.path, version.id)
await add_project_from_version(instance.path, version.id, 'standalone')
await installVersionDependencies(
instance,
version,

View File

@@ -177,7 +177,7 @@ export const installVersionDependencies = async (profile, version, onDepInstalli
const batch = queuedInstalls.slice(i, i + batchSize)
await Promise.all(
batch.map(async ({ versionId }) => {
await add_project_from_version(profile.path, versionId)
await add_project_from_version(profile.path, versionId, 'dependency')
}),
)
}

View File

@@ -4,6 +4,7 @@ use path_util::SafeRelativeUtf8UnixPathBuf;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use theseus::DownloadReason;
use theseus::data::{ContentItem, Dependency, LinkedModpackInfo};
use theseus::prelude::*;
use theseus::profile::QuickPlayType;
@@ -249,8 +250,9 @@ pub async fn profile_update_project(
pub async fn profile_add_project_from_version(
path: &str,
version_id: &str,
reason: DownloadReason,
) -> Result<String> {
Ok(profile::add_project_from_version(path, version_id).await?)
Ok(profile::add_project_from_version(path, version_id, reason).await?)
}
// Adds a project to a profile from a path