Skip to content

Commit

Permalink
Merge pull request #6396 from blockchain/chore/dynamic-routing
Browse files Browse the repository at this point in the history
chore(dynamic-routing): remove dynamic routing and only use threshold
  • Loading branch information
jjBlockchain authored Jul 1, 2024
2 parents 19e2828 + 35acd0c commit 43c290e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 28 deletions.
1 change: 0 additions & 1 deletion packages/blockchain-wallet-v4-frontend/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
window.SARDINE_CLIENT_ID = '**SARDINE_CLIENT_ID**'
window.SARDINE_ENVIRONMENT = '**SARDINE_ENVIRONMENT**'
window.WALLET_V5_LINK = '**WALLET_V5_LINK**'
window.DYNAMIC_ROUTING_WALLET_V5 = '**DYNAMIC_ROUTING_WALLET_V5**'
window.nonce = '**CSP_NONCE**'
</script>
<script nonce="**CSP_NONCE**">
Expand Down
31 changes: 12 additions & 19 deletions packages/blockchain-wallet-v4-frontend/src/scenes/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,19 @@ const App = ({
const [isDynamicRoutingInProgress, setDynamicRoutingState] = useState<boolean>(true)

useEffect(() => {
if (window?.DYNAMIC_ROUTING_WALLET_V5 !== 'true') {
// OBTAIN THE THRESHOLD - STATICALLY SET, DECIDED BY TEAM.
const THRESHOLD = 5

// GET REFERENCE TO BROWSER COOKIES
const cookies = new Cookies()

// THE DYNAMIC ROUTING IS DISABLED, SEND TO V4
// @ts-ignore
// eslint-disable-next-line
if (THRESHOLD === 0) {
cookies.set('wallet_v5_ui_available', 'false', { domain: '.blockchain.com', path: '/' })
// eslint-disable-next-line
console.log('Setting state to false')
console.log('[ROUTING_DEBUG]: Threshold was not set, assuming v5 is disabled.')
setDynamicRoutingState(false)
return
}
Expand All @@ -124,9 +134,6 @@ const App = ({
const pathSegments = fullPath.split('/').filter(Boolean)
const firstSegment = pathSegments[0]?.toLowerCase()

// GET REFERENCE TO BROWSER COOKIES
const cookies = new Cookies()

// IF LANGUAGE EXISTS, REMOVE IT FROM THE PATH, NOT NEEDED FOR DYNAMIC ROUTING.
if (languages.some((lang) => lang.language.toLowerCase() === firstSegment)) {
// UPDATE LANGUAGE COOKIE SO THAT V5 LOADS THE CORRECT LANGUAGE
Expand Down Expand Up @@ -169,20 +176,6 @@ const App = ({
cookies.set('canary_position', `${canaryPosition}`, { domain: '.blockchain.com', path: '/' })
}

// OBTAIN THE THRESHOLD - STATICALLY SET, DECIDED BY TEAM.
const THRESHOLD = 5

// THE DYNAMIC ROUTING IS DISABLED, SEND TO V4
// @ts-ignore
// eslint-disable-next-line
if (THRESHOLD === 0) {
cookies.set('wallet_v5_ui_available', 'false', { domain: '.blockchain.com', path: '/' })
// eslint-disable-next-line
console.log('[ROUTING_DEBUG]: Threshold was not set, assuming v5 is disabled.')
setDynamicRoutingState(false)
return
}

// IF THE USER HAS REQUESTED TO STAY IN V4.
const reversionRequested = cookies.get('opt_out_wallet_v5_ui') === 'true'
const availableUI = canaryPosition <= THRESHOLD
Expand Down
7 changes: 0 additions & 7 deletions packages/blockchain-wallet-v4-frontend/webpackBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,6 @@ const buildWebpackConfig = (envConfig, extraPluginsList) => ({
? process.env.WALLET_V5_LINK
: 'https://google.com'
},
{
pattern: '**DYNAMIC_ROUTING_WALLET_V5**',
// Note: using an obvious redirection issue
replacement: process.env.DYNAMIC_ROUTING_WALLET_V5
? process.env.DYNAMIC_ROUTING_WALLET_V5
: envConfig.DYNAMIC_ROUTING_WALLET_V5
},
{
pattern: '**APP_VERSION**',
replacement: require(CONFIG_PATH.pkgJson).version
Expand Down
1 change: 0 additions & 1 deletion typings/window.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ declare global {
_Sardine: any // Sardine integration
_SardineContext: any // Sardine integration
WALLET_V5_LINK: string
DYNAMIC_ROUTING_WALLET_V5: string
coins: Coins
grecaptcha: any // google recaptcha sets this on window
history?: {
Expand Down

0 comments on commit 43c290e

Please sign in to comment.