[READ ONLY] This repository is a mirror, for issue tracking and development head to: https://github.com/automattic/jetpack
OTHER License
A package for running A/B tests on the Experimentation Platform (ExPlat) in the plugin.
Run composer require automattic/jetpack-explat
and pnpm install -S "@automattic/jetpack-explat"
in the root folder of your project.
In the PHP method that initializes your project, call the following static method to initialize the ExPlat API and register its endpoints:
use Automattic\Jetpack\ExPlat;
ExPlat::init();
In your React code, import the Experiment
component and start running experiments:
import { Experiment } from '@automattic/jetpack-explat';
const DefaultExperience = <div>__( 'Control title' )</div>;
const TreatmentExperience = <div>__( 'Treatment title' )</div>;
const LoadingExperience = <div>⏰</div>;
<Experiment
name="jetpack_example_experiment"
defaultExperience={ DefaultExperience }
treatmentExperience={ TreatmentExperience }
loadingExperience={ LoadingExperience }
/>;
If you plan on using this package in your WordPress plugin, we would recommend that you use Jetpack Autoloader as your autoloader. This will allow for maximum interoperability with other plugins that use this package as well.
Need to report a security vulnerability? Go to https://automattic.com/security/ or directly to our security bug bounty site https://hackerone.com/automattic.
Jetpack ExPlat is licensed under GNU General Public License v2 (or later)