diff --git a/suite-common/message-system/config/config.v1.json b/suite-common/message-system/config/config.v1.json index edba3a9fb37..37c8dd7981d 100644 --- a/suite-common/message-system/config/config.v1.json +++ b/suite-common/message-system/config/config.v1.json @@ -1,7 +1,7 @@ { "version": 1, "timestamp": "2024-01-03T00:00:00+00:00", - "sequence": 74, + "sequence": 75, "actions": [ { "conditions": [ @@ -1255,5 +1255,79 @@ ] } } + ], + "experiments": [ + { + "conditions": [ + { + "settings": [ + { + "eth": true + } + ] + } + ], + "experiment": { + "id": "cb31d5e2-7c18-4b3e-a605-66df7bb8ae05", + "groups": [ + { + "variant": "Base", + "percentage": 45 + }, + { + "variant": "Custom", + "percentage": 55 + } + ] + } + }, + { + "conditions": [ + { + "settings": [ + { + "pol": true + } + ] + } + ], + "experiment": { + "id": "cb31d5e2-7c18-4b3e-a605-66df7bb8ae06", + "groups": [ + { + "variant": "Base", + "percentage": 45 + }, + { + "variant": "Custom", + "percentage": 55 + } + ] + } + }, + { + "conditions": [ + { + "settings": [ + { + "bsc": true + } + ] + } + ], + "experiment": { + "id": "8872d5d5-bc06-4f2c-84d3-f2f27d0e817b", + "groups": [ + { + "variant": "Base", + "percentage": 45 + }, + { + "variant": "Custom", + "percentage": 55 + } + ] + } + } ] } diff --git a/suite-common/message-system/src/experimentUtils.ts b/suite-common/message-system/src/experimentUtils.ts index 38844266ecf..fdaffeeb208 100644 --- a/suite-common/message-system/src/experimentUtils.ts +++ b/suite-common/message-system/src/experimentUtils.ts @@ -61,5 +61,5 @@ export const selectActiveExperimentGroup = ({ inclusion: inclusionFromInstanceId, }); - return experimentRange; + return experimentRange ? { ...experimentRange, inclusion: inclusionFromInstanceId } : undefined; }; diff --git a/suite-common/message-system/src/messageSystemTypes.ts b/suite-common/message-system/src/messageSystemTypes.ts index 6e0cb158d3f..b913909ad9d 100644 --- a/suite-common/message-system/src/messageSystemTypes.ts +++ b/suite-common/message-system/src/messageSystemTypes.ts @@ -40,6 +40,9 @@ export type ContextDomain = (typeof Context)[keyof typeof Context]; export const Experiment = { // e.g. orangeSendButton: 'fb0eb1bc-8ec3-44d4-98eb-53301d73d981', + hellowEthWorld: 'cb31d5e2-7c18-4b3e-a605-66df7bb8ae05', + hellowPolWorld: 'cb31d5e2-7c18-4b3e-a605-66df7bb8ae06', + hellowBNBWorld: '8872d5d5-bc06-4f2c-84d3-f2f27d0e817b', } as const; export type ExperimentId = (typeof Experiment)[keyof typeof Experiment]; diff --git a/suite-native/module-settings/package.json b/suite-native/module-settings/package.json index 16d3034a7a0..531fe1b2c65 100644 --- a/suite-native/module-settings/package.json +++ b/suite-native/module-settings/package.json @@ -17,6 +17,7 @@ "@react-navigation/native-stack": "6.11.0", "@reduxjs/toolkit": "1.9.5", "@suite-common/analytics": "workspace:*", + "@suite-common/message-system": "workspace:*", "@suite-common/suite-config": "workspace:*", "@suite-common/suite-constants": "workspace:*", "@suite-common/suite-types": "workspace:*", diff --git a/suite-native/module-settings/src/components/PreferencesSettings.tsx b/suite-native/module-settings/src/components/PreferencesSettings.tsx index 533a1e18cff..148c5c31188 100644 --- a/suite-native/module-settings/src/components/PreferencesSettings.tsx +++ b/suite-native/module-settings/src/components/PreferencesSettings.tsx @@ -1,17 +1,70 @@ import { Translation } from '@suite-native/intl'; import { SettingsStackRoutes } from '@suite-native/navigation'; import { SettingsSection, SettingsSectionItem } from '@suite-native/settings'; +import { useExperiment, Experiment } from '@suite-common/message-system'; import { useSettingsNavigateTo } from '../navigation/useSettingsNavigateTo'; +const getSectionTitle = (activeExperimentVariant?: { + variant: string; + [k: string]: unknown; + percentage: number; +}) => { + switch (activeExperimentVariant?.variant) { + case 'Base': + return `Čau Štěpáne ${activeExperimentVariant.inclusion}%`; + case 'Custom': + return `Čau Stew ${activeExperimentVariant.inclusion}%`; + default: + return ; + } +}; + +const getItemTitle = (activeExperimentVariant?: { + variant: string; + [k: string]: unknown; + percentage: number; +}) => { + switch (activeExperimentVariant?.variant) { + case 'Base': + return `POL base ${activeExperimentVariant.inclusion}%`; + case 'Custom': + return `POL custom ${activeExperimentVariant.inclusion}%`; + default: + return ; + } +}; + +const getNextItemTitle = (activeExperimentVariant?: { + variant: string; + [k: string]: unknown; + percentage: number; +}) => { + switch (activeExperimentVariant?.variant) { + case 'Base': + return `BNB base ${activeExperimentVariant.inclusion}%`; + case 'Custom': + return `BNB custom ${activeExperimentVariant.inclusion}%`; + default: + return ; + } +}; + export const PreferencesSettings = () => { const navigateTo = useSettingsNavigateTo(); + const { activeExperimentVariant } = useExperiment(Experiment.hellowEthWorld); + const { activeExperimentVariant: activeExperimentVarianPol } = useExperiment( + Experiment.hellowPolWorld, + ); + const { activeExperimentVariant: activeExperimentVarianBNB } = useExperiment( + Experiment.hellowBNBWorld, + ); return ( - }> + } + title={getItemTitle(activeExperimentVarianPol)} subtitle={ } @@ -20,7 +73,7 @@ export const PreferencesSettings = () => { /> } + title={getNextItemTitle(activeExperimentVarianBNB)} subtitle={ } diff --git a/suite-native/module-settings/tsconfig.json b/suite-native/module-settings/tsconfig.json index dafd603defa..951a1cec738 100644 --- a/suite-native/module-settings/tsconfig.json +++ b/suite-native/module-settings/tsconfig.json @@ -5,6 +5,9 @@ { "path": "../../suite-common/analytics" }, + { + "path": "../../suite-common/message-system" + }, { "path": "../../suite-common/suite-config" }, diff --git a/yarn.lock b/yarn.lock index 0c45757b052..b13cb034075 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10881,6 +10881,7 @@ __metadata: "@react-navigation/native-stack": "npm:6.11.0" "@reduxjs/toolkit": "npm:1.9.5" "@suite-common/analytics": "workspace:*" + "@suite-common/message-system": "workspace:*" "@suite-common/suite-config": "workspace:*" "@suite-common/suite-constants": "workspace:*" "@suite-common/suite-types": "workspace:*"