feat(voice): ship noise suppression treatment to everyone (#3029)

This commit is contained in:
Hampus authored and GitHub committed 2026-09-29 03:43:58 +02:00
1 parent 39c72f0fb0
commit c488906131
88 files changed
+2861 -5837

No files matched your search

@@ -0,0 +1,43 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {experimentBucket} from '@fluxer/schema/src/domains/experiment/ExperimentBucket';
import {describe, expect, test} from 'vitest';
const TARGETED_USER_ID = '1000000000000000001';
const OTHER_USER_ID = '1000000000000000002';
function syntheticUserIds(count: number): Array<string> {
const ids: Array<string> = [];
for (let index = 0; index < count; index++) {
ids.push((1400000000000000000n + BigInt(index)).toString());
}
return ids;
}
describe('experimentBucket', () => {
test('stays inside the basis point range for every synthetic id', () => {
for (const userId of syntheticUserIds(500)) {
const bucket = experimentBucket(userId, 'voice-ns-v1');
expect(Number.isInteger(bucket)).toBe(true);
expect(bucket).toBeGreaterThanOrEqual(0);
expect(bucket).toBeLessThan(10000);
}
});
test.each([
{userId: TARGETED_USER_ID, salt: 'voice-ns-v1', expected: 8241},
{userId: TARGETED_USER_ID, salt: 'voice-ns-v2', expected: 8500},
{userId: OTHER_USER_ID, salt: 'voice-ns-v1', expected: 5384},
{userId: OTHER_USER_ID, salt: 'voice-ns-v2', expected: 1357},
])('preserves the assignment bucket for $userId with salt $salt', ({userId, salt, expected}) => {
expect(experimentBucket(userId, salt)).toBe(expected);
});
test('changes with the salt for at least most user ids', () => {
const userIds = syntheticUserIds(200);
const changed = userIds.filter(
(userId) => experimentBucket(userId, 'voice-ns-v1') !== experimentBucket(userId, 'voice-ns-v2'),
);
expect(changed.length).toBeGreaterThan(userIds.length - 5);
});
});
@@ -9,10 +9,6 @@ import {
INERT_PROFILE_TIMEZONE_ASSIGNMENT,
ProfileTimezoneAssignmentResponse,
} from '@fluxer/schema/src/domains/admin/ProfileTimezoneSchemas';
import {
INERT_VOICE_NOISE_SUPPRESSION_ASSIGNMENT,
VoiceNoiseSuppressionAssignmentResponse,
} from '@fluxer/schema/src/domains/admin/VoiceNoiseSuppressionSchemas';
import {z} from 'zod';
export const EXPERIMENT_MIN_POLL_INTERVAL_SECONDS = 60;
@@ -50,7 +46,6 @@ export const ExperimentDeliveryConfigResponse = ExperimentDeliveryConfigSchema;
export type ExperimentDeliveryConfigResponse = z.infer<typeof ExperimentDeliveryConfigResponse>;
const ExperimentAssignmentsSchema = z.object({
voice_noise_suppression: VoiceNoiseSuppressionAssignmentResponse.optional(),
domain_migration: DomainMigrationAssignmentResponse.optional(),
altcha_captcha: AltchaCaptchaAssignmentResponse.optional(),
profile_timezone: ProfileTimezoneAssignmentResponse.optional(),
@@ -70,12 +65,6 @@ export const INERT_EXPERIMENT_ASSIGNMENTS_RESPONSE: ExperimentAssignmentsRespons
assignments: {},
};
export function readVoiceNoiseSuppressionAssignment(
response: ExperimentAssignmentsResponse,
): VoiceNoiseSuppressionAssignmentResponse {
return response.assignments.voice_noise_suppression ?? INERT_VOICE_NOISE_SUPPRESSION_ASSIGNMENT;
}
export function readDomainMigrationAssignment(
response: ExperimentAssignmentsResponse,
): DomainMigrationAssignmentResponse {