import { SDKBase, InstanceWithExtensions, TronicSDKExtensionsOption, TronicSDKAdditionalConfiguration } from 'tronic-provider'; import { IframeControllerConfig } from './iframe-controller'; import { LauncherController } from './launcher/controller'; import { LauncherConfig } from './launcher/types'; import { ViewModule } from './view-module'; import { ReceiverLoader } from './tracking/receiver-loader'; export * from './iframe-controller'; export * from './view-module'; export * from './launcher/simple-widget'; export * from './utils/css-in-js'; export * from 'tronic-provider'; export { ReceiverLoader } from './tracking/receiver-loader'; export * from './tracking/types'; /** * Advanced configuration options for the Tronic SDK * @internal */ interface TronicSDKConfiguration extends Partial { /** Configuration for the launcher widget */ launcher?: LauncherConfig; /** Configuration for the iframe controller */ iframe?: IframeControllerConfig; /** Tracking and analytics configuration */ tracking?: { /** Enable or disable tracking (default: true) */ enabled?: boolean; /** Enable debug mode for tracking */ debug?: boolean; /** API host for tracking endpoints */ apiHost?: string; /** Automatically track initial page view (default: true) */ initialPageview?: boolean; /** Auto-track clicks - true for all, or CSS selector for specific elements */ trackClicks?: boolean | string; /** Auto-track form submissions - true for all, or CSS selector for specific forms */ trackForms?: boolean | string; /** Automatically track outbound link clicks */ trackOutboundLinks?: boolean; /** Automatically track widget interactions */ autoTrackWidget?: boolean; }; } /** * Configuration parameters for initializing the Tronic SDK * @public */ interface TronicInitParams { /** API write key for authentication with Tronic services */ writeKey: string; /** URL for the widget iframe channel */ channelUrl: string; /** Optional API URL for backend services (defaults to production if not provided) */ apiUrl?: string; /** Position of the launcher widget on the page */ position?: 'bottom-left' | 'bottom-right' | 'top-right'; /** Theme for the widget appearance */ theme?: 'light' | 'dark'; /** Enable or disable tracking functionality (default: true) */ tracking?: boolean; /** Enable debug mode for development (default: false) */ debug?: boolean; /** Auto-track clicks - true for all elements, or CSS selector for specific elements */ trackClicks?: boolean | string; /** Auto-track form submissions - true for all forms, or CSS selector for specific forms */ trackForms?: boolean | string; /** Automatically track outbound link clicks */ trackOutboundLinks?: boolean; /** Automatically track widget interactions */ autoTrackWidget?: boolean; } /** * Main Tronic SDK class providing widget functionality and analytics tracking * * @example * ```typescript * import { TronicSDK } from 'tronic-sdk'; * * const tronic = TronicSDK.init({ * writeKey: 'your-api-key', * channelUrl: 'https://your-channel-url.com', * theme: 'dark', * position: 'bottom-right' * }); * * // Track events * tronic.trackEvent('button_clicked', { buttonId: 'signup' }); * * // Identify users * tronic.identifyUser('user123', { email: 'user@example.com' }); * ``` * * @public */ declare class TronicSDK extends SDKBase { /** View module for managing widget display and interactions */ readonly view: ViewModule; /** Optional launcher controller for widget positioning and appearance */ readonly launcher?: LauncherController; /** Tracking module for analytics and user behavior monitoring */ readonly tracking: typeof ReceiverLoader; /** * Initialize Tronic SDK with simplified configuration * * @param params - Configuration parameters for the SDK * @returns Initialized TronicSDK instance * * @example * ```typescript * const tronic = TronicSDK.init({ * writeKey: 'your-api-key', * channelUrl: 'https://your-channel-url.com', * theme: 'dark', * position: 'bottom-right', * debug: false * }); * ``` * * @public */ static init(params: TronicInitParams): TronicSDK; /** * Initialize Tronic SDK with legacy API (for backward compatibility) * * @param apiKey - API key for authentication * @param endpoint - Endpoint URL for the widget * @param options - Additional configuration options * @returns Initialized TronicSDK instance * * @deprecated Use the simplified init(params) method instead * @public */ static init(apiKey: string, endpoint: string, options?: Partial): TronicSDK; constructor(apiKey: string, options?: TronicSDKConfiguration); /** * Track a custom event with optional properties * * @param eventName - Name of the event to track * @param properties - Optional properties to associate with the event * * @example * ```typescript * tronic.trackEvent('button_clicked', { * buttonId: 'signup', * page: 'homepage', * variant: 'primary' * }); * ``` * * @public */ trackEvent(eventName: string, properties?: Record): void; /** * Track a page view with optional properties * * @param pageName - Optional name of the page (defaults to current URL) * @param properties - Optional properties to associate with the page view * * @example * ```typescript * tronic.trackPage('Product Page', { * category: 'electronics', * productId: '12345' * }); * ``` * * @public */ trackPage(pageName?: string, properties?: Record): void; /** * Identify a user with traits for personalized tracking * * @param userId - Unique identifier for the user * @param traits - Optional user traits and properties * * @example * ```typescript * tronic.identifyUser('user123', { * email: 'user@example.com', * firstName: 'John', * plan: 'premium' * }); * ``` * * @public */ identifyUser(userId: string, traits?: Record): void; /** * Track clicks on specific elements * * @param selector - CSS selector, element, or array of elements to track * @param eventName - Name of the event to track when clicked * @param properties - Optional properties to associate with the click event * * @example * ```typescript * tronic.trackClick('.cta-button', 'CTA Clicked', { * section: 'hero', * variant: 'primary' * }); * ``` * * @public */ trackClick(selector: string | Element | Element[], eventName: string, properties?: Record): void; /** * Track form submissions on specific forms * * @param selector - CSS selector, form element, or array of form elements to track * @param eventName - Name of the event to track when form is submitted * @param properties - Optional properties to associate with the form submission * * @example * ```typescript * tronic.trackForm('#newsletter-form', 'Newsletter Signup', { * source: 'footer', * variant: 'compact' * }); * ``` * * @public */ trackForm(selector: string | HTMLFormElement | HTMLFormElement[], eventName: string, properties?: Record): void; /** * Track clicks on link elements * * @param selector - CSS selector, element, or array of elements to track * @param eventName - Name of the event to track when link is clicked * @param properties - Optional properties to associate with the link click * * @example * ```typescript * tronic.trackLink('.external-link', 'External Link Clicked', { * destination: 'partner-site', * section: 'resources' * }); * ``` * * @public */ trackLink(selector: string | Element | Element[], eventName: string, properties?: Record): void; /** * Track screen or page transitions in single-page applications * * @param name - Name of the screen or view * @param properties - Optional properties to associate with the screen view * * @example * ```typescript * tronic.screen('Dashboard', { * userId: 'user123', * section: 'analytics' * }); * ``` * * @public */ screen(name: string, properties?: Record): void; /** * Associate a user with a group or organization * * @param groupId - Unique identifier for the group * @param traits - Optional traits and properties of the group * * @example * ```typescript * tronic.group('company123', { * name: 'Acme Corp', * plan: 'enterprise', * employees: 500 * }); * ``` * * @public */ group(groupId: string, traits?: Record): void; /** * Create an alias to link a new user ID with a previous ID * * @param userId - New user identifier * @param previousId - Previous user identifier to link (optional) * * @example * ```typescript * tronic.alias('user123', 'anonymous-uuid-456'); * ``` * * @public */ alias(userId: string, previousId?: string): void; /** * Reset the current user session and clear stored user data * * @example * ```typescript * tronic.resetUser(); // Clear user session on logout * ``` * * @public */ resetUser(): void; /** * Set up automatic user tracking when authentication state changes */ private setupUserTracking; } export { TronicSDK }; export declare const Tronic: import("tronic-provider").WithExtensions; export declare type Tronic = TronicSDKExtensionsOption> = InstanceWithExtensions;