mirror of
https://github.com/OutlineFoundation/outline-server.git
synced 2026-11-21 23:32:32 +00:00
refactor(server): remove sanctioned-country filter from shared metrics (#1718)
Some checks failed
Build and Test / Lint (push) Has been cancelled
Build and Test / Manual Install Script (push) Has been cancelled
CodeQL analysis / Analyze (push) Has been cancelled
License checks / license-check (push) Has been cancelled
Build and Test / Shadowbox (push) Has been cancelled
Build and Test / Shadowbox (arm64) (push) Has been cancelled
Build and Test / Metrics Server (push) Has been cancelled
Build and Test / Sentry Webhook (push) Has been cancelled
Some checks failed
Build and Test / Lint (push) Has been cancelled
Build and Test / Manual Install Script (push) Has been cancelled
CodeQL analysis / Analyze (push) Has been cancelled
License checks / license-check (push) Has been cancelled
Build and Test / Shadowbox (push) Has been cancelled
Build and Test / Shadowbox (arm64) (push) Has been cancelled
Build and Test / Metrics Server (push) Has been cancelled
Build and Test / Sentry Webhook (push) Has been cancelled
* 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 <noreply@anthropic.com> * test(server): cover previously filtered countries in usage report spec Mix CU, KP and SY into the existing usage-report spec so restoring the removed filter would fail the suite. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * test(server): interleave a single previously filtered country Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
de566bfc9f
commit
bda9ef5ce9
2 changed files with 4 additions and 49 deletions
|
|
@ -104,7 +104,8 @@ describe('OutlineSharedMetricsPublisher', () => {
|
|||
startTime = clock.nowMs;
|
||||
usageMetrics.reportedUsage = [
|
||||
{country: 'EE', inboundBytes: 44, tunnelTimeSec: 11},
|
||||
{country: 'FF', inboundBytes: 55, tunnelTimeSec: 22},
|
||||
{country: 'SY', inboundBytes: 55, tunnelTimeSec: 22},
|
||||
{country: 'FF', inboundBytes: 66, tunnelTimeSec: 33},
|
||||
];
|
||||
|
||||
clock.nowMs += 60 * 60 * 1000;
|
||||
|
|
@ -115,7 +116,8 @@ describe('OutlineSharedMetricsPublisher', () => {
|
|||
endUtcMs: clock.nowMs,
|
||||
userReports: [
|
||||
{bytesTransferred: 44, countries: ['EE'], tunnelTimeSec: 11},
|
||||
{bytesTransferred: 55, countries: ['FF'], tunnelTimeSec: 22},
|
||||
{bytesTransferred: 55, countries: ['SY'], tunnelTimeSec: 22},
|
||||
{bytesTransferred: 66, countries: ['FF'], tunnelTimeSec: 33},
|
||||
],
|
||||
});
|
||||
|
||||
|
|
@ -205,45 +207,6 @@ describe('OutlineSharedMetricsPublisher', () => {
|
|||
]);
|
||||
publisher.stopSharing();
|
||||
});
|
||||
|
||||
it('ignores sanctioned countries', async () => {
|
||||
const clock = new ManualClock();
|
||||
const startTime = clock.nowMs;
|
||||
const serverConfig = new InMemoryConfig<ServerConfigJson>({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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue