Skip to content

Commit dc5e785

Browse files
tom2drumisstuev
authored andcommitted
Mobile. A/B test: txs/token transfers table view (address details page) (#3241)
* Mobile. A/B test: txs/token transfers table view (address details page) Resolves #3230 * fixes and test * [skip ci] change mixpanel event
1 parent 07f7f6b commit dc5e785

16 files changed

+147
-13
lines changed

icons/list_view.svg

Lines changed: 7 additions & 0 deletions
Loading

lib/cookies.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export enum NAMES {
2626
UUID = 'uuid',
2727
SHOW_SCAM_TOKENS = 'show_scam_tokens',
2828
APP_PROFILE = 'app_profile',
29+
TABLE_VIEW_ON_MOBILE = 'table_view_on_mobile',
2930
}
3031

3132
/**

lib/growthbook/init.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { STORAGE_KEY, STORAGE_LIMIT } from './consts';
77

88
export interface GrowthBookFeatures {
99
test_value: string;
10+
txns_view_exp: 'table_view' | 'list_view';
1011
}
1112

1213
export const initGrowthBook = (uuid: string) => {

lib/hooks/useTableViewValue.tsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import React from 'react';
2+
3+
import * as cookies from 'lib/cookies';
4+
import useFeatureValue from 'lib/growthbook/useFeatureValue';
5+
import * as mixpanel from 'lib/mixpanel';
6+
7+
export default function useTableViewValue() {
8+
const cookieValue = cookies.get(cookies.NAMES.TABLE_VIEW_ON_MOBILE);
9+
const [ value, setValue ] = React.useState<boolean | undefined>(cookieValue ? cookieValue === 'true' : undefined);
10+
const { value: featureFlag, isLoading: isFeatureLoading } = useFeatureValue('txns_view_exp', 'list_view');
11+
12+
const onToggle = React.useCallback(() => {
13+
setValue((prev) => {
14+
const nextValue = !prev;
15+
cookies.set(cookies.NAMES.TABLE_VIEW_ON_MOBILE, nextValue ? 'true' : 'false');
16+
mixpanel.logEvent(mixpanel.EventTypes.PAGE_WIDGET, {
17+
Type: 'Txn view switch',
18+
Info: nextValue ? 'Table view' : 'List view',
19+
Source: 'Address page',
20+
});
21+
return nextValue;
22+
});
23+
}, []);
24+
25+
React.useEffect(() => {
26+
if (!isFeatureLoading) {
27+
setValue((prev) => {
28+
if (prev === undefined) {
29+
return featureFlag === 'table_view';
30+
}
31+
return prev;
32+
});
33+
}
34+
}, [ featureFlag, isFeatureLoading ]);
35+
36+
return React.useMemo(() => {
37+
if (value !== undefined) {
38+
return {
39+
value,
40+
isLoading: false,
41+
onToggle,
42+
};
43+
}
44+
45+
return { value: featureFlag === 'table_view', isLoading: isFeatureLoading, onToggle };
46+
}, [ featureFlag, isFeatureLoading, onToggle, value ]);
47+
}

lib/mixpanel/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ Type extends EventTypes.PAGE_WIDGET ? (
147147
Type: 'Chain switch';
148148
Info: string;
149149
Source: 'Revoke essential dapp';
150+
} | {
151+
Type: 'Txn view switch';
152+
Info: 'Table view' | 'List view';
153+
Source: 'Address page';
150154
}
151155
) :
152156
Type extends EventTypes.TX_INTERPRETATION_INTERACTION ? {

public/icons/name.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
| "lightning"
8686
| "link_external"
8787
| "link"
88+
| "list_view"
8889
| "lock"
8990
| "merits_colored"
9091
| "merits_with_dot"

ui/address/AddressTxs.pw.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ test.describe('base view', () => {
5858
});
5959
});
6060

61-
test.describe('base view', () => {
61+
test.describe('mobile', () => {
6262
test.use({ viewport: pwConfig.viewport.mobile });
6363

64-
test('mobile', async({ render, mockApiResponse }) => {
64+
test.beforeEach(async({ mockApiResponse }) => {
6565
await mockApiResponse(
6666
'general:address_txs',
6767
{
@@ -73,6 +73,20 @@ test.describe('base view', () => {
7373
},
7474
{ pathParams: { hash: CURRENT_ADDRESS } },
7575
);
76+
});
77+
78+
test('base view', async({ render }) => {
79+
const component = await render(
80+
<Box pt={{ base: '134px', lg: 6 }}>
81+
<AddressTxs/>
82+
</Box>,
83+
{ hooksConfig },
84+
);
85+
await expect(component).toHaveScreenshot();
86+
});
87+
88+
test('table view', async({ render, mockFeatures }) => {
89+
await mockFeatures([ [ 'txns_view_exp', 'table_view' ] ]);
7690
const component = await render(
7791
<Box pt={{ base: '134px', lg: 6 }}>
7892
<AddressTxs/>

ui/address/AddressTxs.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const AddressTxs = ({ shouldRender = true, isQueryEnabled = true }: Props) => {
6969
top={ ACTION_BAR_HEIGHT_DESKTOP }
7070
sorting={ sort }
7171
setSort={ setSort }
72+
showTableViewButton
7273
/>
7374
</>
7475
);
56.4 KB
Loading
21.2 KB
Loading

0 commit comments

Comments
 (0)