fix(analytics): keep package names and count artifact downloads only

The proxy passed request-buffer names to the analytics engine, which kept
them. The server reuses those buffers, so later requests rewrote the
stored names (for example lodash became lodas, and API paths appeared as
package names). The engine now copies the names it keeps.

Metadata pages (npm packuments, Go list, info and mod files, PyPI pages)
no longer count as downloads, and a Go module is one analytics key by its
module path. The version count now counts distinct versions.
This commit is contained in:
2026-11-24 02:05:53 +00:00
parent 8b4d4746df
commit 7470c41560
4 changed files with 223 additions and 3 deletions
+9 -1
View File
@@ -8,6 +8,7 @@ import (
"fmt"
"io"
"os"
"strings"
"sync"
"time"
@@ -986,8 +987,15 @@ func (m *Manager) Health(ctx context.Context) error {
return nil
}
// trackDownload tracks a package download event in analytics
// trackDownload records an artifact download under the package name. Metadata pages are not
// downloads, and a Go cache key (module/@v/version.zip) is one module.
func (m *Manager) trackDownload(registry, name, version string, size int64) {
if metadata.IsMetadataEntry(registry, name, version) {
return
}
if registry == metadata.GoRegistry {
name, _, _ = strings.Cut(name, "/@v/")
}
download := analytics.PackageDownload{
Registry: registry,
Name: name,