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:
@@ -184,7 +184,7 @@ 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 type DownloadReason = 'standalone' | 'dependency' | 'modpack'
|
||||
export type DownloadReason = 'standalone' | 'dependency' | 'modpack' | 'update'
|
||||
|
||||
export async function add_project_from_version(
|
||||
path: string,
|
||||
|
||||
@@ -311,7 +311,7 @@ async function updateProject(mod: ContentItem) {
|
||||
const profile = await get(props.instance.path).catch(handleError)
|
||||
|
||||
if (profile) {
|
||||
await installVersionDependencies(profile, versionData).catch(handleError)
|
||||
await installVersionDependencies(profile, versionData, 'update').catch(handleError)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -347,7 +347,7 @@ async function switchProjectVersion(mod: ContentItem, version: Labrinth.Versions
|
||||
|
||||
const profile = await get(props.instance.path).catch(handleError)
|
||||
if (profile) {
|
||||
await installVersionDependencies(profile, version).catch(handleError)
|
||||
await installVersionDependencies(profile, version, 'update').catch(handleError)
|
||||
}
|
||||
|
||||
mod.file_path = newPath
|
||||
|
||||
@@ -430,6 +430,7 @@ export function createContentInstall(opts: {
|
||||
await installVersionDependencies(
|
||||
profile,
|
||||
version,
|
||||
'dependency',
|
||||
(depProject: Labrinth.Projects.v2.Project, depVersion?: Labrinth.Versions.v2.Version) => {
|
||||
addInstallingItem(instance.id, depProject, depVersion)
|
||||
installedProjectIds.push(depProject.id)
|
||||
@@ -488,7 +489,7 @@ export function createContentInstall(opts: {
|
||||
await opts.router.push(`/instance/${encodeURIComponent(id)}/`)
|
||||
|
||||
const instance = await get(id)
|
||||
await installVersionDependencies(instance, version)
|
||||
await installVersionDependencies(instance, version, 'dependency')
|
||||
|
||||
trackEvent('InstanceCreate', {
|
||||
source: 'ProjectInstallModal',
|
||||
@@ -589,6 +590,7 @@ export function createContentInstall(opts: {
|
||||
await installVersionDependencies(
|
||||
instance,
|
||||
version,
|
||||
'dependency',
|
||||
(
|
||||
depProject: Labrinth.Projects.v2.Project,
|
||||
depVersion?: Labrinth.Versions.v2.Version,
|
||||
|
||||
@@ -48,7 +48,7 @@ export const isVersionCompatible = (version, project, instance) => {
|
||||
)
|
||||
}
|
||||
|
||||
export const installVersionDependencies = async (profile, version, onDepInstalling) => {
|
||||
export const installVersionDependencies = async (profile, version, reason, onDepInstalling) => {
|
||||
const projectNames = new Map()
|
||||
const storeProjectName = (p) => {
|
||||
if (p?.id && p.title) projectNames.set(p.id, p.title)
|
||||
@@ -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, 'dependency')
|
||||
await add_project_from_version(profile.path, versionId, reason)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ pub enum DownloadReason {
|
||||
Dependency,
|
||||
/// Project was downloaded as part of a modpack.
|
||||
Modpack,
|
||||
/// Project was re-downloaded due to an update.
|
||||
Update,
|
||||
}
|
||||
|
||||
impl std::str::FromStr for DownloadReason {
|
||||
|
||||
Reference in New Issue
Block a user