@billdog.io/core
v1.0.0-beta.1
Published
Platform-agnostic core for BillDog SDK
Maintainers
Readme
@billdog.io/core
Platform-agnostic core for BillDog SDK v1.0.0.
Overview
This package provides the core functionality for the BillDog SDK. It is designed to be platform-agnostic and is extended by platform-specific implementations (React Native, iOS, Android, Web, etc.).
Features
- 🎯 Configuration Management - Centralized SDK configuration
- 🌐 API Client - HTTP client for BillDog API
- 💳 Paywall Management - Fetch and cache paywall configurations
- 👤 Customer Management - Track customer info and entitlements
- 🛒 Purchase Management - Platform-agnostic purchase handling (requires delegate)
- 📦 Module System - Plugin architecture for optional features
Installation
npm install @billdog.io/coreNote: This package is typically not installed directly. Use platform-specific packages instead:
@billdog.io/react-nativefor React Native@billdog.io/webfor web applicationsBillDog(CocoaPods) for iOScom.billdog:core(Maven) for Android
Usage
Basic Configuration
import { BillDogCore } from '@billdog.io/core';
const sdk = new BillDogCore();
sdk.configure({
apiKey: 'bd_live_...',
environment: 'production',
enableLogging: true,
});Fetch Paywall
const paywall = await sdk.fetchPaywall('premium_offer');
if (paywall) {
console.log('Paywall components:', paywall.components);
}Customer Info
const customer = await sdk.getCustomerInfo('user-123');
if (customer) {
console.log('Active subscriptions:', customer.activeSubscriptions);
}
// Check entitlement
const hasPremium = sdk.hasEntitlement('premium');Track Events
await sdk.trackEvent('paywall_viewed', {
paywallId: 'premium_offer',
placement: 'onboarding',
});Using Modules
import { BillDogCore } from '@billdog.io/core';
import { Analytics } from '@billdog.io/analytics';
const sdk = new BillDogCore();
sdk.configure({
apiKey: 'bd_live_...',
modules: [Analytics],
});
// Or register after configuration
sdk.use(Analytics);Architecture
The core SDK is organized into managers:
- ConfigManager - Handles configuration and module registration
- ApiClient - Makes HTTP requests to BillDog API
- PaywallManager - Fetches and caches paywall configurations
- CustomerManager - Manages customer information
- PurchaseManager - Handles purchases (requires platform-specific delegate)
Platform-Specific Implementations
Platform-specific SDKs extend the core and provide:
- Purchase delegate implementation (StoreKit, Google Play Billing, etc.)
- UI components for rendering paywalls
- Platform-specific storage (AsyncStorage, UserDefaults, SharedPreferences)
- Native module bridges (for React Native)
Size
- Minified + Gzipped: ~45KB
- Tree-shakeable: Yes
API Reference
See API Documentation for complete API reference.
License
MIT
