feat(app): gate the expression info card behind an experiment (#2773)

This commit is contained in:
Hampus authored and GitHub committed 2026-09-14 20:14:58 +02:00
1 parent 7c9274847f
commit 6339c3b8ad
110 files changed
+12827 -5191

No files matched your search

@@ -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));