/** * Expose capability for adding plugin methods to SDK instance. * * Plugins use this to add public API methods that users can call. * Methods are merged directly onto the SDK instance. * * @example * ```typescript * const expose = new Expose(sdkInstance); * expose.expose({ * track(event: string) { * console.log('Tracking:', event); * } * }); * // Now: sdk.track('page_view'); * ``` */ export class Expose { private sdk: any; /** * Create an Expose instance. * * @param sdk - SDK instance to expose methods on */ constructor(sdk: any) { this.sdk = sdk; } /** * Expose methods on the SDK instance. * * Merges the provided methods object onto the SDK instance, * making them available as `sdk.methodName()`. * * @param api - Object containing methods to expose * * @example * ```typescript * expose.expose({ * track(event: string, properties?: any) { * // Track event * }, * identify(userId: string) { * // Identify user * } * }); * * // Available as: * // sdk.track('page_view', { path: '/home' }); * // sdk.identify('user-123'); * ``` */ expose(api: Record): void { Object.assign(this.sdk, api); } }