Skip to content

Commit 7487b89

Browse files
chore(config): move more remote config to Statsig (#6474)
### Description This PR moves the following remote config variables to statsig dynamic config: - dapp list url -> app config - dapp in-app webview enabled -> dapps webview config - celo news -> app config - swap price impact warning threshold -> swap config - `maxNumRecentDapps` is no longer used and just removed here ### Test plan n/a ### Related issues - Related to RET-1272 ### Backwards compatibility Y ### Network scalability If a new NetworkId and/or Network are added in the future, the changes in this PR will: - [ ] Continue to work without code changes, OR trigger a compilation error (guaranteeing we find it when a new network is added)
1 parent 411b209 commit 7487b89

28 files changed

+73
-196
lines changed

src/app/reducers.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { BIOMETRY_TYPE } from '@interaxyz/react-native-keychain'
22
import { Platform } from 'react-native'
33
import { Actions, ActionTypes, AppState } from 'src/app/actions'
4-
import { CeloNewsConfig } from 'src/celoNews/types'
54
import { DEEP_LINK_URL_SCHEME } from 'src/config'
65
import { REMOTE_CONFIG_VALUES_DEFAULTS } from 'src/firebase/remoteConfigValuesDefaults'
76
import { Screens } from 'src/navigator/Screens'
@@ -32,7 +31,6 @@ interface State {
3231
fiatConnectCashInEnabled: boolean
3332
fiatConnectCashOutEnabled: boolean
3433
inviterAddress: string | null
35-
celoNews: CeloNewsConfig
3634
hapticFeedbackEnabled: boolean
3735
pushNotificationRequestedUnixTime: number | null
3836
pushNotificationsEnabled: boolean
@@ -65,7 +63,6 @@ const initialState = {
6563
fiatConnectCashInEnabled: REMOTE_CONFIG_VALUES_DEFAULTS.fiatConnectCashInEnabled,
6664
fiatConnectCashOutEnabled: REMOTE_CONFIG_VALUES_DEFAULTS.fiatConnectCashOutEnabled,
6765
inviterAddress: null,
68-
celoNews: JSON.parse(REMOTE_CONFIG_VALUES_DEFAULTS.celoNews),
6966
hapticFeedbackEnabled: true,
7067
pushNotificationRequestedUnixTime: null,
7168
pushNotificationsEnabled: false,
@@ -157,7 +154,6 @@ export const appReducer = (
157154
sentryNetworkErrors: action.configValues.sentryNetworkErrors,
158155
fiatConnectCashInEnabled: action.configValues.fiatConnectCashInEnabled,
159156
fiatConnectCashOutEnabled: action.configValues.fiatConnectCashOutEnabled,
160-
celoNews: action.configValues.celoNews,
161157
}
162158
case Actions.ACTIVE_SCREEN_CHANGED:
163159
return {

src/app/saga.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
inAppReviewLastInteractionTimestampSelector,
3131
sentryNetworkErrorsSelector,
3232
} from 'src/app/selectors'
33-
import { CeloNewsConfig } from 'src/celoNews/types'
3433
import { DEFAULT_APP_LANGUAGE, FETCH_TIMEOUT_DURATION, isE2EEnv } from 'src/config'
3534
import { FiatExchangeFlow } from 'src/fiatExchanges/types'
3635
import { FiatAccountSchemaCountryOverrides } from 'src/fiatconnect/types'
@@ -176,18 +175,13 @@ export function* checkAndroidMobileServicesSaga() {
176175
}
177176

178177
export interface RemoteConfigValues {
179-
dappListApiUrl: string | null
180178
inviteRewardsVersion: string
181179
allowOtaTranslations: boolean
182180
sentryTracesSampleRate: number
183181
sentryNetworkErrors: string[]
184-
maxNumRecentDapps: number
185-
dappsWebViewEnabled: boolean
186182
fiatConnectCashInEnabled: boolean
187183
fiatConnectCashOutEnabled: boolean
188184
fiatAccountSchemaCountryOverrides: FiatAccountSchemaCountryOverrides
189-
celoNews: CeloNewsConfig
190-
priceImpactWarningThreshold: number
191185
}
192186

193187
export function* appRemoteFeatureFlagSaga() {

src/app/selectors.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ export const phoneNumberVerifiedSelector = (state: RootState) => state.app.phone
4545

4646
export const inviterAddressSelector = (state: RootState) => state.app.inviterAddress
4747

48-
export const celoNewsConfigSelector = (state: RootState) => state.app.celoNews
49-
5048
export const hapticFeedbackEnabledSelector = (state: RootState) => state.app.hapticFeedbackEnabled
5149

5250
export const pushNotificationsEnabledSelector = (state: RootState) =>

src/celoNews/CeloNewsFeed.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import { useTranslation } from 'react-i18next'
44
import { FlatList, ListRenderItemInfo, StyleSheet, Text, View } from 'react-native'
55
import AppAnalytics from 'src/analytics/AppAnalytics'
66
import { CeloNewsEvents } from 'src/analytics/Events'
7-
import { celoNewsConfigSelector } from 'src/app/selectors'
87
import CeloNewsFeedItem from 'src/celoNews/CeloNewsFeedItem'
98
import { CeloNewsArticle, CeloNewsArticles } from 'src/celoNews/types'
109
import Button, { BtnSizes, BtnTypes } from 'src/components/Button'
1110
import EmptyView from 'src/components/EmptyView'
1211
import { navigate } from 'src/navigator/NavigationService'
1312
import { Screens } from 'src/navigator/Screens'
14-
import { useSelector } from 'src/redux/hooks'
13+
import { getDynamicConfigParams } from 'src/statsig'
14+
import { DynamicConfigs } from 'src/statsig/constants'
15+
import { StatsigDynamicConfigs } from 'src/statsig/types'
1516
import colors from 'src/styles/colors'
1617
import { typeScale } from 'src/styles/fonts'
1718
import { Spacing } from 'src/styles/styles'
@@ -61,7 +62,8 @@ export default function CeloNewsFeed() {
6162
const { t } = useTranslation()
6263

6364
const asyncArticles = useFetchArticles()
64-
const { readMoreUrl } = useSelector(celoNewsConfigSelector)
65+
const { links } = getDynamicConfigParams(DynamicConfigs[StatsigDynamicConfigs.APP_CONFIG])
66+
const readMoreUrl = links?.celoNews
6567
const isLoading = asyncArticles.status === 'loading'
6668

6769
useEffect(() => {

src/celoNews/types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
export interface CeloNewsConfig {
2-
readMoreUrl?: string
3-
}
41
export interface CeloNewsArticles {
52
articles: CeloNewsArticle[]
63
nextPageId: string

src/dapps/DappsScreen.test.tsx

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const dappsCategories: DappCategory[] = [
3939
]
4040

4141
const defaultStore = createMockStore({
42-
dapps: { dappListApiUrl: 'http://url.com', dappsList, dappsCategories },
42+
dapps: { dappsList, dappsCategories },
4343
})
4444

4545
describe('DappsScreen', () => {
@@ -106,7 +106,6 @@ describe('DappsScreen', () => {
106106
it('opens dapps directly', () => {
107107
const store = createMockStore({
108108
dapps: {
109-
dappListApiUrl: 'http://url.com',
110109
dappsList,
111110
dappsCategories,
112111
},
@@ -130,7 +129,6 @@ describe('DappsScreen', () => {
130129
it('renders error message when fetching dapps fails', () => {
131130
const store = createMockStore({
132131
dapps: {
133-
dappListApiUrl: 'http://url.com',
134132
dappsList: [],
135133
dappsCategories: [],
136134
dappsListError: 'Error fetching dapps',
@@ -152,7 +150,6 @@ describe('DappsScreen', () => {
152150
it('renders correctly when there are no favorite dapps', () => {
153151
const store = createMockStore({
154152
dapps: {
155-
dappListApiUrl: 'http://url.com',
156153
dappsList,
157154
dappsCategories,
158155
favoriteDappIds: [],
@@ -173,7 +170,6 @@ describe('DappsScreen', () => {
173170
it('renders correctly when there are favourited dapps', () => {
174171
const store = createMockStore({
175172
dapps: {
176-
dappListApiUrl: 'http://url.com',
177173
dappsList,
178174
dappsCategories,
179175
favoriteDappIds: ['dapp2'],
@@ -195,7 +191,6 @@ describe('DappsScreen', () => {
195191
it('triggers the events when favoriting', () => {
196192
const store = createMockStore({
197193
dapps: {
198-
dappListApiUrl: 'http://url.com',
199194
dappsList,
200195
dappsCategories,
201196
favoriteDappIds: ['dapp1'],
@@ -230,7 +225,6 @@ describe('DappsScreen', () => {
230225
it('triggers the events when unfavoriting', () => {
231226
const store = createMockStore({
232227
dapps: {
233-
dappListApiUrl: 'http://url.com',
234228
dappsList,
235229
dappsCategories,
236230
favoriteDappIds: ['dapp2'],
@@ -268,7 +262,6 @@ describe('DappsScreen', () => {
268262
it('renders correctly when there are no search results', () => {
269263
const store = createMockStore({
270264
dapps: {
271-
dappListApiUrl: 'http://url.com',
272265
dappsList,
273266
dappsCategories,
274267
favoriteDappIds: [],
@@ -291,7 +284,6 @@ describe('DappsScreen', () => {
291284
it('renders correctly when there are search results in both sections', () => {
292285
const store = createMockStore({
293286
dapps: {
294-
dappListApiUrl: 'http://url.com',
295287
dappsList,
296288
dappsCategories,
297289
favoriteDappIds: ['dapp2'],
@@ -324,7 +316,6 @@ describe('DappsScreen', () => {
324316
it('clearing search input should show all dapps', () => {
325317
const store = createMockStore({
326318
dapps: {
327-
dappListApiUrl: 'http://url.com',
328319
dappsList,
329320
dappsCategories,
330321
favoriteDappIds: ['dapp2'],
@@ -360,7 +351,6 @@ describe('DappsScreen', () => {
360351
it('renders correctly when there are no filters applied', () => {
361352
const store = createMockStore({
362353
dapps: {
363-
dappListApiUrl: 'http://url.com',
364354
dappsList,
365355
dappsCategories,
366356
favoriteDappIds: ['dapp1'],
@@ -391,7 +381,6 @@ describe('DappsScreen', () => {
391381
it('renders correctly when there are filters applied', () => {
392382
const store = createMockStore({
393383
dapps: {
394-
dappListApiUrl: 'http://url.com',
395384
dappsList,
396385
dappsCategories,
397386
favoriteDappIds: ['dapp1'],
@@ -425,7 +414,6 @@ describe('DappsScreen', () => {
425414
it('triggers event when filtering', () => {
426415
const store = createMockStore({
427416
dapps: {
428-
dappListApiUrl: 'http://url.com',
429417
dappsList,
430418
dappsCategories,
431419
favoriteDappIds: ['dapp1'],
@@ -453,7 +441,6 @@ describe('DappsScreen', () => {
453441
it('triggers events when toggling a category filter', () => {
454442
const store = createMockStore({
455443
dapps: {
456-
dappListApiUrl: 'http://url.com',
457444
dappsList,
458445
dappsCategories,
459446
favoriteDappIds: ['dapp1'],
@@ -488,7 +475,6 @@ describe('DappsScreen', () => {
488475
it('triggers event when clearing filters from category section', () => {
489476
const store = createMockStore({
490477
dapps: {
491-
dappListApiUrl: 'http://url.com',
492478
dappsList,
493479
dappsCategories,
494480
favoriteDappIds: ['dapp2'],
@@ -524,7 +510,6 @@ describe('DappsScreen', () => {
524510
it('triggers event when clearing filters from favorite section', () => {
525511
const store = createMockStore({
526512
dapps: {
527-
dappListApiUrl: 'http://url.com',
528513
dappsList,
529514
dappsCategories,
530515
favoriteDappIds: ['dapp1'],
@@ -559,7 +544,6 @@ describe('DappsScreen', () => {
559544
it('renders correctly when there are results in all and favorites sections', () => {
560545
const store = createMockStore({
561546
dapps: {
562-
dappListApiUrl: 'http://url.com',
563547
dappsList,
564548
dappsCategories,
565549
favoriteDappIds: ['dapp1'],
@@ -588,7 +572,6 @@ describe('DappsScreen', () => {
588572
it('renders correctly when there are results in favorites and no results in all', () => {
589573
const store = createMockStore({
590574
dapps: {
591-
dappListApiUrl: 'http://url.com',
592575
dappsList,
593576
dappsCategories,
594577
favoriteDappIds: ['dapp1'],
@@ -619,7 +602,6 @@ describe('DappsScreen', () => {
619602
it('renders correctly when there are no results in favorites and results in all', () => {
620603
const store = createMockStore({
621604
dapps: {
622-
dappListApiUrl: 'http://url.com',
623605
dappsList,
624606
dappsCategories,
625607
favoriteDappIds: ['dapp2'],
@@ -651,7 +633,6 @@ describe('DappsScreen', () => {
651633

652634
describe('dapp open analytics event properties', () => {
653635
const defaultStoreProps = {
654-
dappListApiUrl: 'http://url.com',
655636
dappsList,
656637
dappsCategories,
657638
favoriteDappIds: [],

src/dapps/saga.test.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@ import { expectSaga } from 'redux-saga-test-plan'
33
import { select } from 'redux-saga/effects'
44
import { DEEP_LINK_URL_SCHEME } from 'src/config'
55
import { handleFetchDappsList, handleOpenDapp } from 'src/dapps/saga'
6-
import { dappsListApiUrlSelector, dappsWebViewEnabledSelector } from 'src/dapps/selectors'
76
import { dappSelected, fetchDappsListCompleted, fetchDappsListFailed } from 'src/dapps/slice'
87
import { Dapp, DappSection } from 'src/dapps/types'
98
import { currentLanguageSelector } from 'src/i18n/selectors'
109
import { navigate } from 'src/navigator/NavigationService'
1110
import { Screens } from 'src/navigator/Screens'
12-
import { getExperimentParams } from 'src/statsig'
11+
import { getDynamicConfigParams, getExperimentParams } from 'src/statsig'
1312
import { walletAddressSelector } from 'src/web3/selectors'
1413
import { mockAccount } from 'test/values'
1514

1615
jest.mock('src/statsig')
16+
jest.mocked(getDynamicConfigParams).mockReturnValue({
17+
inAppWebviewEnabled: true,
18+
links: {
19+
dappList: 'http://some.url',
20+
},
21+
})
1722

1823
describe('Dapps saga', () => {
1924
describe('Handles opening a dapp', () => {
@@ -30,9 +35,7 @@ describe('Dapps saga', () => {
3035
await expectSaga(
3136
handleOpenDapp,
3237
dappSelected({ dapp: { ...baseDapp, openedFrom: DappSection.All } })
33-
)
34-
.provide([[select(dappsWebViewEnabledSelector), true]])
35-
.run()
38+
).run()
3639

3740
expect(navigate).toHaveBeenCalledWith(Screens.WebViewScreen, {
3841
uri: baseDapp.dappUrl,
@@ -50,10 +53,7 @@ describe('Dapps saga', () => {
5053
},
5154
})
5255
)
53-
.provide([
54-
[select(dappsWebViewEnabledSelector), true],
55-
[select(walletAddressSelector), mockAccount],
56-
])
56+
.provide([[select(walletAddressSelector), mockAccount]])
5757
.run()
5858

5959
expect(navigate).toHaveBeenCalledWith(Screens.BidaliScreen, { currency: undefined })
@@ -68,10 +68,7 @@ describe('Dapps saga', () => {
6868

6969
it('does not fetch the dapps list if the wallet is not yet initialized', async () => {
7070
await expectSaga(handleFetchDappsList)
71-
.provide([
72-
[select(dappsListApiUrlSelector), 'http://some.url'],
73-
[select(walletAddressSelector), null],
74-
])
71+
.provide([[select(walletAddressSelector), null]])
7572
.run()
7673

7774
expect(mockFetch).not.toHaveBeenCalled()
@@ -123,7 +120,6 @@ describe('Dapps saga', () => {
123120

124121
await expectSaga(handleFetchDappsList)
125122
.provide([
126-
[select(dappsListApiUrlSelector), 'http://some.url'],
127123
[select(walletAddressSelector), '0xabc'],
128124
[select(currentLanguageSelector), 'en'],
129125
])
@@ -171,7 +167,6 @@ describe('Dapps saga', () => {
171167

172168
await expectSaga(handleFetchDappsList)
173169
.provide([
174-
[select(dappsListApiUrlSelector), 'http://some.url'],
175170
[select(walletAddressSelector), '0xabc'],
176171
[select(currentLanguageSelector), 'en'],
177172
])

src/dapps/saga.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { PayloadAction } from '@reduxjs/toolkit'
22
import { openDeepLink, openUrl } from 'src/app/actions'
33
import { handleDeepLink, handleOpenUrl } from 'src/app/saga'
4-
import { dappsListApiUrlSelector, dappsWebViewEnabledSelector } from 'src/dapps/selectors'
54
import {
65
dappSelected,
76
DappSelectedAction,
@@ -14,6 +13,9 @@ import { currentLanguageSelector } from 'src/i18n/selectors'
1413
import { setLanguage } from 'src/i18n/slice'
1514
import { navigate } from 'src/navigator/NavigationService'
1615
import { Screens } from 'src/navigator/Screens'
16+
import { getDynamicConfigParams } from 'src/statsig'
17+
import { DynamicConfigs } from 'src/statsig/constants'
18+
import { StatsigDynamicConfigs } from 'src/statsig/types'
1719
import { isDeepLink } from 'src/utils/linking'
1820
import Logger from 'src/utils/Logger'
1921
import { safely } from 'src/utils/safely'
@@ -36,7 +38,9 @@ interface Application {
3638

3739
export function* handleOpenDapp(action: PayloadAction<DappSelectedAction>) {
3840
const { dappUrl } = action.payload.dapp
39-
const dappsWebViewEnabled = yield* select(dappsWebViewEnabledSelector)
41+
const dappsWebViewEnabled = getDynamicConfigParams(
42+
DynamicConfigs[StatsigDynamicConfigs.DAPP_WEBVIEW_CONFIG]
43+
).inAppWebviewEnabled
4044

4145
if (dappsWebViewEnabled) {
4246
const walletConnectEnabled: boolean = yield* call(isWalletConnectEnabled, dappUrl)
@@ -51,7 +55,8 @@ export function* handleOpenDapp(action: PayloadAction<DappSelectedAction>) {
5155
}
5256

5357
export function* handleFetchDappsList() {
54-
const dappsListApiUrl = yield* select(dappsListApiUrlSelector)
58+
const { links } = getDynamicConfigParams(DynamicConfigs[StatsigDynamicConfigs.APP_CONFIG])
59+
const dappsListApiUrl = links.dappList
5560
if (!dappsListApiUrl) {
5661
Logger.warn(TAG, 'dappsListApiUrl not found, skipping dapps list fetch')
5762
return

src/dapps/selectors.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ function getDappsById(dapps: Dapp[], dappIds: string[]) {
1717
return matchingDapps
1818
}
1919

20-
export const dappsListApiUrlSelector = (state: RootState) => state.dapps.dappListApiUrl
21-
22-
export const activeDappSelector = (state: RootState) =>
23-
state.dapps.dappsWebViewEnabled ? state.dapps.activeDapp : null
24-
25-
export const dappsWebViewEnabledSelector = (state: RootState) => state.dapps.dappsWebViewEnabled
20+
export const activeDappSelector = (state: RootState) => state.dapps.activeDapp
2621

2722
export const dappsCategoriesSelector = (state: RootState) => state.dapps.dappsCategories
2823

0 commit comments

Comments
 (0)