import queryString from 'query-string' ; import { computed , observable } from 'mobx' ; export type Variant = 'a' | 'b' ; export type Logging = 'console' | 'firebase' | 'sheets' ; export class FeatureFlags { @ observable id = 'cococo' ; @ observable readonly variant : Variant = 'a' ; @ computed get baseline ( ) { return this . variant === 'b' ; } @ observable readonly logging : Logging = 'console' ; @ computed get firebaseLogging ( ) { return this . logging === 'firebase' ; } @ computed get sheetsLogging ( ) { return this . logging === 'sheets' ; } constructor ( ) { const parsed = queryString . parse ( window . location . search ) ; const { variant , logging , id } = parsed ; if ( variant === 'b' ) { this . variant = variant ; } if ( logging === 'firebase' || logging === 'sheets' ) { this . logging = logging ; } if ( id ) { this . id = `${ id }` ; } } } export default new FeatureFlags ( ) ;