feat(premium): add the Plutonium page behind an experiment (#3097)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-01 21:45:44 +02:00
1 parent 9a074adb11
commit be69333eaf
118 files changed
+18252 -2368

No files matched your search

@@ -51,6 +51,10 @@ import {
type StoredBillingConfig,
StoredBillingConfigSchema,
} from '@fluxer/schema/src/domains/admin/InstanceBillingSchemas';
import {
type PlutoniumPageConfig,
PlutoniumPageConfigSchema,
} from '@fluxer/schema/src/domains/admin/PlutoniumPageSchemas';
import {
type LegacyPushServiceDeliveryWire,
type PushRelayConfig,
@@ -78,6 +82,7 @@ import {z} from 'zod';
const GATEWAY_ROLLOUT_CONFIG_KEY = 'gateway_rollout_config';
const PUSH_RELAY_CONFIG_KEY = 'push_service_delivery_config';
const DOMAIN_MIGRATION_CONFIG_KEY = 'domain_migration_config';
const PLUTONIUM_PAGE_CONFIG_KEY = 'plutonium_page_config';
const CAPTCHA_CONFIG_KEY = 'captcha_config';
const EXPERIMENT_DELIVERY_CONFIG_KEY = 'experiment_delivery_config';
const REGISTRATION_CONFIG_KEY = 'registration_config';
@@ -407,6 +412,7 @@ type StoredConfigSection =
| 'gateway rollout'
| 'push relay'
| 'domain migration'
| 'plutonium page'
| 'captcha'
| 'experiment delivery'
| 'instance policy'
@@ -568,6 +574,10 @@ function parseStoredDomainMigrationConfig(raw: string | null): DomainMigrationCo
return parseStoredConfigOrDefault(DomainMigrationConfigSchema, raw, 'domain migration');
}
function parseStoredPlutoniumPageConfig(raw: string | null): PlutoniumPageConfig {
return parseStoredConfigOrDefault(PlutoniumPageConfigSchema, raw, 'plutonium page');
}
function parseStoredCaptchaConfig(raw: string | null): CaptchaConfig {
return parseStoredConfigOrDefault(CaptchaConfigSchema, raw, 'captcha');
}
@@ -1234,6 +1244,7 @@ export class InstanceConfigRepository {
);
parseStoredPushRelayConfig(snapshot.get(PUSH_RELAY_CONFIG_KEY) ?? null);
parseStoredDomainMigrationConfig(snapshot.get(DOMAIN_MIGRATION_CONFIG_KEY) ?? null);
parseStoredPlutoniumPageConfig(snapshot.get(PLUTONIUM_PAGE_CONFIG_KEY) ?? null);
parseStoredCaptchaConfig(snapshot.get(CAPTCHA_CONFIG_KEY) ?? null);
parseStoredExperimentDeliveryConfig(snapshot.get(EXPERIMENT_DELIVERY_CONFIG_KEY) ?? null);
parseStoredInstancePolicyConfig(snapshot.get(INSTANCE_POLICY_CONFIG_KEY) ?? null);
@@ -1348,6 +1359,23 @@ export class InstanceConfigRepository {
);
}
async getPlutoniumPageConfig(): Promise<PlutoniumPageConfig> {
const raw = await this.getConfig(PLUTONIUM_PAGE_CONFIG_KEY);
return parseStoredPlutoniumPageConfig(raw);
}
async setPlutoniumPageConfig(config: PlutoniumPageConfig): Promise<void> {
await this.updatePlutoniumPageConfig(() => config);
}
updatePlutoniumPageConfig(
update: (current: PlutoniumPageConfig) => PlutoniumPageConfig,
): Promise<PlutoniumPageConfig> {
return this.updateStoredConfig(PLUTONIUM_PAGE_CONFIG_KEY, (raw) =>
validateStoredConfig(PlutoniumPageConfigSchema, update(parseStoredPlutoniumPageConfig(raw)), 'plutonium page'),
);
}
async getCaptchaConfig(): Promise<CaptchaConfig> {
const raw = await this.getConfig(CAPTCHA_CONFIG_KEY);
return parseStoredCaptchaConfig(raw);