From 22c0ba084e20fb2db322672229984a52bd60fc96 Mon Sep 17 00:00:00 2001 From: Sarah Laplante Date: Wed, 21 Oct 2026 13:58:55 +0200 Subject: [PATCH] refactor(server): remove sanctioned-country filter from shared metrics The opt-in usage report dropped rows from a hardcoded set of countries (CU, KP, SY). PR #1717 proposed removing just SY; this removes the filter entirely, along with its helper and the spec that covered it. Co-Authored-By: Claude Fable 5.1 --- src/shadowbox/server/shared_metrics.spec.ts | 39 --------------------- src/shadowbox/server/shared_metrics.ts | 8 ----- 2 files changed, 47 deletions(-) diff --git a/src/shadowbox/server/shared_metrics.spec.ts b/src/shadowbox/server/shared_metrics.spec.ts index ebe57025..6d68229e 100644 --- a/src/shadowbox/server/shared_metrics.spec.ts +++ b/src/shadowbox/server/shared_metrics.spec.ts @@ -205,45 +205,6 @@ describe('OutlineSharedMetricsPublisher', () => { ]); publisher.stopSharing(); }); - - it('ignores sanctioned countries', async () => { - const clock = new ManualClock(); - const startTime = clock.nowMs; - const serverConfig = new InMemoryConfig({serverId: 'server-id'}); - const usageMetrics = new ManualUsageMetrics(); - const metricsCollector = new FakeMetricsCollector(); - const publisher = new OutlineSharedMetricsPublisher( - clock, - serverConfig, - null, - usageMetrics, - metricsCollector - ); - - publisher.startSharing(); - usageMetrics.reportedUsage = [ - {country: 'AA', tunnelTimeSec: 99, inboundBytes: 11}, - {country: 'SY', tunnelTimeSec: 88, inboundBytes: 11}, - {country: 'CC', tunnelTimeSec: 77, inboundBytes: 22}, - {country: 'AA', tunnelTimeSec: 66, inboundBytes: 33}, - {country: 'DD', tunnelTimeSec: 55, inboundBytes: 33}, - ]; - - clock.nowMs += 60 * 60 * 1000; - await clock.runCallbacks(); - expect(metricsCollector.collectedServerUsageReport).toEqual({ - serverId: 'server-id', - startUtcMs: startTime, - endUtcMs: clock.nowMs, - userReports: [ - {bytesTransferred: 11, tunnelTimeSec: 99, countries: ['AA']}, - {bytesTransferred: 22, tunnelTimeSec: 77, countries: ['CC']}, - {bytesTransferred: 33, tunnelTimeSec: 66, countries: ['AA']}, - {bytesTransferred: 33, tunnelTimeSec: 55, countries: ['DD']}, - ], - }); - publisher.stopSharing(); - }); }); it('reports feature metrics correctly', async () => { const clock = new ManualClock(); diff --git a/src/shadowbox/server/shared_metrics.ts b/src/shadowbox/server/shared_metrics.ts index 8cb4b949..2cc77bc9 100644 --- a/src/shadowbox/server/shared_metrics.ts +++ b/src/shadowbox/server/shared_metrics.ts @@ -24,7 +24,6 @@ import {ServerConfigJson} from './server_config'; const MS_PER_HOUR = 60 * 60 * 1000; const MS_PER_DAY = 24 * MS_PER_HOUR; -const SANCTIONED_COUNTRIES = new Set(['CU', 'KP', 'SY']); export interface ReportedUsage { country: string; @@ -238,9 +237,6 @@ export class OutlineSharedMetricsPublisher implements SharedMetricsPublisher { if (locationUsage.inboundBytes === 0 && locationUsage.tunnelTimeSec === 0) { continue; } - if (isSanctionedCountry(locationUsage.country)) { - continue; - } // Make sure to always set a country, which is required by the metrics server validation. // It's used to differentiate the row from the legacy key usage rows. const country = locationUsage.country || 'ZZ'; @@ -282,7 +278,3 @@ export class OutlineSharedMetricsPublisher implements SharedMetricsPublisher { await this.metricsCollector.collectFeatureMetrics(featureMetricsReport); } } - -function isSanctionedCountry(country: string) { - return SANCTIONED_COUNTRIES.has(country); -}