automattic / jetpack-explat
A package for running A/B tests on the Experimentation Platform (ExPlat) in the plugin.
Installs: 1 305
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Language:TypeScript
Type:jetpack-library
Requires
- php: >=7.2
- automattic/jetpack-connection: ^6.0.0
Requires (Dev)
- automattic/jetpack-changelogger: ^5.0.0
- yoast/phpunit-polyfills: ^1.1.1
Suggests
- automattic/jetpack-autoloader: Allow for better interoperability with other plugins that use this package.
README
A package for running A/B tests on the Experimentation Platform (ExPlat) in the plugin.
How to install Jetpack ExPlat
Run composer require automattic/jetpack-explat
and pnpm install -S "@automattic/jetpack-explat"
in the root folder of your project.
Using this package in your WordPress plugin
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.
Security
Need to report a security vulnerability? Go to https://automattic.com/security/ or directly to our security bug bounty site https://hackerone.com/automattic.
License
Jetpack ExPlat is licensed under GNU General Public License v2 (or later)