Add update download reason to analytics (#6023)

* Add  download reason to analytics

* mark modpack updates as actual updates in analytics

* fmt
This commit is contained in:
aecsocket
2026-05-07 14:07:20 +01:00
committed by GitHub
parent 56dae8f104
commit e8dc3c3150
10 changed files with 30 additions and 14 deletions

View File

@@ -218,9 +218,8 @@ pub async fn generate_pack_from_version_id(
icon_url: Option<String>,
profile_path: String,
// Existing loading bar. Unlike when existing_loading_bar is used, this one is pre-initialized with PackFileDownload
// For example, you might use this if multiple packs are being downloaded at once and you want to use the same loading bar
initialized_loading_bar: Option<LoadingBarId>,
reason: DownloadReason,
) -> crate::Result<CreatePack> {
let state = State::get().await?;
let has_icon_url = icon_url.is_some();
@@ -301,7 +300,7 @@ pub async fn generate_pack_from_version_id(
})?;
let download_meta = DownloadMeta {
reason: DownloadReason::Modpack,
reason,
game_version: profile.game_version.clone(),
loader: profile.loader.as_str().to_string(),
};

View File

@@ -48,6 +48,7 @@ pub async fn install_zipped_mrpack(
icon_url,
profile_path.clone(),
None,
DownloadReason::Modpack,
)
.await?
}
@@ -57,7 +58,12 @@ pub async fn install_zipped_mrpack(
};
// Install pack files, and if it fails, fail safely by removing the profile
let result = install_zipped_mrpack_files(create_pack, false).await;
let result = install_zipped_mrpack_files(
create_pack,
false,
DownloadReason::Modpack,
)
.await;
match result {
Ok(profile) => Ok(profile),
@@ -74,6 +80,7 @@ pub async fn install_zipped_mrpack(
pub async fn install_zipped_mrpack_files(
create_pack: CreatePack,
ignore_lock: bool,
reason: DownloadReason,
) -> crate::Result<String> {
let state = &State::get().await?;
@@ -221,7 +228,7 @@ pub async fn install_zipped_mrpack_files(
})?;
let download_meta = DownloadMeta {
reason: DownloadReason::Modpack,
reason,
game_version: profile.game_version.clone(),
loader: profile.loader.as_str().to_string(),
};

View File

@@ -461,7 +461,7 @@ pub async fn update_project(
let mut path = Profile::add_project_version(
profile_path,
update_version,
fetch::DownloadReason::Standalone,
fetch::DownloadReason::Update,
&state.pool,
&state.fetch_semaphore,
&state.io_semaphore,

View File

@@ -1,4 +1,5 @@
use crate::state::CacheBehaviour;
use crate::util::fetch::DownloadReason;
use crate::{
LoadingBarType,
event::{
@@ -162,7 +163,8 @@ async fn replace_managed_modrinth(
profile.name.clone(),
None,
profile_path.to_string(),
Some(shared_loading_bar.clone())
Some(shared_loading_bar.clone()),
DownloadReason::Update,
),
generate_pack_from_version_id(
project_id.clone(),
@@ -170,7 +172,8 @@ async fn replace_managed_modrinth(
profile.name.clone(),
None,
profile_path.to_string(),
Some(shared_loading_bar)
Some(shared_loading_bar),
DownloadReason::Update,
)
)?
} else {
@@ -182,6 +185,7 @@ async fn replace_managed_modrinth(
None,
profile_path.to_string(),
None,
DownloadReason::Update,
)
.await?;
old_pack_creator.description.existing_loading_bar = None;
@@ -205,6 +209,7 @@ async fn replace_managed_modrinth(
pack::install_mrpack::install_zipped_mrpack_files(
new_pack_creator,
ignore_lock,
DownloadReason::Update,
)
.await?;

View File

@@ -27,6 +27,7 @@ pub enum DownloadReason {
Standalone,
Dependency,
Modpack,
Update,
}
#[derive(Debug, Clone, Serialize)]