
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
@automattic/calypso-config
Advanced tools
This module reads config data from window.configData
(passed from the Node.js
server in the HTML response) and initializes a config
object that is
used to read these values.
You can read more about how to use config
in the
config documentation.
The config files contain a features object that can be used to determine whether to enable a feature for certain environments. This allows us to merge in-progress features without launching them to production.
Is a feature enabled?
import config from '@automattic/calypso-config';
if ( config.isEnabled( 'myFeature' ) ) {
// do something only when myFeature is enabled
}
Enable a feature.
import config from '@automattic/calypso-config';
config.enable( 'myFeature' );
Disable a feature.
import config from '@automattic/calypso-config';
config.disable( 'myFeature' );
The key should always be a literal string not a variable so that down the road we can process the compiled scripts and remove code for disabled features in production.
When Calypso is running in development mode or in the stage
environment, you
can specify a ?flags=
query argument or a flags
cookie to modify feature
flags for each full page load.
Query argument examples:
?flags=flag1
: Enable feature flag1
.?flags=-flag2
: Disable feature flag2
.?flags=+flag1,-flag2
: Enable feature flag1
and disable feature flag2
.You can use the same syntax in a cookie or via session storage
Cookies:
document.cookie = 'flags=+flag1,-flag2;max-age=1209600;path=/';
: Enable feature flag1
and disable feature flag2
.document.cookie = 'flags= ; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;';
: Reset flags cookie to config values.Session Storage:
window.sessionStorage.setItem( 'flags', 'flag1,-flag2' );
: Enable feature flag1
and disable feature flag2
.window.sessionStorage.removeItem( 'flags' );
: Reset flags session item to config values.Note: the flags
query argument, cookie, and sessionStorage won't work for feature flags used by Node.js
server. For this case, you can use the
ENABLE_FEATURES
and/or DISABLE_FEATURES
environment variables instead.
We often need to enable or disable certain features not only based on the Calypso environment
(development, production, staging, horizon, ...) but also when Calypso runs in the calypso.live
testing environment. The config
module exports a helper function isCalypsoLive
that returns
true
if Calypso is running on the *.calypso.live
origin.
import { isCalypsoLive } from '@automattic/calypso-config';
if ( isCalypsoLive() ) {
/* ... */
}
FAQs
The Calypso configuration API.
We found that @automattic/calypso-config demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 67 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.