
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
global-this-react-izanami
Advanced tools
react-izanami
is a simple set of React components to leverage the power of Izanami feature flipping and experiments.
In order to use the client you need to proxify Izanami to avoid leaking the credentials to the client side.
npm install react-izanami
import {IzanamiProvider, Feature, Enabled, Disabled, Experiment, Variant, Api as IzanamiApi} from 'izanami';
You can wrap your application in the izanami provider and let izanami fetch data from the proxy you have exposed:
<IzanamiProvider fetchFrom="/api/izanami">
{/* your app */}
</IzanamiProvider>
You can pass fallbacks in the case of the server is not up:
<IzanamiProvider fetchFrom="/api/izanami" featuresFallback={{my: {feature: {active: true}}}} experimentsFallback={{my:{experiment:{variant: 'B'}}}} >
{/* ... */}
</IzanamiProvider>
You can also pass features and experiments as props if you don't want the provider to fetch datas:
<IzanamiProvider features={{my: {feature: {active: true}}}} experiments={{my:{experiment:{variant: 'B'}}}} >
{/* ... */}
</IzanamiProvider>
You can trigger manual reload using the Api class. For example during router transition :
componentWillReceiveProps(nextProps) {
// will be true
const locationChanged = nextProps.location !== this.props.location;
if (locationChanged) {
//Reload izanami data on route change
IzanamiApi.izanamiReload("/api/izanami");
}
}
Once you the provider configured, you can switch code depending on a feature :
<Feature path="izanami.example.deleteAll">
<Enabled>
<tr>
<td></td>
<td></td>
<td></td>
<td><button type="button" className="btn btn-sm btn-default" onClick={this.deleteAll}>Delete done items</button></td>
</tr>
</Enabled>
<Disabled>
<tr></tr>
</Disabled>
</Feature>
Once you the provider configured, you can displayed a specific variant for an experiment :
{this.state.todoLists.map(l =>
<tr key={`td-${l.name}`}>
<td><Link to={`/todos/${l.name}`} >{l.name}</Link></td>
<td>{l.user}</td>
<td>
<Experiment path={"izanami:example:button"} notifyDisplay="/api/izanami/experiments/displayed" >
<Variant id={"A"}>
<Link to={`/todos/${l.name}`} onClick={this.onTodosClick} className="btn btn-sm btn-default"><i className="fas fa-eye" aria-hidden="true" /></Link>
<button className="btn btn-sm btn-default" onClick={this.removeTodoList(l.name)}><i className="glyphicon glyphicon-trash" /></button>
</Variant>
<Variant id={"B"}>
<Link to={`/todos/${l.name}`} onClick={this.onTodosClick} className="btn btn-sm btn-primary"><i className="glyphicon glyphicon-pencil" /></Link>
<button className="btn btn-sm btn-primary" onClick={this.removeTodoList(l.name)}><i className="glyphicon glyphicon-trash" /></button>
</Variant>
</Experiment>
</td>
</tr>
)}
If specified, the notifyDisplay
field will call the registered url to notify Izanami that the current variant is displayed.
You have to call yourself Izanami when a variant won because the react client can't decide this for you :).
In this example, the variant won if the client click on the button.
For that we will do an http POST on /api/izanami/experiments/won
when the client click on the link using this function :
export function notifyWon(key) {
return fetch(`/api/izanami/experiments/won?experiment=${key}`, {
method: 'POST',
credentials: 'include',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
});
}
and then when the client click on the link:
onTodosClick = () => {
Service.notifyWon("izanami:example:button");
};
FAQs
A set of React Component to use izanami idiomatically
We found that global-this-react-izanami demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.