import type { ConsentConfig, StoredConsent, ConsentCategories, GeoDetectionResult, GeoDetectionLogEntry, GA4EcommerceParams, GA4PurchaseParams, GA4GenerateLeadParams } from "./types"; import type { SupportedLocale } from "../i18n/types"; /** * US states with comprehensive consumer privacy laws (CCPA-like). * Stored in lowercase for case-insensitive matching. */ export declare const CCPA_REGIONS: Set; /** * Consent Manager - orchestrates consent flow */ export declare class ConsentManager { private config; private locale; private initialized; private isEU; private geoResult; private geoDetectionLog; private userId; private remoteStorage; private showBannerCallback; private hideBannerCallback; private showPreferenceCenterCallback; private hidePreferenceCenterCallback; private scriptBlockerCleanup; private routerCleanup; private bannerPending; private preferenceCenterPending; private consentChangeListeners; constructor(config?: ConsentConfig); /** * Register callback to show banner. * If init() already requested the banner before this callback was registered, * fires immediately (handles race condition with component mount timing). */ onShowBanner(callback: () => void): void; /** * Register callback to hide banner */ onHideBanner(callback: () => void): void; /** * Register (or clear) callback to show preference center. * Pass null to unregister. * If showPreferenceCenter() was called before this callback was registered, * fires immediately (same race-condition handling as banner). */ onShowPreferenceCenter(callback: (() => void) | null): void; /** * Register (or clear) callback to hide preference center. * Pass null to unregister. */ onHidePreferenceCenter(callback: (() => void) | null): void; /** * Register a listener that fires whenever consent categories change. * Used internally by the script blocker; also available for external consumers. */ onConsentChange(listener: (categories: Omit) => void): void; /** * Programmatically show the preference center modal */ showPreferenceCenter(): void; /** * Get the resolved locale */ getLocale(): SupportedLocale; /** * Initialize consent manager */ init(): Promise; /** * Persist consent locally and (if remote storage is configured) remotely. * Sets cookies only when at least one non-necessary category is accepted. * Fire-and-forget: remote push does not block UI. */ private saveConsentWithRemote; /** * Perform geo detection and update instance state. * Centralizes geo detection logic to avoid duplication across init flows. * Sets this.isEU, this.geoResult, and this.geoDetectionLog. * @returns The geo detection result * @throws If geo detection fails (caller should handle) */ private performGeoDetection; /** * Check if user has roamed to EU and needs re-consent. * Called when stored consent was given outside EU (isEU=false or undefined). * Returns true if user is now in EU and needs to re-consent. */ private checkRoamingToEU; /** * Apply consent settings */ private applyConsent; /** * Accept all cookies */ acceptAll(): Promise; /** * Reject all non-essential cookies */ rejectAll(): Promise; /** * Save custom preferences */ savePreferences(categories: Partial>): Promise; /** * Get current consent state */ getConsent(): StoredConsent | null; /** * Check if user has made a consent choice */ hasConsent(): boolean; /** * Reset consent (show banner again) */ resetConsent(): void; /** * Track a page view manually (for SPA navigation). * Skips sending if analytics consent is explicitly denied. * Before user makes a choice, page views are sent under Consent Mode defaults (cookieless pings). */ trackPageView(path: string, title?: string): void; /** * Track a custom event (GA4 recommended events, ecommerce, or custom). * Skips sending if analytics consent is explicitly denied. * Before user makes a choice, events are sent under Consent Mode defaults (cookieless pings). * * @param eventName - GA4 event name (e.g., 'sign_up', 'purchase', 'add_to_cart') * @param params - Event parameters * * @example * ```typescript * manager.trackEvent('sign_up', { method: 'email' }); * manager.trackEvent('purchase', { transaction_id: 'T_123', value: 99.99, currency: 'USD', items: [...] }); * ``` */ trackEvent(eventName: string, params?: Record): void; /** * Track a purchase event with typed parameters. * @see https://developers.google.com/analytics/devguides/collection/ga4/ecommerce */ trackPurchase(params: GA4PurchaseParams): void; /** * Track add_to_cart event. */ trackAddToCart(params: GA4EcommerceParams): void; /** * Track begin_checkout event. */ trackBeginCheckout(params: GA4EcommerceParams): void; /** * Track view_item event. */ trackViewItem(params: GA4EcommerceParams): void; /** * Track view_item_list event. */ trackViewItemList(params: Omit & { item_list_id?: string; item_list_name?: string; }): void; /** * Track select_item event (click on product in list). */ trackSelectItem(params: Omit & { item_list_id?: string; item_list_name?: string; }): void; /** * Track add_shipping_info event. */ trackAddShippingInfo(params: GA4EcommerceParams & { shipping_tier?: string; }): void; /** * Track add_payment_info event. */ trackAddPaymentInfo(params: GA4EcommerceParams & { payment_type?: string; }): void; /** * Track sign_up event. * @param method - Registration method (e.g., 'email', 'google', 'facebook') */ trackSignUp(method?: string): void; /** * Track login event. * @param method - Login method (e.g., 'email', 'google', 'facebook') */ trackLogin(method?: string): void; /** * Track generate_lead event (form submission, contact request). */ trackGenerateLead(params?: GA4GenerateLeadParams): void; /** * Check if consent manager has been initialized */ isInitialized(): boolean; /** * Check if user is detected as EU */ isEUUser(): boolean | null; /** * Check if user is in a CCPA-covered US state (California, Virginia, Colorado, etc.). * Returns true only if ccpaEnabled is true in config and user is in a covered region. * Matching is case-insensitive to handle variations in geo API responses. */ isCCPAUser(): boolean; /** * Get the region/state detected for the user. * Returns undefined if region detection has not run or region is not available. */ getRegion(): string | undefined; /** * Get geo-detection result (countryCode, region, method, isEU). * Returns null if geo detection has not run yet. * Note: When consent is restored from cookie, this returns the stored geo result. */ getGeoResult(): GeoDetectionResult | null; /** * Get geo-detection log showing all methods attempted with their results. * Useful for debugging geo-detection issues in the debug panel. * Returns empty array if geo detection has not run yet. */ getGeoDetectionLog(): GeoDetectionLogEntry[]; /** * Get configuration */ getConfig(): ConsentConfig; /** * Register router tracking cleanup function. * Called internally by setupRouterTracking when used with the Vue plugin. * @internal */ setRouterCleanup(cleanup: (() => void) | null): void; /** * Clean up resources (script blocker observer, router tracking, etc.). * Call when unmounting the app. */ destroy(): void; } /** * Create a new ConsentManager instance */ export declare function createConsentManager(config?: ConsentConfig): ConsentManager;