SDK Reference

SDK Reference

Core Methods

PricePilot.init(config)

Initialize the Price Pilot SDK.

interface PricePilotConfig {
  apiKey: string;
  domain: string;
  debug?: boolean;
}

PricePilot.init(config: PricePilotConfig): Promise<void>

PricePilot.createTest(config)

Create a new A/B test.

interface TestConfig {
  name: string;
  variants: {
    id: string;
    weight: number;
    config: object;
  }[];
}

PricePilot.createTest(config: TestConfig): Promise<Test>

PricePilot.track(event)

Track conversion events.

interface TrackEvent {
  type: 'view' | 'click' | 'conversion';
  metadata?: Record<string, any>;
}

PricePilot.track(event: TrackEvent): Promise<void>

Events

The SDK emits the following events:

  • ready: SDK is initialized and ready
  • variantAssigned: User has been assigned to a variant
  • conversion: Conversion event has been tracked

Error Handling

try {
  await PricePilot.init({ apiKey: 'invalid' })
} catch (error) {
  if (error instanceof PricePilotError) {
    console.error('SDK Error:', error.message)
  }
}

Copyright © 2025. All rights reserved.