feat: use user_agent for download source

This commit is contained in:
tdgao
2026-05-18 16:03:24 -06:00
parent c1afb22e66
commit d6dc8a99f1
4 changed files with 9 additions and 7 deletions
@@ -21,7 +21,7 @@ export function getAnalyticsBreakdownValue(
return ALL_BREAKDOWN_VALUE
}
case 'download_source':
return normalizeBreakdownValue('domain' in point ? point.domain : undefined)
return normalizeBreakdownValue('user_agent' in point ? point.user_agent : undefined)
case 'download_reason':
return normalizeBreakdownValue(
'reason' in point ? point.reason : undefined,
@@ -717,7 +717,7 @@ function withBreakdownFields(
break
case 'download_source':
if (includesStat(breakdownStats, 'downloads') && includesStat(enabledStats, 'downloads')) {
downloads.push('domain')
downloads.push('user_agent')
}
break
case 'download_reason':
@@ -779,7 +779,7 @@ function withBreakdownFields(
if (filters.download_source.length > 0) {
const filterStats = getAnalyticsStatsForFilterCategory('download_source')
if (includesStat(filterStats, 'downloads') && includesStat(enabledStats, 'downloads')) {
downloads.push('domain')
downloads.push('user_agent')
}
}
@@ -695,8 +695,8 @@ function getAnalyticsDataFilterOptionSummary(
}
}
if (dataPoint.metric_kind === 'downloads' && dataPoint.domain) {
const downloadSource = dataPoint.domain.trim()
if (dataPoint.metric_kind === 'downloads' && dataPoint.user_agent) {
const downloadSource = dataPoint.user_agent.trim()
if (downloadSource.length > 0) {
downloadSources.add(downloadSource)
}
@@ -932,7 +932,7 @@ function getDownloadSourceFilterValue(
return undefined
}
return dataPoint.domain ?? null
return dataPoint.user_agent ?? null
}
function getDownloadReasonFilterValue(
@@ -1824,7 +1824,7 @@ export function createAnalyticsDashboardContext(
bucket_by: ['country'],
},
project_downloads: {
bucket_by: ['country', 'domain', 'reason', 'game_version', 'loader'],
bucket_by: ['country', 'user_agent', 'reason', 'game_version', 'loader'],
},
project_playtime: {
bucket_by: ['country', 'game_version', 'loader'],
@@ -299,6 +299,7 @@ export namespace Labrinth {
| 'project_id'
| 'version_id'
| 'domain'
| 'user_agent'
| 'site_path'
| 'country'
| 'monetized'
@@ -351,6 +352,7 @@ export namespace Labrinth {
export type ProjectDownloads = {
domain?: string
user_agent?: string
site_path?: string
version_id?: string
country?: string