/** * Type definitions for Tronic tracking functionality */ /** * Configuration for the ReceiverLoader tracking system */ export interface TrackingConfig { /** 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; } /** * Common event properties that can be included with any tracking event */ export interface TrackingProperties { /** Timestamp of the event */ timestamp?: string; /** Version of the SDK */ sdk_version?: string; /** Whether this was auto-tracked */ auto_tracked?: boolean; /** Any additional custom properties */ [key: string]: any; } /** * Properties specific to page tracking events */ export interface PageTrackingProperties extends TrackingProperties { /** Page path */ path?: string; /** Full page URL */ url?: string; /** Page title */ title?: string; /** Referrer URL */ referrer?: string; /** Whether this is from SPA navigation */ from_spa_navigation?: boolean; /** Current widget position */ widget_position?: string; /** Current widget theme */ widget_theme?: string; } /** * User identification traits */ export interface UserTraits { /** User's email address */ email?: string; /** User's first name */ firstName?: string; /** User's last name */ lastName?: string; /** User's full name */ name?: string; /** User's wallet address */ walletAddress?: string; /** Whether email is verified */ emailVerified?: boolean; /** Source of the identification */ source?: string; /** Any additional user traits */ [key: string]: any; } /** * Group/organization traits */ export interface GroupTraits { /** Group/organization name */ name?: string; /** Industry */ industry?: string; /** Number of employees */ employees?: number; /** Plan type */ plan?: string; /** Any additional group traits */ [key: string]: any; } /** * Screen/view tracking properties */ export interface ScreenProperties extends TrackingProperties { /** Name of the screen/view */ name?: string; /** Category of the screen */ category?: string; /** Any additional screen properties */ [key: string]: any; } /** * Click tracking properties */ export interface ClickProperties extends TrackingProperties { /** Text content of the clicked element */ element_text?: string; /** ID of the clicked element */ element_id?: string; /** Class names of the clicked element */ element_classes?: string; /** Type of element (button, link, etc.) */ element_type?: string; /** For links, the destination URL */ link_url?: string; /** Whether it's an outbound link */ outbound?: boolean; } /** * Form tracking properties */ export interface FormProperties extends TrackingProperties { /** Form ID */ form_id?: string; /** Form name */ form_name?: string; /** Form action URL */ form_action?: string; /** Form method (GET, POST, etc.) */ form_method?: string; /** Type of form (signup, contact, etc.) */ form_type?: string; } /** * Widget interaction properties */ export interface WidgetProperties extends TrackingProperties { /** Type of widget interaction */ interaction_type?: 'open' | 'close' | 'button_click' | 'tab_change' | 'form_submit'; /** Widget state */ widget_state?: 'opened' | 'closed' | 'minimized'; /** For button clicks, the button text */ button_text?: string; /** For button clicks, the button ID */ button_id?: string; /** Current widget position */ position?: string; /** Current widget theme */ theme?: string; } /** * Campaign/UTM parameters */ export interface CampaignProperties { /** UTM source parameter */ utm_source?: string; /** UTM medium parameter */ utm_medium?: string; /** UTM campaign parameter */ utm_campaign?: string; /** UTM term parameter */ utm_term?: string; /** UTM content parameter */ utm_content?: string; } /** * Main tracking interface exposed on TronicSDK instance */ export interface TrackingInterface { /** Track a custom event */ trackEvent(eventName: string, properties?: TrackingProperties): void; /** Track a page view */ trackPage(pageName?: string, properties?: PageTrackingProperties): void; /** Identify a user */ identifyUser(userId: string, traits?: UserTraits): void; /** Track clicks on elements */ trackClick(selector: string | Element | Element[], eventName: string, properties?: ClickProperties): void; /** Track form submissions */ trackForm(selector: string | HTMLFormElement | HTMLFormElement[], eventName: string, properties?: FormProperties): void; /** Track link clicks */ trackLink(selector: string | Element | Element[], eventName: string, properties?: ClickProperties): void; /** Track screen/view changes */ screen(name: string, properties?: ScreenProperties): void; /** Associate user with a group/organization */ group(groupId: string, traits?: GroupTraits): void; /** Create an alias for a user */ alias(userId: string, previousId?: string): void; /** Reset user data (typically on logout) */ resetUser(): void; } /** * Static ReceiverLoader interface */ export interface ReceiverLoaderStatic { /** Initialize the tracking system */ initialize(config: TrackingConfig & { apiKey: string; apiHost: string; }): void; /** Check if tracking is initialized */ isInitialized(): boolean; /** Get the receiver instance */ getReceiver(): any; /** Reset the loader (for testing) */ reset(): void; trackEvent(eventName: string, properties?: TrackingProperties): void; trackPage(pageName?: string, properties?: PageTrackingProperties): void; identifyUser(userId: string, traits?: UserTraits): void; trackClick(selector: string | Element | Element[], eventName: string, properties?: ClickProperties): void; trackForm(selector: string | HTMLFormElement | HTMLFormElement[], eventName: string, properties?: FormProperties): void; trackLink(selector: string | Element | Element[], eventName: string, properties?: ClickProperties): void; screen(name: string, properties?: ScreenProperties): void; group(groupId: string, traits?: GroupTraits): void; alias(userId: string, previousId?: string): void; resetUser(): void; }