This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fasih/DPROD-3590/integrate firebase feature flag for third party items (
#7149) * feat: implement json which contain items name * feat: adding flag on third party packages * feat: implemented flag on trade platfrom apps * feat: removed unsued code * feat: made some items value false * feat: enabled all items * feat: add condition for derivgo footer badge * feat: updated keys * feat: interated api and hook * feat: updated hook with importing function * feat: updated hook and filtered footer icon data * feat: remvoed hotjar and gtm from flags * feat: removed unused code * feat: made every item true * feat: updated other layout files * feat: updated the condition --------- Co-authored-by: fasihali-deriv <[email protected]> Co-authored-by: Muhammad Fasih Ali Naqvi <[email protected]>
- Loading branch information
1 parent
e87e9fe
commit 7c6f41d
Showing
21 changed files
with
488 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { useState, useEffect } from 'react' | ||
import { initializeApp } from 'firebase/app' | ||
import { getDatabase, ref, onValue } from 'firebase/database' | ||
// import useRegion from 'components/hooks/use-region' | ||
import featuresConfig from '../../../static/appConfig' | ||
|
||
const thirdPartyFlagsConfig = { | ||
databaseURL: 'https://app-config-staging.firebaseio.com', | ||
} | ||
|
||
const useThirdPartyFlags = (featurePath) => { | ||
const [data, setData] = useState(featuresConfig) | ||
const [feature, setFeature] = useState(null) | ||
|
||
useEffect(() => { | ||
const app = initializeApp(thirdPartyFlagsConfig, 'thirdPartyFlagsConfig') | ||
const db = getDatabase(app) | ||
|
||
// let fetchedData = featuresConfig | ||
const starCountRef = ref(db, 'remote_config/deriv-com') | ||
const flagsData = onValue( | ||
starCountRef, | ||
(snapshot) => { | ||
setData(snapshot.val()) | ||
}, | ||
(error) => { | ||
console.error(error) | ||
}, | ||
) | ||
return flagsData | ||
}, []) | ||
|
||
useEffect(() => { | ||
const pathParts = featurePath.split('.') | ||
let currentFeature = data | ||
|
||
for (const part of pathParts) { | ||
if (currentFeature[part] === undefined) { | ||
return // Feature path does not exist | ||
} | ||
currentFeature = currentFeature[part] | ||
} | ||
if (typeof currentFeature === 'object') { | ||
setFeature(currentFeature) | ||
} else { | ||
setFeature(Boolean(currentFeature)) | ||
} | ||
}, [data, featurePath]) | ||
|
||
return feature | ||
} | ||
|
||
export default useThirdPartyFlags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.