AB Test - Experiment API
Depends on Experiment API to get AB Test configuration, calculation will be done on server side.
Pre-requisite
getServerSidePropsdata fetching
Flow
- Before fetching experiment config,
updateSessionTokenwill be called to fetch user session; Experiment API requirestvLifetime - Experiment config will be cached in the browser cookie for 1 minute; Cookie TTL won't be extended
- Experiment config will be fetched from API if not exists in cookie
- Fallback variant will be used if API call failed or timeout
Example
export const getServerSideProps: GetServerSideProps = async ctx => {
const config = await fetchExperimentConfig(ctx, {
// Required
namespace: 'experiment_namespace',
fallbackVariant: 'control',
// Optional
additionalInput: { ... }
});
return { ... }
};