Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(message-system): DO NOT MERGE demonstration of AB test on mobile for testing purposes only #16661

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 75 additions & 1 deletion suite-common/message-system/config/config.v1.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"timestamp": "2024-01-03T00:00:00+00:00",
"sequence": 74,
"sequence": 75,
"actions": [
{
"conditions": [
Expand Down Expand Up @@ -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
}
]
}
}
]
}
2 changes: 1 addition & 1 deletion suite-common/message-system/src/experimentUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ export const selectActiveExperimentGroup = ({
inclusion: inclusionFromInstanceId,
});

return experimentRange;
return experimentRange ? { ...experimentRange, inclusion: inclusionFromInstanceId } : undefined;
};
3 changes: 3 additions & 0 deletions suite-common/message-system/src/messageSystemTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions suite-native/module-settings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <Translation id="moduleSettings.items.preferences.title" />;
}
};

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 <Translation id="moduleSettings.items.preferences.localization.title" />;
}
};

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 <Translation id="moduleSettings.items.preferences.customization.title" />;
}
};

export const PreferencesSettings = () => {
const navigateTo = useSettingsNavigateTo();
const { activeExperimentVariant } = useExperiment(Experiment.hellowEthWorld);
const { activeExperimentVariant: activeExperimentVarianPol } = useExperiment(
Experiment.hellowPolWorld,
);
const { activeExperimentVariant: activeExperimentVarianBNB } = useExperiment(
Experiment.hellowBNBWorld,
);

return (
<SettingsSection title={<Translation id="moduleSettings.items.preferences.title" />}>
<SettingsSection title={getSectionTitle(activeExperimentVariant)}>
<SettingsSectionItem
iconName="flag"
title={<Translation id="moduleSettings.items.preferences.localization.title" />}
title={getItemTitle(activeExperimentVarianPol)}
subtitle={
<Translation id="moduleSettings.items.preferences.localization.subtitle" />
}
Expand All @@ -20,7 +73,7 @@ export const PreferencesSettings = () => {
/>
<SettingsSectionItem
iconName="palette"
title={<Translation id="moduleSettings.items.preferences.customization.title" />}
title={getNextItemTitle(activeExperimentVarianBNB)}
subtitle={
<Translation id="moduleSettings.items.preferences.customization.subtitle" />
}
Expand Down
3 changes: 3 additions & 0 deletions suite-native/module-settings/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
{
"path": "../../suite-common/analytics"
},
{
"path": "../../suite-common/message-system"
},
{
"path": "../../suite-common/suite-config"
},
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:*"
Expand Down
Loading