mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-11-26 06:37:07 +00:00
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:
Vendored
+9
-1
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user