mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 21:45:31 +09:00
feat(app): gate the expression info card behind an experiment (#2773)
This commit is contained in:
1 parent
7c9274847f
commit
6339c3b8ad
110 files changed
+12827
-5191
No files matched your search
@@ -21,6 +21,10 @@ import {
|
||||
DEFAULT_EXPERIMENT_DELIVERY_CONFIG,
|
||||
type ExperimentDeliveryConfig,
|
||||
} from '@fluxer/schema/src/domains/experiment/ExperimentSchemas';
|
||||
import {
|
||||
DEFAULT_EXPRESSION_INFO_CARD_CONFIG,
|
||||
type ExpressionInfoCardConfig,
|
||||
} from '@fluxer/schema/src/domains/experiment/ExpressionInfoCardSchemas';
|
||||
import {
|
||||
DEFAULT_GUILD_ACTIVITY_LOG_PRESENTATION_CONFIG,
|
||||
type GuildActivityLogPresentationConfig,
|
||||
@@ -40,6 +44,7 @@ const MESSAGE_HOVER_TRACKING_CONFIG_KEY = 'message_hover_tracking_config';
|
||||
const MESSAGE_KEYBOARD_FOCUS_CONFIG_KEY = 'message_keyboard_focus_config';
|
||||
const BLOCKED_MESSAGE_GROUPS_CONFIG_KEY = 'blocked_message_groups_config';
|
||||
const GUILD_ACTIVITY_LOG_PRESENTATION_CONFIG_KEY = 'guild_activity_log_presentation_config';
|
||||
const EXPRESSION_INFO_CARD_CONFIG_KEY = 'expression_info_card_config';
|
||||
const EXPERIMENT_DELIVERY_CONFIG_KEY = 'experiment_delivery_config';
|
||||
const APP_PUBLIC_CONFIG_KEY = 'app_public_config';
|
||||
const INSTANCE_POLICY_CONFIG_KEY = 'instance_policy_config';
|
||||
@@ -516,6 +521,51 @@ describe('InstanceConfigRepository', () => {
|
||||
await expect(repository.getGuildActivityLogPresentationConfig()).resolves.toEqual(config);
|
||||
});
|
||||
|
||||
it('returns the default expression info card config when the key is absent', async () => {
|
||||
const executor = new CountingInMemoryCassandraQueryExecutor();
|
||||
setCassandraQueryExecutorForTesting(executor);
|
||||
const kvProvider = new MockKVProvider();
|
||||
const repository = createRepository(kvProvider);
|
||||
|
||||
await expect(repository.getExpressionInfoCardConfig()).resolves.toEqual(DEFAULT_EXPRESSION_INFO_CARD_CONFIG);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{name: 'unparseable text', stored: 'not-json'},
|
||||
{name: 'a json array', stored: '[]'},
|
||||
{name: 'out-of-range values', stored: '{"rollout_basis_points":99999}'},
|
||||
{name: 'a target that is not a snowflake', stored: '{"included_user_ids":["nope"]}'},
|
||||
])('falls back to the default expression info card config for $name', async ({stored}) => {
|
||||
const executor = new CountingInMemoryCassandraQueryExecutor();
|
||||
setCassandraQueryExecutorForTesting(executor);
|
||||
const kvProvider = new MockKVProvider();
|
||||
const repository = createRepository(kvProvider);
|
||||
|
||||
await repository.setConfig(EXPRESSION_INFO_CARD_CONFIG_KEY, stored);
|
||||
|
||||
await expect(repository.getExpressionInfoCardConfig()).resolves.toEqual(DEFAULT_EXPRESSION_INFO_CARD_CONFIG);
|
||||
});
|
||||
|
||||
it('round-trips a stored expression info card config', async () => {
|
||||
const executor = new CountingInMemoryCassandraQueryExecutor();
|
||||
setCassandraQueryExecutorForTesting(executor);
|
||||
const kvProvider = new MockKVProvider();
|
||||
const repository = createRepository(kvProvider);
|
||||
|
||||
const config: ExpressionInfoCardConfig = {
|
||||
...DEFAULT_EXPRESSION_INFO_CARD_CONFIG,
|
||||
enabled: true,
|
||||
config_version: 5,
|
||||
rollout_basis_points: 2500,
|
||||
rollout_salt: 'expression-info-card-v2',
|
||||
included_user_ids: ['1400000000000000001'],
|
||||
excluded_user_ids: ['1400000000000000002'],
|
||||
};
|
||||
await repository.setExpressionInfoCardConfig(config);
|
||||
|
||||
await expect(repository.getExpressionInfoCardConfig()).resolves.toEqual(config);
|
||||
});
|
||||
|
||||
it('fills newly added voice noise suppression fields from the schema defaults', async () => {
|
||||
const executor = new CountingInMemoryCassandraQueryExecutor();
|
||||
setCassandraQueryExecutorForTesting(executor);
|
||||
|
||||
@@ -40,6 +40,10 @@ import {
|
||||
type ExperimentDeliveryConfig,
|
||||
ExperimentDeliveryConfigSchema,
|
||||
} from '@fluxer/schema/src/domains/experiment/ExperimentSchemas';
|
||||
import {
|
||||
type ExpressionInfoCardConfig,
|
||||
ExpressionInfoCardConfigSchema,
|
||||
} from '@fluxer/schema/src/domains/experiment/ExpressionInfoCardSchemas';
|
||||
import {
|
||||
type GuildActivityLogPresentationConfig,
|
||||
GuildActivityLogPresentationConfigSchema,
|
||||
@@ -75,6 +79,7 @@ const EXPERIMENT_DELIVERY_CONFIG_KEY = 'experiment_delivery_config';
|
||||
const MESSAGE_HOVER_TRACKING_CONFIG_KEY = 'message_hover_tracking_config';
|
||||
const MESSAGE_KEYBOARD_FOCUS_CONFIG_KEY = 'message_keyboard_focus_config';
|
||||
const BLOCKED_MESSAGE_GROUPS_CONFIG_KEY = 'blocked_message_groups_config';
|
||||
const EXPRESSION_INFO_CARD_CONFIG_KEY = 'expression_info_card_config';
|
||||
const REGISTRATION_CONFIG_KEY = 'registration_config';
|
||||
const REGISTRATION_URLS_KEY = 'registration_urls';
|
||||
const REGISTRATION_PENDING_APPROVALS_KEY = 'registration_pending_approvals';
|
||||
@@ -362,6 +367,7 @@ type StoredConfigSection =
|
||||
| 'message hover tracking'
|
||||
| 'message keyboard focus'
|
||||
| 'blocked message groups'
|
||||
| 'expression info card'
|
||||
| 'instance policy'
|
||||
| 'integrations'
|
||||
| 'media'
|
||||
@@ -519,6 +525,10 @@ function parseStoredBlockedMessageGroupsConfig(raw: string | null): BlockedMessa
|
||||
return parseStoredConfigOrDefault(BlockedMessageGroupsConfigSchema, raw, 'blocked message groups');
|
||||
}
|
||||
|
||||
function parseStoredExpressionInfoCardConfig(raw: string | null): ExpressionInfoCardConfig {
|
||||
return parseStoredConfigOrDefault(ExpressionInfoCardConfigSchema, raw, 'expression info card');
|
||||
}
|
||||
|
||||
function validateStoredCollection<T>(schema: z.ZodType<T>, value: unknown, section: StoredConfigSection): Array<T> {
|
||||
if (!Array.isArray(value)) {
|
||||
throw new Error(`Stored ${section} configuration must be an array`);
|
||||
@@ -1042,6 +1052,7 @@ export class InstanceConfigRepository {
|
||||
parseStoredMessageHoverTrackingConfig(snapshot.get(MESSAGE_HOVER_TRACKING_CONFIG_KEY) ?? null);
|
||||
parseStoredMessageKeyboardFocusConfig(snapshot.get(MESSAGE_KEYBOARD_FOCUS_CONFIG_KEY) ?? null);
|
||||
parseStoredBlockedMessageGroupsConfig(snapshot.get(BLOCKED_MESSAGE_GROUPS_CONFIG_KEY) ?? null);
|
||||
parseStoredExpressionInfoCardConfig(snapshot.get(EXPRESSION_INFO_CARD_CONFIG_KEY) ?? null);
|
||||
const policy = parseStoredInstancePolicyConfig(snapshot.get(INSTANCE_POLICY_CONFIG_KEY) ?? null);
|
||||
checkStoredConfig('registration', () =>
|
||||
parseStoredRegistrationConfig(snapshot.get(REGISTRATION_CONFIG_KEY) ?? null),
|
||||
@@ -1171,6 +1182,16 @@ export class InstanceConfigRepository {
|
||||
await this.setConfig(BLOCKED_MESSAGE_GROUPS_CONFIG_KEY, JSON.stringify(validated));
|
||||
}
|
||||
|
||||
async getExpressionInfoCardConfig(): Promise<ExpressionInfoCardConfig> {
|
||||
const raw = await this.getConfig(EXPRESSION_INFO_CARD_CONFIG_KEY);
|
||||
return parseStoredExpressionInfoCardConfig(raw);
|
||||
}
|
||||
|
||||
async setExpressionInfoCardConfig(config: ExpressionInfoCardConfig): Promise<void> {
|
||||
const validated = validateStoredConfig(ExpressionInfoCardConfigSchema, config, 'expression info card');
|
||||
await this.setConfig(EXPRESSION_INFO_CARD_CONFIG_KEY, JSON.stringify(validated));
|
||||
}
|
||||
|
||||
async setExperimentDeliveryConfig(config: ExperimentDeliveryConfig): Promise<void> {
|
||||
const validated = validateStoredConfig(ExperimentDeliveryConfigSchema, config, 'experiment delivery');
|
||||
await this.setConfig(EXPERIMENT_DELIVERY_CONFIG_KEY, JSON.stringify(validated));
|
||||
|
||||
Reference in new issue
Block a user