From c1bb029a1c3e054a8bf0b3a18721e5a5a7b62819 Mon Sep 17 00:00:00 2001 From: miloschwartz Date: Wed, 22 Oct 2025 21:41:36 -0700 Subject: [PATCH] simplify telemetry collection --- server/lib/telemetry.ts | 65 +++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/server/lib/telemetry.ts b/server/lib/telemetry.ts index 56d54d7c..d3b0b9d6 100644 --- a/server/lib/telemetry.ts +++ b/server/lib/telemetry.ts @@ -200,10 +200,7 @@ class TelemetryClient { event: "supporter_status", properties: { valid: stats.supporterStatus.valid, - tier: stats.supporterStatus.tier, - github_username: stats.supporterStatus.githubUsername - ? this.anon(stats.supporterStatus.githubUsername) - : "None" + tier: stats.supporterStatus.tier } }); } @@ -217,21 +214,6 @@ class TelemetryClient { install_timestamp: hostMeta.createdAt } }); - - for (const email of stats.adminUsers) { - // There should only be on admin user, but just in case - if (email) { - this.client.capture({ - distinctId: this.anon(email), - event: "admin_user", - properties: { - host_id: hostMeta.hostMetaId, - app_version: stats.appVersion, - hashed_email: this.anon(email) - } - }); - } - } } private async collectAndSendAnalytics() { @@ -262,19 +244,38 @@ class TelemetryClient { num_clients: stats.numClients, num_identity_providers: stats.numIdentityProviders, num_sites_online: stats.numSitesOnline, - resources: stats.resources.map((r) => ({ - name: this.anon(r.name), - sso_enabled: r.sso, - protocol: r.protocol, - http_enabled: r.http - })), - sites: stats.sites.map((s) => ({ - site_name: this.anon(s.siteName), - megabytes_in: s.megabytesIn, - megabytes_out: s.megabytesOut, - type: s.type, - online: s.online - })), + num_resources_sso_enabled: stats.resources.filter( + (r) => r.sso + ).length, + num_resources_non_http: stats.resources.filter( + (r) => !r.http + ).length, + num_newt_sites: stats.sites.filter((s) => s.type === "newt") + .length, + num_local_sites: stats.sites.filter( + (s) => s.type === "local" + ).length, + num_wg_sites: stats.sites.filter( + (s) => s.type === "wireguard" + ).length, + avg_megabytes_in: + stats.sites.length > 0 + ? Math.round( + stats.sites.reduce( + (sum, s) => sum + (s.megabytesIn ?? 0), + 0 + ) / stats.sites.length + ) + : 0, + avg_megabytes_out: + stats.sites.length > 0 + ? Math.round( + stats.sites.reduce( + (sum, s) => sum + (s.megabytesOut ?? 0), + 0 + ) / stats.sites.length + ) + : 0, num_api_keys: stats.numApiKeys, num_custom_roles: stats.numCustomRoles }