UNPKG

payload-ab

Version:

Payload CMS plugin for A/B testing with PostHog

61 lines (60 loc) 1.71 kB
import type { Config } from 'payload'; export interface ABTestingPluginOptions { /** * Configuration for collections that should have A/B testing fields * Can be either an array of collection slugs or an object with more detailed configuration */ collections: Record<string, ABCollectionConfig> | string[]; /** * Enable or disable the plugin * @default false */ disabled?: boolean; /** * PostHog configuration options */ posthog?: PostHogConfig; } /** * PostHog configuration options */ export interface PostHogConfig { /** * PostHog project API key */ apiKey?: string; /** * PostHog feature flag key to use for this experiment * If not provided, one will be generated based on the collection slug */ featureFlagKey?: string; /** * PostHog host URL * @default 'https://app.posthog.com' */ host?: string; } export interface ABCollectionConfig { /** * Enable or disable A/B testing for this collection * @default true */ enabled?: boolean; /** * Fields to exclude from the A/B variant * Only used when fields is not specified * @default ['id', 'createdAt', 'updatedAt'] */ excludeFields?: string[]; /** * Fields to include in the A/B variant * If not specified, all fields will be included except system fields */ fields?: string[]; } /** * Payload CMS plugin for A/B testing with PostHog * Adds an optional abVariant field group to specified collections */ export declare const abTestingPlugin: (pluginOptions: ABTestingPluginOptions) => (incomingConfig: Config) => Config; export default abTestingPlugin;