Skip to main content

AB Test - Experiment API

Depends on Experiment API to get AB Test configuration, calculation will be done on server side.

Pre-requisite

  • getServerSideProps data fetching

Flow

  • Before fetching experiment config, updateSessionToken will be called to fetch user session; Experiment API requires tvLifetime
  • 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 { ... }
};

Reference