-
Notifications
You must be signed in to change notification settings - Fork 61
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
feat: add remote toggle for livechat and whatsapp #833
Merged
ahmadtaimoor-deriv
merged 9 commits into
deriv-com:master
from
henry-deriv:henry/livechat-feature-toggle
Nov 1, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a6d6ddc
feat: add remote toggle
henry-deriv a827d5e
empty commit
henry-deriv ca13a22
empty commit
henry-deriv 9940aac
Merge branch 'master' of github.com:deriv-com/smarttrader into henry/…
henry-deriv facca69
Merge branch 'master' of github.com:deriv-com/smarttrader into henry/…
henry-deriv 74320b9
merge conflict
henry-deriv 5c19cac
fix: make workflow trigger when production firebase config changes
henry-deriv 2363d4a
fix: resolve comments
henry-deriv 62ed179
fix: layout issue
henry-deriv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"cs_chat_livechat":true,"cs_chat_whatsapp":true,"marketing_growthbook":true,"passkeys":true,"tracking_GTM":true,"tracking_datadog":false,"tracking_hotjar":true,"tracking_rudderstack":true} | ||
{"cs_chat_livechat":true,"cs_chat_whatsapp":true,"marketing_growthbook":true,"passkeys":true,"tracking_GTM":true,"tracking_datadog":false,"tracking_hotjar":true,"tracking_rudderstack":true} |
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,51 @@ | ||
const ObjectUtils = require('@deriv-com/utils').ObjectUtils; | ||
const initData = require('../../_common/remote_config.json'); | ||
|
||
const RemoteConfig = (() => { | ||
let data = initData; | ||
let isEnabled = false; | ||
|
||
const remoteConfigQuery = async function () { | ||
const isProductionOrStaging = process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'staging'; | ||
const REMOTE_CONFIG_URL = process.env.REMOTE_CONFIG_URL || ''; | ||
if (isProductionOrStaging && REMOTE_CONFIG_URL === '') { | ||
throw new Error('Remote Config URL is not set!'); | ||
} | ||
const response = await fetch(REMOTE_CONFIG_URL); | ||
if (!response.ok) { | ||
throw new Error('Remote Config Server is out of reach!'); | ||
} | ||
return response.json(); | ||
}; | ||
|
||
const fetchAndUpdateData = async () => { | ||
if (!isEnabled) return data; | ||
|
||
try { | ||
const res = await remoteConfigQuery(); | ||
const resHash = await ObjectUtils.hashObject(res); | ||
const dataHash = await ObjectUtils.hashObject(data); | ||
if (resHash !== dataHash) { | ||
data = res; | ||
} | ||
} catch (error) { | ||
// eslint-disable-next-line no-console | ||
console.log('Remote Config error: ', error); | ||
} | ||
return data; | ||
}; | ||
|
||
const getRemoteConfig = async (enabled = false) => { | ||
isEnabled = enabled; | ||
if (isEnabled) { | ||
await fetchAndUpdateData(); | ||
} | ||
return { data }; | ||
}; | ||
|
||
return { | ||
getRemoteConfig, | ||
}; | ||
})(); | ||
|
||
module.exports = RemoteConfig; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, but will it work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can but i still have to update isEnabled. hence was using isEnabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aaa, okay, got it, then ignore me comment please