Add env to auto report new strings in console

Need to debounce to prevent over-reporting. 2s seems to be the minimum.
This commit is contained in:
infinite-persistence 2022-01-04 22:25:43 +08:00 committed by infinite-persistence
parent ec5a9802fc
commit 128e51a4f6
2 changed files with 10 additions and 1 deletions

View file

@ -117,7 +117,7 @@ ENABLE_WILD_WEST=true
BRANDED_SITE=odysee
LOADING_BAR_COLOR=#e50054
#FIREBASE
# FIREBASE
FIREBASE_API_KEY=AIzaSyAgc-4QORyglpYZ3qH9E5pDauEDOJXgM3A
FIREBASE_AUTH_DOMAIN=lbry-mobile.firebaseapp.com
FIREBASE_PROJECT_ID=lbry-mobile
@ -126,3 +126,6 @@ FIREBASE_MESSAGING_SENDER_ID=638894153788
FIREBASE_APP_ID=1:638894153788:web:35b295b15297201bd2e339
FIREBASE_MEASUREMENT_ID=G-2MPJGFEEXC
FIREBASE_VAPID_KEY=BFayEBpwMTU9GQQpXgitIJkfx-SD8-ltrFb3wLTZWgA27MfBhG4948pe0eERl432NzPrMKsbkXnA7ap_vLPgLYk
# Development
REPORT_NEW_STRINGS=false

View file

@ -5,6 +5,7 @@ const isProduction = process.env.NODE_ENV === 'production';
const localStorageAvailable = isLocalStorageAvailable();
window.i18n_messages = window.i18n_messages || {};
let reportTimer;
/**
* Collects new i18n strings encountered during runtime.
@ -26,6 +27,11 @@ function saveMessageWeb(message) {
if (!window.app_strings[message] && !window.new_strings[message]) {
window.new_strings[message] = removeContextMetadata(message);
// @if REPORT_NEW_STRINGS='true'
if (reportTimer) clearTimeout(reportTimer);
reportTimer = setTimeout(() => console.log(window.new_strings), 2000); // eslint-disable-line no-console
// @endif
}
// @endif
}